I'm totally new here but got an idea for a small game. A guy has to stay on a wheel which would start to spin if he's not right above it's center point. So I would need to somehow implement lever rules and I would need to rotate the wheel but I really don't know how to do this.
I already took a look at this but really don't understand the code. The first one seems a bit buggy, the second works fine but I can't find the point where the sprite is assigned to the car table.
so to start I would've thought of something simple like this
------------- (get the rotated sprite and draw it)
rotate_wheel(1) (add's one degree of rotation every frame (does not have to be 1°))
So in a sentence I want a sprite that get's rotated with ever frame by a certain amount.
Instead of rotating and blitting a sprite, you could draw the wheel using line drawing functions like LINE() and CIRC().
Like, say, a circle for the rim and a series of lines through the center point as spokes, and some individual pixels at various points for decoration. Calculate the angle of rotation on any given frame, do a little cos() and sin() math to offset the endpoints of your lines and points, et voila.
I do a really simple version of this with just straight lines in this cart to make those sticks and crosses, for example.
Another approach, depending on how much sprite sheet you want to use and how big your wheel is, is to actually pre-render each of your rotational frames as individual sprites, and just display the correct one each frame.
If your wheel has a lot of rotational symmetry, you can pull this off smoothly with relatively few sprites, even; a wheel with, say, 8 spokes that are evenly spaced only needs to rotate through 1/8th of a circle before it looks like you're back where you're started, so you could do frames enough to do 1/8th of a turn in smooth small increments and then just cycle back to the start of that sprite sequence for the 1/8th threshold, 2/8ths, etc.
So I had some success with the sprit rotation. I found a cartridge which already did what I needed and altered a little bit to fit my needs. However there seems to be a problem with the algorithm since the whole screen is "falling".
I kinda like the rugged look of the rotation algorithm so I would like to fix it and keep that. But it seems I really have to get my hands on the algorithm myself. Googled a lot but haven't found something valuable about per pixel image rotation.
I think the "falling" is just an effect caused by the print statement each draw advancing the cursor down the screen, forcing a scroll.
If you called CLS() to clear the old screen, CURSOR() to reset the cursor, or printed at specific coordinates it might help.
Hi, if you like, you could use this function ?
Does the same as SPR and apply a rotation of the angle A to the sprite. The rotation is applied to the center of the sprite.
[Please log in to post a comment]