[LD 42] Spaceabon

Show off your games, demos and other (playable) creations.
Post Reply
Agecaf
Prole
Posts: 1
Joined: Mon Aug 13, 2018 11:35 pm

[LD 42] Spaceabon

Post by Agecaf »

Hi all,

I decided to participate in the Ludum Dare with Löve this time. It's my first time using it, as well as the first time doing some major work in Lua, but it ended up being quite ok (even the array starting at 1 shenanigans). I did have quite a bit more trouble when porting it to HTML5 though, but in the end it was done (after like 4 extra hours but oh well).

Here are the links:
https://ldjam.com/events/ludum-dare/42/spaceabon
https://agecaf.itch.io/spaceabon

If anyone is interested in learning from its source, it's in the links above. It ended up being a massive single 1K-lines file, but the logic should be simple enough.

The main gameplay logic happens after the player inputs a key, which usually moves the little robot along the grid, checking if it can push blocks along the way. The update callbacks are used to smoothen the transitions with my special sauce; exponential ease-in transitions;

Code: Select all

-- x is the current drawn position
-- tx is where it is supposed to be, and where it's transitioning to, its target
-- lambda is a number close to zero; 0.1, 0.05, etc.
-- called each frame
x = x + lambda *  (tx - x)
There's also a main menu screen and a game over screen. The main menu is simply a static image with black rectangles drawn on top; each rectangle is then faded into transparency to animate the thing behind it "fading in".

Code: Select all

-- menuTimer is the time since we moved into the menu
-- 10 is the time where the rectangle should start fading out.
love.graphics.setColor(0, 0, 0, 1 - (menuTimer - 10) * 2)
love.graphics.rectangle("fill", 0, 150, 300, 210)
The game takes place in a space station in space; the game over screen has that station slowly going further away, it keeps the stars, and fades in a pixel-caligraphy "Game Over", as something interesting happens with the music;

The game has two music loops; the main menu one and the in-game one. They just happen to fit in perfectly; so they actually both play at all times, but
  1. In the main menu, the game music is set to volume 0.
  2. As the game starts, we cross-fade from the menu music into the game music.
  3. On game over, we keep the game music, but slowly fade in the menu music.
  4. When returning to the main menu, we suddenly drop the game music.
This makes it sound quite awesome, even if we used only two tracks! It didn't work in the HTML5 version though, since for some reason there's no way to sync up the music easily (believe me, I tried).

Anyway, if you're interested in how I did something, I'll be glad to look up the piece of code and discuss it! As a jam game, it was not commented as well as it should...
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 21 guests