Can anyone help me
Need help with game maker
Need help with game maker
I am making my first game maker game(apart from the tutorial one) and It involves a powerup that travels quickly in a strait line then bounces off the wall. I need help with getting the powerup to bounce off the wall in a random direction,not bouncing relative to the angle it hit the wall.
Can anyone help me
Can anyone help me
Generation 59: Community experiment. The first time you see this, take the generation # and add 1. Put in your signature.
Here you go. I hope this is what you meant.
In the collision event of the powerup with the wall, put the "Execute Code" action (found in the control tab) and paste this code into it:
BTW, the "//" combination means that anything typed after it will act as a comment until the end of the line. Comments are usually used for helping the makers understand the code, and with color coding, are almost always marked green.
In the collision event of the powerup with the wall, put the "Execute Code" action (found in the control tab) and paste this code into it:
Code: Select all
if (place_free(x+4,y)) // check if the position 4 pixels to the right of the player is collision-free
{
direction = 315+random(90) // set the direction to somewhere between 315 (down-right) and 405 (up-right)
exit // abort execution of this piece of code
}
if (place_free(x,y+4)) // check if the position 4 pixels below the player is collision-free
{
direction = 225+random(90) // set the direction to somewhere between 225 (down-left) and 315 (down-right)
exit // abort execution of this piece of code
}
if (place_free(x-4,y)) // check if the position 4 pixels to the left of the player is collision-free
{
direction = 135+random(90) // set the direction to somewhere between 135 (up-left) and 225 (down-left)
exit // abort execution of this piece of code
}
if (place_free(x,y-4)) // check if the position 4 pixels above the player is collision-free
{
direction = 45+random(90) // set the direction to somewhere between 45 (up-right) and 135 (up-left)
exit // abort execution of this piece of code
}
