Today’s guest post comes to you courtesy of Sergey Lerg, creator of Corona-built games Cubic Run and Laser Flow. In this post, Sergey discusses his experience as a participant in CoronaBlitz #2 and how he managed to make a full game in under a week.
I just participated in CoronaBlitz #2 and not only did I enjoy it, but I managed to create a complete game, Hex LED, in just under a week!
My first game, Laser Flow, is also a child of a game jam. Six months ago, I participated in the GlitchGames Game Jam, produced Laser Flow, and since then my game has provided many hours of puzzling gameplay to players around the world.
“Make a game in 4 hours,” they say. Well, it’s a challenge but it’s not impossible. If you have your idea in mind before coding, you can indeed implement it in under 4 hours using Corona. Laser Flow took me a month to finish because it has a lot of levels, however Hex LED didn’t need as many. I decided to keep this game simple and lightweight.
Fun fact #1: On the app icon, the green line is larger than red or blue, yet sometimes it appears smaller due to an optical illusion caused by the shape of the icon.
The theme for CoronaBlitz #2 was “energy/energize,” so I considered RGB LEDs (Light-Emitting Diodes) and how to play with their colors. Each color component requires different energy to light up, and the more energy you have, the more colors are powered. The goal is to combine energy and get as many lights as possible. Essentially, my concept was a blend of Triple Town, Threes, and 2048.
Hexagonal boards provide a lot of variety to the gameplay. When I created Hex LED, my score was around 10,000 and I thought that it was nearly impossible to score more than 20,000. However, my friend treser2 from the #corona IRC channel beta-tested the game and managed to score about 24,000. I was amazed because I never thought somebody could score so high! Ironically, a few days later, I scored more than 30,000 — the trick is getting two 4096 tiles and collapsing them together.
Fun fact #2: Initially there was only one tile set — RGB LEDs — but later I decided to add conventional Arabic numbers because some people had troubles playing with the RGB set. Later, I also added beautiful Chinese numbers, which have since become my favorite.
Hexagonal Board Math
To learn how to work with a hexagonal map, I read a great tutorial from RedBlocks Games. The most amazing thing is that the tutorial is interactive — it’s truly one of the best tutorials I’ve ever seen.
I chose to use the Axial Coordinate System for my game and it was the right decision. Doing the math for moving the tiles and finding possible moves was much simpler using this coordinate system. The more challenging part was making the tiles move and collapse according to the rules. At the beginning, not all tiles are moving, so tiles didn’t always collapse when they had to, and sometimes there were gaps and overlapping tiles. But, after a few days, I managed to fix it and gameplay became as smooth as I hoped.
Fun fact #3: The Chinese tile set consists of Chinese numbers from 1 to 10, however there are no standalone hieroglyphs for 11 or 12, so I used 100 and 1000 instead.
Useful Code and Tips
Usual left and right swipes are detected by looking at the
event.x - event.xStart value, however for my game I had to use a radial coordinate system to detect the correct swipe. Basically, I calculate the angle with finger slides on the screen. Here’s part of my touch listener:
if ( event.phase == 'moved' ) then
local dx, dy = event.x - event.xStart, event.y - event.yStart
local distance = math.sqrt(dx ^ 2 + dy ^ 2)
if ( (distance > 50) and self.lastSwipe ~= event.id ) then
self.lastSwipe = event.id
local angle = math.round(math.deg(math.atan2(dy, dx)) / 60)
if ( angle == 3 or angle == -3 ) then
elseif angle == 0 then
elseif angle == 1 then
elseif angle == 2 then
elseif angle == -1 then
elseif angle == -2 then
When I was preparing the store listing for the Google Play Store, I received a “Your APK seems not to be designed for tablets.” message. This report was a puzzle of its own. After hours of research, I figured out that Google Play doesn’t like my screenshots because they have too much white space. In order to avoid this issue, your first 7” tablet screenshot must be filled up with something. So, I added some promo text to it and it passed the test, although it took me awhile to figure out how to position the text so it both looks good and Google approves of the screenshot.
config.lua file is interesting. It uses pixel-perfect settings for all iOS devices and some Android devices, then relies on 320×480 “letterbox” mode for anything else.
local h, w = display.pixelWidth, display.pixelHeight
if (w == 1024 and h == 768) or (w == 960 and h == 640) or (w == 1136 and h == 640) or (w == 2048 and h == 1536) or (w == 1280 and h == 720) or (w == 480 and h == 320) then
while w > 700 do
w = w * 0.5
h = h * 0.5
w, h = h, w
w = 320
h = 480
width = w,
height = h,
scale = 'letterbox',
fps = 60,
['@2x'] = 1.2,
Hex LED already has great reviews and some people are really addicted to it. Thanks to all of the Corona folks in the #corona IRC channel for helping me iron out the small issues. And of course, thanks to Tyraziel and Corona Labs for organizing the awesome CoronaBlitz game jam!
Remember my other game prototype, the endless runner Cubic Run? If you download and rate Hex LED, I’ll send you the source code for Cubic Run!
Hex LED in the App Store — https://itunes.apple.com/app/id830218249
Hex LED on Google Play — https://play.google.com/store/apps/details?id=com.spiralcodestudio.hexled