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.
PÖNG
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: PÖNG
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!
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
Re: PÖNG
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.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!
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: PÖNG
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.furi wrote:It doesn't really seem worth updating with the fixes, though, as it's still just a mini pong clone.
Help us help you: attach a .love.
Re: PÖNG
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.Robin wrote: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.furi wrote:It doesn't really seem worth updating with the fixes, though, as it's still just a mini pong clone.
- TechnoCat
- Inner party member
- Posts: 1612
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: PÖNG
I still can't react in the fraction of a second the ball takes to move off screen.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.
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: PÖNG
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.
Re: PÖNG
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?TechnoCat wrote:I still can't react in the fraction of a second the ball takes to move off screen.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.
Who is online
Users browsing this forum: No registered users and 3 guests