Posted May 07, 2022 by Moosadee
#trigonometry #crank
Just some small demos today dealing with the crank and trigonometry. :)
Under Lua/08_Crank you'll find a basic demo that draws a line from the center of the screen to an x, y position based on the crank position using cosine and sine. I added some rudimentary comments. You could use this demo to help you create a game where you aim with the crank and have a bullet follow that line.
MoosieTron is inspired by RoboTron. You can move with the DPAD, aim with the crank, and shoot with the B button, though on an actual PlayDate this would actually be really hard to control! But it's an example. The bullets will fly straight along the path based on the angle the player was aiming when they shot the bullet.
Gorillas.BAS was a game where you'd type in an angle and the gorilla would shoot a banana at that angle. This is just a simple demo of aiming with the crank and the bananas falling due to "gravity" over time.
This isn't really useful as a game but I was just playing around with drawing stuff based on crank position. This line moves forward and its Y position changes based on the sine of the crank angle.
Enjoy!