asteriod - how to make one rotate - Help!!

Hey guys. I am making a game and in it, there are asteroids slowly going across the screen.
is there a way to make them slowly rotate while moving?
ps im new to codea

try this. If you’re new, there will be several lines that don’t make sense - in which case I suggest you read some of the tutorials in the wiki link above. I have an ebook there that may help you understand Codea’s drawing

    pushMatrix()  --remember the current drawing setup
    --then, for each asteroid
    translate(x,y)  --move drawing centre to x,y, where x,y is asteroid's new position
    rotate(a)  --where a is angle in degrees
    sprite(image,0,0) --where image is the asteroid image
    --when you're done with all asteroids, put the next line to reset the drawing centre


@Ignatz, your ebook is very very comprehensive and clear with a lot of pictures. It would be great to read it with all supports in epub format if it’s possible.

hmm what you gave me doesnt seem to be working
just to clarify, the asteriod needs to continuously rotate, not be rotated to a certain angle

@OwenClaxton create a new variable in the setup function angInt = 0 then in the draw function put angInt = angInt + 1 then use angInt in the rotate function

it wont let me put anything besides numbers in the rotate()

@OwenClaxton That is the only thing you can put inside them,

@OwenClaxton What were you trying to put in the rotate function?

I think he was trying to do something like 45°
or something like 44° 13’ 43"

but yes you can only work with numbers, where 45 = 45° and 360 = 360° etc etc

idk if you can work with floats @OwenClaxton

@stevon8ter @OwenClaxton Digits work. Besides, even integers get converted to digits, as there’s only a “number” type in Codea, no separate type for ints.

i was trying to do:
m = 0
m = m + 1
i dont know what else to do

@OwnClaxton Are you resetting it back to 0 every frame then?

@OwenClaxton If that code is in draw, m will always be 1. Try putting m = 0 in setup, and keeping m = m + 1 in draw. In setup, it first defines the variable m as a number with the value of 0. In draw, every frame, it adds 1 to m. The first frame, m would be 1, the next 2, the third 3, etc.

I think Owen really needs to do some tutorials

i did some… but its for school and i dont have very long to whip something up thats moderately decent

The user and all related content has been deleted.

I have over 100 tutorials and most of an ebook, on Codea, and a whole ebook on Lua - see the wiki link above. And there are many others there, too.

@NatTheCoder @OwenClaxton I believe the only tutorials on Codea are by Prynok.

There are probably non-Codea based Lua tutorials, though.

im reading the ebook :slight_smile: its helping alot