P
Pepasone
Guest
I can't seem to figure out what I have wrong.
When I click on the cabbage, it behaves correctly, increases speed, adds score, moves and changes direction. If I click on a powerup, it just uses the code from the bottom as if I clicked on nothing.
So it checks to see if I clicked. I have, then it checks to see if I was over the cabbage or a powerup and I am. If I am over the cabbage, it works correctly. However if I am over a powerup, it skips to the bottom of the code and resets the speed to 4 and multiplier to one.
I appreciate the help!
When I click on the cabbage, it behaves correctly, increases speed, adds score, moves and changes direction. If I click on a powerup, it just uses the code from the bottom as if I clicked on nothing.
So it checks to see if I clicked. I have, then it checks to see if I was over the cabbage or a powerup and I am. If I am over the cabbage, it works correctly. However if I am over a powerup, it skips to the bottom of the code and resets the speed to 4 and multiplier to one.
I appreciate the help!
Code:
if mouse_check_button_pressed(mb_left)
{
if position_meeting(mouse_x, mouse_y, obj_cabbage) || position_meeting(mouse_x, mouse_y, obj_powerup)
{
// THIS IS WHAT HAPPEN WHEN IT IS A CABBAGE
if position_meeting(mouse_x, mouse_y, obj_cabbage)
{
score_current += (score_multiplier * score_base);
score_multiplier += 1;
// Check if ball_speed is is past 10 keep at ten.
if ball_speed >= 10
{
ball_speed = 10;
}
else
{
ball_speed += 1;
}
move_random(1, 1);
motion_set(irandom(359), ball_speed);
}
// THIS IS WHAT SHOULD HAPPEN IF IT IS A POWERUP
else
{
move_random(1, 1);
motion_set(irandom(359), ball_speed);
}
}
//THIS IS WHAT IS SUPPOSED TO HAPPEN IF WE CLICK IN THE GAME AREA BUT MISS THE POWERUP AND CABBAGE
else
{
score_multiplier = 1;
ball_speed = 4;
move_random(1, 1);
motion_set(irandom(359), ball_speed);
}
}
Last edited by a moderator: