Simple Tetris Clone for LOVE

Show off your games, demos and other (playable) creations.
User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Simple Tetris Clone for LOVE

Post by _ex_ » Mon Dec 12, 2011 1:42 am

Hi guys,
I ported my clone http://code.google.com/p/simple-tetris-clone/ to LOVE

Image

I just learned Lua so the source code it's just a mess of global objects and functions (Game and Platform)
Any help refactoring it? I'm missing the encapsulation and data hiding support of other programming languages :x
If you can review in pedantic mode I would love to hear about your observations.
I'm aiming for a simple code base but in the Lua spirit.

UPDATE: Added the awesome music theme Jarno gently composed for me.

Thanks!
Attachments
stc.love
Updated game
(1.36 MiB) Downloaded 561 times
Last edited by _ex_ on Sun Jan 01, 2012 2:17 am, edited 1 time in total.

User avatar
ivan
Party member
Posts: 1531
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Simple Tetris Clone for LOVE

Post by ivan » Mon Dec 12, 2011 4:38 am

Looks pretty cool, good work.
Your code is very clear, seems like you know what you're doing.
Since you're going with an event system for the input you can do away with the large if-then code:

Code: Select all

keys = {}
keys["left"] = Game.Event.MOVE_LEFT
keys["right"] = Game.Event.MOVE_RIGHT
...

function Platform:onKeyDown(key)
  if keys[key] then
    Game:onEventStart ( keys[key] )
  end
end
You can then move the keys table to a seperate config file.

Are you moving to Lua from C/C++?
I think with a bit of OO programming a lot of those if-then statements could be avoided.
Other than that the game and code are pretty good.
I do have a couple of minor gripes:
I think you should be allowed to rotate the pieces counter-clockwise (for example with the down arrow)
Visually the game looks good but there's too much text I think.
The button instructions could be removed altogether, and instead of numeric stats perhaps you could have progress bars like in Tengen Tetris on the NES.

User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Simple Tetris Clone for LOVE

Post by _ex_ » Mon Dec 12, 2011 5:02 am

hey Ivan, thanks for the feedback, much appreciated
ivan wrote: I think you should be allowed to rotate the pieces counter-clockwise (for example with the down arrow)
Visually the game looks good but there's too much text I think.
The button instructions could be removed altogether, and instead of numeric stats perhaps you could have progress bars like in Tengen Tetris on the NES.
The game support CCW rotations, but that event is not mapped to any key.
I think this little game is more like a demo, the cool things (sound, music, effects) are left as an exercise to the astute reader :D
I'm not moving to Lua, but I needed a bit of no trivial code in Lua for learning purposes :joker: .

negester
Prole
Posts: 9
Joined: Fri Nov 18, 2011 4:41 am

Re: Simple Tetris Clone for LOVE

Post by negester » Tue Dec 13, 2011 6:18 pm

_ex_ wrote: I'm missing the encapsulation and data hiding support of other programming languages
You do these in Lua via proxy tables. Private items, read-only items, counting accesses to an item, etc.

It's an advanced topic, and I'm not even going to try explaining it. You're obviously an experienced programmer who presumably likes to dive in at the deep end, so visit http://www.lua.org/pil/13.4.html It's somewhere in the subsections.

User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Simple Tetris Clone for LOVE

Post by josefnpat » Tue Dec 13, 2011 8:15 pm

This is a very nice clone! Mind adding a quick fullscreen, and/or a way to scale the game?

Also, I love the "love" colors :)
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push

User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Simple Tetris Clone for LOVE

Post by _ex_ » Tue Dec 13, 2011 11:27 pm

josefnpat wrote:This is a very nice clone! Mind adding a quick fullscreen, and/or a way to scale the game?
Also, I love the "love" colors :)
Thanks! I just started using the engine, so I don't know how LOVE supports the full-screen scaling with different resolutions and aspect ratios, Does it support automatic black stripes when the aspect ratio is different?. Need to play more with this.

User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Simple Tetris Clone for LOVE

Post by Robin » Wed Dec 14, 2011 12:31 am

_ex_ wrote:I don't know how LOVE supports the full-screen scaling with different resolutions and aspect ratios,
Yep.
_ex_ wrote:Does it support automatic black stripes when the aspect ratio is different?
Nope.
Help us help you: attach a .love.

User avatar
slime
Solid Snayke
Posts: 2854
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Simple Tetris Clone for LOVE

Post by slime » Wed Dec 14, 2011 3:08 am

_ex_ wrote:Does it support automatic black stripes when the aspect ratio is different?
I believe that's up to the video driver, not any game or framework or engine.

User avatar
_ex_
Citizen
Posts: 65
Joined: Thu Dec 08, 2011 2:59 pm

Re: Simple Tetris Clone for LOVE

Post by _ex_ » Sun Jan 01, 2012 2:24 am

Added the awesome music theme Jarno gently composed for me.

User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Simple Tetris Clone for LOVE

Post by MarekkPie » Sun Jan 01, 2012 5:23 am

Sweet clone. I like the visual drop shadow as well. One thing I'd suggest it some audio indication that you've made a tetris.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests