Hi guys,
I ported my clone http://code.google.com/p/simple-tetris-clone/ to LOVE
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
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!
Simple Tetris Clone for LOVE
Re: Simple Tetris Clone for LOVE
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:
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.
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
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.
Re: Simple Tetris Clone for LOVE
hey Ivan, thanks for the feedback, much appreciated
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
I'm not moving to Lua, but I needed a bit of no trivial code in Lua for learning purposes .
The game support CCW rotations, but that event is not mapped to any key.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.
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
I'm not moving to Lua, but I needed a bit of no trivial code in Lua for learning purposes .
Re: Simple Tetris Clone for LOVE
You do these in Lua via proxy tables. Private items, read-only items, counting accesses to an item, etc._ex_ wrote: I'm missing the encapsulation and data hiding support of other programming languages
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.
- josefnpat
- Inner party member
- Posts: 955
- Joined: Wed Oct 05, 2011 1:36 am
- Location: your basement
- Contact:
Re: Simple Tetris Clone for LOVE
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
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
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
Re: Simple Tetris Clone for LOVE
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.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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Simple Tetris Clone for LOVE
Yep._ex_ wrote:I don't know how LOVE supports the full-screen scaling with different resolutions and aspect ratios,
Nope._ex_ wrote:Does it support automatic black stripes when the aspect ratio is different?
Help us help you: attach a .love.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Simple Tetris Clone for LOVE
I believe that's up to the video driver, not any game or framework or engine._ex_ wrote:Does it support automatic black stripes when the aspect ratio is different?
Re: Simple Tetris Clone for LOVE
Added the awesome music theme Jarno gently composed for me.
Re: Simple Tetris Clone for LOVE
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.
Who is online
Users browsing this forum: Google [Bot] and 6 guests