# Cannon Rotating

**URL:** https://forum.kirupa.com/t/cannon-rotating/184929
**Category:** programming
**Created:** [April 9, 2006, 11:35am UTC](https://forum.kirupa.com/t/cannon-rotating/184929 "2006-04-09T11:35:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![darc10222](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@darc10222](https://forum.kirupa.com/u/darc10222)
#### Post date: [April 9, 2006, 11:35am UTC](https://forum.kirupa.com/t/cannon-rotating/184929/1 "2006-04-09T11:35:24Z")

</div>

Hey I need a code to make the shooting part of my cannon rotate. Ive got a MC called theCannon and then inside it a MC called base which is the bottom part and another one in theCannon called head which is the part that is gonna shoot out whatever bullet/laser/cannonball or whatever. An very good example is [http://www.newgrounds.com/portal/view/305865](http://www.newgrounds.com/portal/view/305865).  
Thanks in Advance.  
:mu:  
[EDIT]I forgot to mention I want it to rotate with the mouse.

---

<div class="post-metadata">

### Author: ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)
#### Post date: [April 9, 2006, 11:44am UTC](https://forum.kirupa.com/t/cannon-rotating/184929/2 "2006-04-09T11:44:18Z")

</div>

```auto
if(Key.isDown(Key.RIGHT)){
this._rotate --;
}
if(Key.isDown(Key.LEFT)){
this._rotate ++;
}

```

// For shooting you’ll need physics

---

<div class="post-metadata">

### Author: ![darc10222](https://avatars.discourse-cdn.com/v4/letter/d/bb73d2/32.png) [@darc10222](https://forum.kirupa.com/u/darc10222)
#### Post date: [April 9, 2006, 11:59am UTC](https://forum.kirupa.com/t/cannon-rotating/184929/3 "2006-04-09T11:59:57Z")

</div>

Oops sorry. I forgot to mention I want it to rotate with the mouse.

---

<div class="post-metadata">

### Author: ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)
#### Post date: [April 9, 2006, 12:11pm UTC](https://forum.kirupa.com/t/cannon-rotating/184929/4 "2006-04-09T12:11:51Z")

</div>

> **[Making a game like A.L.I.A.S.](https://www.kirupa.com/forum/showthread.php?t=90914&highlight=platform)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

That should help you 😉
