I’ve had this idea in my head for a while, and it fit perfectly with the Collection theme. It’s inspired by Pivvot, Brick Roll, and Mr. Ninja. It also works well, because my idea can be implemented using basic shapes and no fancy graphics.
I wasn’t sure I could get it done, but I did and I’m really happy with the result.
(final screenshot)
Basic idea is rotating planets with a dot that can jump between them to collect coins.
0:00-1:00 – Planet and coin setup
Took the first hour to get the planets and coins setup. I had to iterate over all the planets and coins to make sure they weren’t drawn over each other, and to make sure that they had a minimum safe distance between each other and the edges of the screen.
The planets have a random radius with a random rotation direction and speed. They also have a marker so we can actually see which way they are rotating. I put both the planets and markers in their own display group so I could rotate that instead of each individual object.
1:00-2:00 – Physics and intersections
I considered using real corona physics briefly, but decided to just plot my own positions and do my own collision detection with MATH!
I used the runtime “enterFrame” event to run every 60FPS. So every frame, I rotate all the planets and also move the dot, if the dot has a velocity.
Once everything is moved, I loop over all the coins and planets to see if the dot collides. The collision is just a simple radius check (since its all spheres). If the dot collides with the planet, I set the velocity to zero and then start rotating the dot around the planets center.
Thanks to stack overflow for saving me some time on the rotation math.
http://stackoverflow.com/questions/2259476/rotating-a-point-about-another-point-2d
Implementation Note: I decided to just keep the dot in its own worldspace instead of putting it in the planet’s display group. I wasted some time trying to get the appropriate planet rotation so I could move between world and planet space. Keeping the dot in worldspace was way easier, and it worked out fine.
2:00-2:30 – Proper collision distances
One thing that was bothering me was when the dot got attached to the planet, sometimes it was a little too close due to the velocity being too high and the frame refresh. The dot’s position would update to be inside the planet. To fix that, I just offset the dot back to just outside the planets radius. Calculated at collision time.
2:30-3:00 – Graphical juice
I tried to think of what I could do to make this juicy, and there were only a few things.
- Dot trail - If the dot was moving through space, I just inserted a circle at the dot’s old location and scaled it down and faded it out over 1/4 second. I also added a second circle interpolated between the old position and current position to make the trail more solid. You could see the individual dots it if was moving too fast.
- Planet hit – Added a sphere at the point of collision. Scales up and fades out.
- Coin hit – Scaled the coin in the Y and faded it out.
3:00-3:45 – Sounds, cleanup, init and play
I used CFXR to create the sounds. It’s pretty sweet.
I also cleaned up the code, added a few comments and made it so all the graphics objects got released and set to nil every time you get that last coin and reset the game.
3:45-4:00 – Background music
I used GarageBand on my iPad with a basic arcade synthesizer to create a 15 second loop. No I didn’t do all those notes, I just held one key down and it sounded cool.
Overall I’m really really happy with the game. I’m considering putting some more time into this and releasing it on the app store. Maybe???
Thanks for reading. Here’s a video of the game in action!
Cheers.
-Kyle