• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Issues with wall collision in "pong" game

J

Jmarlin3

Guest
The paddle I created will not bounce off the walls and reflect back down on the y-axis. The player has control of the paddles, but when it hits the wall, the paddle bounce down and you continue playing.

[/CODE]
if keyboard_check(vk_up) vspeed = -3;
if keyboard_check(vk_down) vspeed = 3;
//Collion with wall
if (place_meeting(x,y+vsp,o_wall))
{
while (!place_meeting(x,y+sign(vsp),o_wall))
{
y = y + sign(vsp);
}
vsp = -vsp;
}
y = y + vsp;

Please help and thank you in advance.
 

Simon Gust

Member
The paddle I created will not bounce off the walls and reflect back down on the y-axis. The player has control of the paddles, but when it hits the wall, the paddle bounce down and you continue playing.

[/CODE]
if keyboard_check(vk_up) vspeed = -3;
if keyboard_check(vk_down) vspeed = 3;
//Collion with wall
if (place_meeting(x,y+vsp,o_wall))
{
while (!place_meeting(x,y+sign(vsp),o_wall))
{
y = y + sign(vsp);
}
vsp = -vsp;
}
y = y + vsp;

Please help and thank you in advance.
You are using vspeed and vsp at the same time? That won't work very well. vspeed will ignore what you do with vsp.
 

Ladi_Pix3l

Member
You are using vspeed and vsp at the same time? That won't work very well. vspeed will ignore what you do with vsp.
This is true. Doesn't help that I'm certain game maker autochanged your "vsp" to "vspeed"

Also little side note:
I think you forgot to put
Code:
[code]
at start of your code.
 
Top