Todd Nelling
  • Projects
    • Skylanders: SWAP Force
    • Hex Game
    • Chroma
    • Monster Munchies
  • Individual Levels
    • Night of Fear
    • Battle for Genosha
    • Morph Ball Madness
    • Unreal Kart
  • Scripting
    • UnrealScript
    • Lua
    • Hammer I/O
    • Unreal Kismet
    • TESScript
  • About Me/Resume
  • Downloads

Tetris | Lua | LOVE 2D Engine

Picture
NOTE: Includes game and source code files. Requires installation of LOVE 2D engine to play on Mac or Linux (instructions in readme).

Picture

Tetris in LOVE

This simple version of Tetris was a one day project designed to demonstrate my proficiency with the Lua scripting language.  It was built from scratch using the LOVE 2D game engine.

Accomplishments:
  • Smooth controls (use of timers to avoid excessive responsiveness)
  • Intuitive piece rotation (no drift, pieces 'bump' back onto the board to allow for rotating pieces near the side of the board)
  • Combo scoring system (each additional line cleared from a single move is worth more than the previous line)
  • Accelerating descent speed based on score
  • Wall kicks (ability to slide a piece another under before it locks in)
  • Appropriate flow of game states (pause, game over, new game)
  • Next piece display
  • Custom art assets



Picture
Code snippet showing key press logic in the update function

Example: Key Presses

The key press logic ensures smooth, appropriately responsive controls.

To allow players to hold down a key, rather than having to spam it, the update function constantly checks to see which keys are depressed.  However, the update function cycles very quickly, so the key presses need to be throttled, or else the player will be able to move pieces faster than they can control.

The timers shown in the code snippet throttle the controls so that the player can manipulate pieces at a reasonable speed.  Since rotating a piece calls for more precision than sliding it, rotation uses a different, slower timer to ensure that pieces rotate only once per key press, but can still be rotated continuously if the player holds the key down. 

Powered by

✕