PÖNG

Show off your games, demos and other (playable) creations.
User avatar
furi
Citizen
Posts: 73
Joined: Sat Feb 26, 2011 8:15 pm

PÖNG

Post by furi »

500th topic, awesome.

Pretty simple. W and S to move up and down for P1, and for P2, I and J. Space to start. Whoever gets to 10 first wins, and after pressing space, it restarts.

Allow me to note that this is the very first thing I've completed in LÖVE. Not really the best thing ever.
Attachments
Pong2.love
(1.05 KiB) Downloaded 165 times
Pong.love
(1001 Bytes) Downloaded 128 times
Last edited by furi on Sun Mar 06, 2011 5:37 pm, edited 1 time in total.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: PÖNG

Post by TechnoCat »

Oh you, didn't use DT for the ball movement.
I can't react in the fraction of the second given.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: PÖNG

Post by tentus »

I couldn't get it to run (possibly it was running faster than my eye can see, because you didn't use dt?)

I tried to debug it a little, and here is what I think you should do:

1: Use dt. Not using it is unacceptable, to the point that I can't even think of an analogy that describes how critical it is.
2: Indent. 100% of the time.
3: Use tables when applicable (two nearly identical sets of data? use tables!)
4: If code looks repetitive, it should probably be turned into a function. (Your drawing code is an easy example here.)
5: Speaking of the drawing code, use the rectangle function, rather than drawing each individual pixel. Way more efficient and elegant.

tips:
- variable == true and variable == false can be replaced with just variable and not variable. it's short and easier to read.
- Semicolons are redundant in lua, at least the way you're using them. save yourself the typing!
- Use dt!
Kurosuke needs beta testers
User avatar
furi
Citizen
Posts: 73
Joined: Sat Feb 26, 2011 8:15 pm

Re: PÖNG

Post by furi »

tentus wrote:I couldn't get it to run (possibly it was running faster than my eye can see, because you didn't use dt?)

I tried to debug it a little, and here is what I think you should do:

1: Use dt. Not using it is unacceptable, to the point that I can't even think of an analogy that describes how critical it is.
2: Indent. 100% of the time.
3: Use tables when applicable (two nearly identical sets of data? use tables!)
4: If code looks repetitive, it should probably be turned into a function. (Your drawing code is an easy example here.)
5: Speaking of the drawing code, use the rectangle function, rather than drawing each individual pixel. Way more efficient and elegant.

tips:
- variable == true and variable == false can be replaced with just variable and not variable. it's short and easier to read.
- Semicolons are redundant in lua, at least the way you're using them. save yourself the typing!
- Use dt!
Yeah, I kinda learned those tips and bits since the time I made this. It doesn't really seem worth updating with the fixes, though, as it's still just a mini pong clone.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: PÖNG

Post by Robin »

furi wrote:It doesn't really seem worth updating with the fixes, though, as it's still just a mini pong clone.
It could be good for exercise. The fact that it's small makes it even better, because no matter how awful the code, it can't be so bad it can't be fixed.
Help us help you: attach a .love.
User avatar
furi
Citizen
Posts: 73
Joined: Sat Feb 26, 2011 8:15 pm

Re: PÖNG

Post by furi »

Robin wrote:
furi wrote:It doesn't really seem worth updating with the fixes, though, as it's still just a mini pong clone.
It could be good for exercise. The fact that it's small makes it even better, because no matter how awful the code, it can't be so bad it can't be fixed.
Well, you've convinced me. Pong2 is the changed one, with a weird way of using dt, and I kept up the original one for a pseudo-diff.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: PÖNG

Post by TechnoCat »

furi wrote:Well, you've convinced me. Pong2 is the changed one, with a weird way of using dt, and I kept up the original one for a pseudo-diff.
I still can't react in the fraction of a second the ball takes to move off screen.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: PÖNG

Post by Robin »

The fact that you have to press space every time the ball flies of screen is rather annoying, especially since the ball does it so often.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: PÖNG

Post by Jasoco »

Yeah. There should be a delay of a second before the ball moves, but the paddle should still be movable during this time. And the paddle should be returned to the middle every round.
User avatar
furi
Citizen
Posts: 73
Joined: Sat Feb 26, 2011 8:15 pm

Re: PÖNG

Post by furi »

TechnoCat wrote:
furi wrote:Well, you've convinced me. Pong2 is the changed one, with a weird way of using dt, and I kept up the original one for a pseudo-diff.
I still can't react in the fraction of a second the ball takes to move off screen.
Are you serious? It moves a crapload slower for me, and in fact, it's quite unplayable because of it. Do you own a supercomputer or something?
Post Reply

Who is online

Users browsing this forum: veethree and 57 guests