I created a recreation of Turbo Fly. Turbo Fly is a mobile 3D game where you tilt the phone to guide a hovercraft around a track. Some levels you race against other craft (run by the computer), and others are endurance rounds and you see how many laps you can make without hitting the wall too much and too long. One of the tracks is in space, and instead of walls you fall into the void below. This style of track in an endurance round is what I recreated.
You can play on PC with the left and right arrow keys, and I haven’t had a chance to test the mobile controls.
I created this with a combination of lists, trigonometry, and the 3D beetle library. Basically, the 3D rendering is handled by the library, but I have a list of all the points on the track which I then compare the ship’s (beetle’s) coordinates to using trigonometry. I also went so far as to allow you to jump off of one part of the track and onto another (just like in the original).
PS: There is a way to skip half the level if you’re sneaky…
The tilt controls seem to be reversed. Tilting to the left makes you turn right, and tilting to the right makes you turn left. I’m not sure if you are aware, but the tilt controls currently work in a way that you don’t physically tilt the device, you just change the direction it’s facing (the same direction as if you were turning a computer around to show the person in front of you). If this is how you want them you can leave them as is! I just mentioned this in case this was not how you wanted the tilt controls to work.
Ah. I don’t have access to a phone or other device to test it on. I’ve now changed it from tilt z to tilt x; hopefully that is correct…? I also don’t know if this means the controls will still be reversed…
I just went back to test it out. I figured out that the correct tilt, if you want the player to tilt their phone side to side, is tilt y. I think the controls are still reversed, but idk, since I am testing this on a Chromebook at school. When I get home, around 3:00 p.m (in my time), I will test the program on my phone.
This is a cool game. If I find the time I will make a version where you can use for instance a microbit to control the ship by looking at the tilt of the microbit.
The tilt controls just don’t work for me. No matter which way I tilt, it’s always facing left.
After testing in my tilt testing project that I just made, tilting left and right seem to be the tilt x. Positive is to the right, and nrgative is to the left. The max value I was getting was about 50 (or well, at a reasonable max tilt angle). Looking at your code, the issue really is that you’re assuming it’s in the range of 45-135, which only gives anything above 45 if I tilt my phone so it’s completely on its side.
Edit: after some experimentation, this works great.
Alright, I got ahold of a phone and it should work now (assuming the tilt block works the same for all devices).
Yeah. I did need to limit it to some range though; in the original game too there was a limit to how far you could turn. That just wasn’t the correct one :).
Additionally, I noticed that the performance on the phone was bad enough that the speed at which the flyer moved around the track was significantly decreased. The program will now dynamically change the increments at which the flyer moves and the frequency at which it updates the screen to compensate. I did put an upper limit to ensure that you can still control the thing, and with reasonable frames, however.
Unfortunately, I don’t have that implemented and don’t think I can. The challenge is that I would have to render a moving object in the 3D Beetle space, which only allows you to have stationary objects; and only lets you clear the entire environment. To include that functionality, I would have to drop the 3D Beetle Geometry library altogether.