First game (newbie)

Show off your games, demos and other (playable) creations.
Post Reply
nelmaven
Prole
Posts: 3
Joined: Wed Jan 29, 2014 8:44 pm

First game (newbie)

Post by nelmaven » Wed Jan 29, 2014 10:23 pm

Hai there! :megagrin:

First of all, this is my first time posting here, so excuse me if this is not the proper place to post this.

The game it's a Pong clone (shocking, right?) and this is my first time diving into Lua and LÖVE so I would like to ask for opinions, on the game and on the code. Pretty please? :3

The code is hosted on Github.
Attachments
pong.love
(47.97 KiB) Downloaded 130 times

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: First game (newbie)

Post by davisdude » Wed Jan 29, 2014 11:00 pm

nelmaven wrote:Hai there! :megagrin:
Hello! :D
nelmaven wrote:First of all, this is my first time posting here, so excuse me if this is not the proper place to post this.
Welcome, and this is the right place to post this.
nelmaven wrote:The game it's a Pong clone (shocking, right?) and this is my first time diving into Lua and LÖVE so I would like to ask for opinions, on the game and on the code. Pretty please? :3
Terribly shocking. Nobody does Pong clones anymore (just kidding). ;)
Anyway, here are my comments:
I like how you have all of your pictures in the pictures folder, etc. It leads to good organization, and keeps everything nice and clean.
As for the code, here it goes:
ball.lua
Just some math here, doesn't really matter, but:

Code: Select all

return (love.window.getWidth() / 2) - (ball.width / 2)
is the same as

Code: Select all

return ( love.window.getWidth() - ball.width ) / 2
Doesn't really make much of a difference, but, ya' know...

If I were you, I would make ball.rotation a value, just to avoid hard-coding information. It makes it easier to edit in the long run.
Same with most all straight-up numbers. Good habit to get into.

field.lua
You make field a global table. If I were you, I would do the same thing I did for ball, which is make a local table, then return it.
Same for pad, collision, field, score, title, and menu.

main.lua
Your coding style is somewhat inconsistent. Sometime you make functions by doing

Code: Select all

loop = function(dt)
other times you do

Code: Select all

function field.draw()
Not sure what you're dong with this either:

Code: Select all

screen.paused = screen.playing
It seems sort of strange to have love.load at the end of the file, but that's your call.

Overall you've done a good job, especially for a first game! :)
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Re: First game (newbie)

Post by Xkeeper » Wed Jan 29, 2014 11:05 pm

Nice. It certainly works, so that's a plus.

Here are some things that might improve it:

- Some indication of what the controls are.
- The game should wait for a moment and indicate what direction the ball will initially travel after a goal. It's easy to lose a puck near the top or bottom of the screen and have one or two more slide by before you can get back to the middle.

The only other thing I can think of is the paddle area could stand to be better defined in some way. It's a bit ambiguous where the game paddles are.


Some difficulty would also be nice, make rallies speed up the ball with each one slightly so that it's harder to keep up with and predicting the position is more useful :P

nelmaven
Prole
Posts: 3
Joined: Wed Jan 29, 2014 8:44 pm

Re: First game (newbie)

Post by nelmaven » Thu Jan 30, 2014 9:41 pm

@davisdude
First of all, thanks for the heartfelt welcome and for taking the time to look through the code and the tips. ;)
davisdude wrote:Doesn't really make much of a difference, but, ya' know...

... simple is better. Thanks!
davisdude wrote:field.lua
You make field a global table. If I were you, I would do the same thing I did for ball, which is make a local table, then return it.
Same for pad, collision, field, score, title, and menu.
Globals are evil. Fixed this on the last revision. Well sorta, still have to decide how to handle the player objects defined on the "score" module
davisdude wrote:main.lua
Your coding style is somewhat inconsistent. Sometime you make functions by doing

Code: Select all

loop = function(dt)
other times you do

Code: Select all

function field.draw()
Fair point. Though in this case, the "loop" function is inside a complex object. I'm still trying to figure how to abstract the "screen" and the "mode" objects and move them to modules, which is a bit difficult because of the way they are called and the fact they need to access other local variables.
davisdude wrote:Not sure what you're dong with this either:

Code: Select all

screen.paused = screen.playing
Should've commented this one before but the case here is that I need to define a "paused" screen, but right now I only need it to be the equal to the "playing" screen. This will be changed later to show a game paused message.
davisdude wrote:It seems sort of strange to have love.load at the end of the file, but that's your call.
I guess this is because I come from an imperative background. You know, define everything before hand then call the main function.
davisdude wrote:Overall you've done a good job, especially for a first game! :)
Thanks! :D That means a lot!

--------------------------------

@Xkeeper
Hi! Thank you for the look in the game and for the feedback! Much appreciated! :D
Xkeeper wrote:Some indication of what the controls are.
I guess a controls screen is on the way
Xkeeper wrote:The game should wait for a moment and indicate what direction the ball will initially travel after a goal.
This is one of my goals but I'm not sure how to "pause the action"?
Xkeeper wrote:make rallies speed up the ball
Sorry, I don't understand what you mean by rallies. :P


Sorry for the long post.

davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: First game (newbie)

Post by davisdude » Fri Jan 31, 2014 12:21 am

Rallies are a succession of consecutive hits. Basically, the longer you go, the faster the ball goes.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim

nelmaven
Prole
Posts: 3
Joined: Wed Jan 29, 2014 8:44 pm

Re: First game (newbie)

Post by nelmaven » Fri Jan 31, 2014 5:10 am

Oh I see. I do something similar already in which I slightly increase the ball speed with each successful hit of the pads, but this seems more interesting. :D

I was also thinking of adding speed pads to the field that activate when the player is able to score 3 goals in a row. They would then be active during X seconds and if the player is able to aim the disk at it, it would give a speed bost to his shot.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests