Page 1 of 2

PÖNG

Posted: Sun Mar 06, 2011 3:38 am
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.

Re: PÖNG

Posted: Sun Mar 06, 2011 6:14 am
by TechnoCat
Oh you, didn't use DT for the ball movement.
I can't react in the fraction of the second given.

Re: PÖNG

Posted: Sun Mar 06, 2011 8:35 am
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!

Re: PÖNG

Posted: Sun Mar 06, 2011 8:45 am
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.

Re: PÖNG

Posted: Sun Mar 06, 2011 12:14 pm
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.

Re: PÖNG

Posted: Sun Mar 06, 2011 5:38 pm
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.

Re: PÖNG

Posted: Sun Mar 06, 2011 7:23 pm
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.

Re: PÖNG

Posted: Sun Mar 06, 2011 7:44 pm
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.

Re: PÖNG

Posted: Mon Mar 07, 2011 3:30 am
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.

Re: PÖNG

Posted: Mon Mar 07, 2011 4:46 am
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?