pong quest

Show off your games, demos and other (playable) creations.
Post Reply
musky44
Prole
Posts: 6
Joined: Fri Mar 01, 2013 1:08 am

pong quest

Post by musky44 »

This pong game can be confusing and their are a few glitches but it is very addicting. You start at level 1 where the ball goes very slow but each time the ball is hit it speeds up a little. you have 5 lives, each enemy has 3 lives and win, if you beat them you go to the next level. The stats are shown outside of the game play zone. Each level you speed up and the enemy speeds up, although if you get a good hit on a enemy, they might not be able to get the serve and you would get a free passage to the next level. Once you get to level 10 words are shown, by level 13 you have unlocked the secret rank of... There is also difficulty setting that makes the ball speed up faster or slower. and there is sound. also there is a delta time but is still being tested, and it is not automatic and needs to be changed.

I am also planning on adding upgrades. the second version had been taken out.

controls
left/right arrows: move
w/s: change difficulty
e/d: change delta time
q: quit
Attachments
pong quest V1.4.love
new version
(4.54 KiB) Downloaded 134 times
pong quest V1.3.love
third version
(4.5 KiB) Downloaded 87 times
pong quest.love
original
(824 Bytes) Downloaded 107 times
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: pong quest

Post by Germanunkol »

There's something wrong with your code.
I tried version 4 and, as you descirbe, the deltatime does not work correctly yet.
This means that it's unplayable on my computer, because the computer is too fast, I believe.

For one thing, you need to actually set the deltatime. Try doing it in love.update:

Code: Select all

function love.update(timePassed)
	dt = timePassed
end
Then, in the functions handling left and right movement, you should multiply the added x value by dt, not divide it.
The idea behind this is:
timePassed is a value that shows the time between two frames that are being rendered. It can change, that's why you need to update dt in love.update.
Also, timePassed is very different on each PC, depending on the speed of the PC. If a PC is fast, timePassed is very low, because the time it takes the PC to render a frame is very low (and so the time between two frames is also low).
That means if you do something like:
x = x + speed*dt
then this is mostly system-independent, and that's what you want. Speed is a constant (let's say it's 5) and dt is low on fast computers.
So every frame, this function line gets executed. Because frames render faster, this line is executed more often than on a slow PC, but since dt is also lower, in the end, you get a similar result on both PCs, meaning your paddle (or the ball, or whatever) moves with the same speed on both PCs.

Edit: On a side note, indent your code! It's very hard to read otherwise. There's lots of good editors out there that actually do this for you.

It's be great if you could update the game, I'd love to try the higher levels but can't reach them right now ^^.
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
musky44
Prole
Posts: 6
Joined: Fri Mar 01, 2013 1:08 am

Re: pong quest

Post by musky44 »

thanks, i figured that out in my second game, fast flight.
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: pong quest

Post by veethree »

Germanunkol wrote:There's something wrong with your code.
I tried version 4 and, as you descirbe, the deltatime does not work correctly yet.
This means that it's unplayable on my computer, because the computer is too fast, I believe.

For one thing, you need to actually set the deltatime. Try doing it in love.update:

Code: Select all

function love.update(timePassed)
	dt = timePassed
end
Then, in the functions handling left and right movement, you should multiply the added x value by dt, not divide it.
The idea behind this is:
timePassed is a value that shows the time between two frames that are being rendered. It can change, that's why you need to update dt in love.update.
Also, timePassed is very different on each PC, depending on the speed of the PC. If a PC is fast, timePassed is very low, because the time it takes the PC to render a frame is very low (and so the time between two frames is also low).
That means if you do something like:
x = x + speed*dt
then this is mostly system-independent, and that's what you want. Speed is a constant (let's say it's 5) and dt is low on fast computers.
So every frame, this function line gets executed. Because frames render faster, this line is executed more often than on a slow PC, but since dt is also lower, in the end, you get a similar result on both PCs, meaning your paddle (or the ball, or whatever) moves with the same speed on both PCs.

Edit: On a side note, indent your code! It's very hard to read otherwise. There's lots of good editors out there that actually do this for you.

It's be great if you could update the game, I'd love to try the higher levels but can't reach them right now ^^.
I'm pretty sure you don't need the "timePassed" variable, You can just put "dt" as love.update's argument.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: pong quest

Post by Robin »

veethree wrote:I'm pretty sure you don't need the "timePassed" variable, You can just put "dt" as love.update's argument.
A rose by any other name...
Help us help you: attach a .love.
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: pong quest

Post by substitute541 »

Robin wrote:
veethree wrote:I'm pretty sure you don't need the "timePassed" variable, You can just put "dt" as love.update's argument.
A rose by any other name...
... just as sweet.
When everything's worse, our work is complete!
Jessie!
James!
Meowth thats the name!

... Actually, I'm laughing too hard to continue on (it's a version of the team rocket motto in pokemon).
Currently designing themes for WordPress.

Sometimes lurks around the forum.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: pong quest

Post by Germanunkol »

Robin wrote:
veethree wrote:I'm pretty sure you don't need the "timePassed" variable, You can just put "dt" as love.update's argument.
A rose by any other name...
Wait, what? Why?
He wants dt to be global, right? He's using the dt value everywhere else.
But aren't received arguments automatically local? So to make it global, I need to assign the local value to a global variable.
?
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: pong quest

Post by Robin »

Germanunkol wrote:Wait, what? Why?
He wants dt to be global, right? He's using the dt value everywhere else.
But aren't received arguments automatically local? So to make it global, I need to assign the local value to a global variable.
?
You are right. I don't know about veethree, but I read right past that because making dt global is really ugly and bad design and you shouldn't do that ever. Instead, pass dt as an argument to whatever function needs it.
Help us help you: attach a .love.
Germanunkol
Party member
Posts: 712
Joined: Fri Jun 22, 2012 4:54 pm
Contact:

Re: pong quest

Post by Germanunkol »

Good, just making sure I didn't miss something.

I agree with you, of course. Just didn't want to make it more complicated than it already was.

I'm not very fond of the way Lua makes everything global by default...
trAInsported - Write AI to control your trains
Bandana (Dev blog) - Platformer featuring an awesome little ninja by Micha and me
GridCars - Our jam entry for LD31
Germanunkol.de
Post Reply

Who is online

Users browsing this forum: No registered users and 57 guests