P
pbruce9
Guest
I am trying to make a mini golf game with the ball bouncing off the walls in the level. I have used some different coding than usual to get my game working, but the normal bounce function wont work. I have got the ball to bounce of the top and bottom walls but it wont bounce off side walls, instead it will just freeze next to it.
Any help would be appreciated.
Code:
// Create Event for obj_ball
{
max_power=30;
pow=0;
dir=0;
spd=0;
m_dir=0;
held=false;
frict=0.7;
percent=20;
}
Code:
// Step Event for obj_ball
if (mouse_check_button_pressed(mb_left)){
if (point_distance(x,y,mouse_x,mouse_y)<32){
held=true;
}
}
if (held) {
pow=min(percent*point_distance(x,y,mouse_x,mouse_y)/100,max_power);
dir=point_direction(mouse_x,mouse_y,x,y);
}
if (mouse_check_button_released(mb_left)){
spd=pow;
m_dir=dir;
held=false;
pow=0;
}
if(spd>0){
x+=lengthdir_x(spd,m_dir);
y+=lengthdir_y(spd,m_dir);
if (spd-frict>+0){
spd-=frict;
}
else{
spd=0;
}
}
Code:
// Collision event for obj_ball with obj_wall
{
m_dir = m_dir * -1
}
Last edited by a moderator: