TulioHenry
Member
I'm making a top down shooter that when you shot it create a bulletshell, and that bullet shell will rotate and move to a certain direction, and if it collide with an wall it will change the movement to the opposite direction.
The problem is that when it collide with the wall the image flickers and the object do not bounce
Here the code:
create:
step:
OBS: the "dir" is coming from the player mouse position (point direction) + 90°
So when the player shoot, it will create the bulletcase and assing the direction
*also the sprite is a 8x6 rectangle
The problem is that when it collide with the wall the image flickers and the object do not bounce
Here the code:
create:
Code:
rotateSpd = random(4);
spd = 5;
dir = 0;
Code:
//rotaciona a imagem
if(spd > 0){
spd -= 0.1;
image_angle += rotateSpd;
}else{
spd = 0;
}
caseX = lengthdir_x(spd,dir);
caseY = lengthdir_y(spd,dir);
//colisions
if(caseX != 0){
var collisionH = place_meeting(x+caseX,y,oWall);
if(collisionH){
repeat(abs(caseX)){
if(!place_meeting(x+sign(caseX),y,oWall)){
x += sign(caseX);
}else break;
}
dir = dir + 180;
}
}
if(caseY != 0){
var collisionV = place_meeting(x,y+caseY,oWall);
if(collisionV){
repeat(abs(caseY)){
if(!place_meeting(x,y+sign(caseY),oWall)){
y += sign(caseY)
}else break;
}
dir = dir + 180;
}
}
x += caseX;
y += caseY;
So when the player shoot, it will create the bulletcase and assing the direction
*also the sprite is a 8x6 rectangle
Last edited: