29 August 2013
Guest Piece: CoronaBlitz – My First Game Jam
Kyle Yamamoto is the co-founder of MochiBits, an independent game studio. While originally working with Cocos2D, the team switch to Corona SDK to take advantage of Corona’s cross-platform capabilities. To date, Kyle and co-founder Howard Go have build and published 11 mobile apps.
Kyle recently participated in CoronaBlitz, a 4 hour coding challenge put on by Corona developer Andrew Potozniak. In today’s piece, Kyle writes on his experience participating in his first-ever game jam. If you’d like to see more from Kyle, you can follow him on Twitter at @_kyleyamamoto. To check out all the CoronaBlitz entries, please visit our forum.
When I first heard about the CoronaBlitz, I really wanted to do it. The 4-hour time frame spread over a week was perfect for a game jam newbie.
I’ve had this vague idea for a game inspired by Pivvot, Brick Roll, and the old-school Mr. Ninja. Luckily, the idea fit perfectly with the “Collection” theme. I didn’t need any fancy graphics and the gameplay was also pretty simple.
The basic premise is that you are a dot and you can only do one thing: jump. Your direction is controlled by spinning planets and your only goal is to collect all the coins on the screen. No dying and no time limit.
Here’s an hour-by-hour break down of how I spent my time:
0:00-1:00 — Planet and coin setup
I took the first hour to get the planets and coins set up. 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 planet’s center.
Thanks to stack overflow for saving me some time on the rotation math.
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.
1) 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.
2) Planet hit — Added a sphere at the point of collision. Scales up and fades out.
3) Coin hit — Scaled the coin in the Y and faded it out.
3:00-3:45 — Sounds, cleanup, initialization 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 happy with what I was able to do in 4 hours. The game turned out really fun.
It was really easy getting things up and running using Corona SDK. I would definitely do another CoronaBlitz and maybe other game jams too!
We’re planning on taking my prototype and releasing it as a REAL game. Look for it sometime in October 2013. In the meantime, here’s a video of the game in action: