made this due to boredom and nothing else. This is basically single player pong where you control both of the players.
The whole thing is quite messy right now, Bunch of bugs and stuff. If i continue working on this i'll polish it a bit
Also, The ball will likely move really slow for you..it did that for my friend, just change the ball.speed and ball.a values in the script to something higher.
Forever Alone Pong
Re: Forever Alone Pong
The ball moves at different speeds on different machines because you've made it dependent on the frame rate:
Code like this makes the ball take a step of the same size in every frame regardless of how much time there is between frames.
What you could do is simply multiply the speed by dt:
Now it makes physical sense and will go at the same speed on every machine.
I say it makes physical sense because consider the units:
Code: Select all
ball.x = ball.x - ball.speed
What you could do is simply multiply the speed by dt:
Code: Select all
ball.x = ball.x - ball.speed*dt
I say it makes physical sense because consider the units:
Code: Select all
[pixels] = [pixels] - [pixels/sec] -- subtracting pixels per second from pixels makes no physical sense
Code: Select all
[pixels] = [pixels] - [pixels/sec]*[sec] -- the seconds cancel, subtracting pixels from pixels is allowed
Re: Forever Alone Pong
thanks!hughes wrote:The ball moves at different speeds on different machines because you've made it dependent on the frame rate:Code like this makes the ball take a step of the same size in every frame regardless of how much time there is between frames.Code: Select all
ball.x = ball.x - ball.speed
What you could do is simply multiply the speed by dt:Now it makes physical sense and will go at the same speed on every machine.Code: Select all
ball.x = ball.x - ball.speed*dt
I say it makes physical sense because consider the units:Code: Select all
[pixels] = [pixels] - [pixels/sec] -- subtracting pixels per second from pixels makes no physical sense
Code: Select all
[pixels] = [pixels] - [pixels/sec]*[sec] -- the seconds cancel, subtracting pixels from pixels is allowed
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Forever Alone Pong
Found a bug: if the ball gets far enough, it can get stuck, because it will still be to far, it "bounces" again and again and again.
Help us help you: attach a .love.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Forever Alone Pong
The solution being the use of math.abs (or -math.abs).
Re: Forever Alone Pong
how exactly can i use that?bartbes wrote:The solution being the use of math.abs (or -math.abs).
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Forever Alone Pong
Well, if you're at the left and you need to bounce you set the direction to math.abs(current_speed) and on the right you set it to -math.abs(current_speed). (That's always-right or always-left respectively.)
EDIT: Where current_speed is the speed on the X axis, I should add.
EDIT: Where current_speed is the speed on the X axis, I should add.
Who is online
Users browsing this forum: Ahrefs [Bot] and 3 guests