Hi!
I'm making a platform game and one of the playable characters is a drummer who can throw drumsticks like two boomerangs.
My code for that is that when you press the attackbutton the player stops, throws two drumsticks which are created on a timer. When the drumsticks hits an enemy, a wall or just travels a short distance it returns to the player again.
It wouldn't be fun if you could spam the button so when you throw the first drumstick it makes global.boomerangammo = 0 and when the second drumstick comes back it resets the ammo to 1.
This works fine for the most parts but sometimes if you throw while moving forward or mess around a bit the character just throws the first one and not the second. Thereby making it impossible to get global.boomerangammo = 1 again. I don't want to set a timer to reset the ammo because this would glitch up the attacks and make spamming shots a possibility.
Any ideas?
Thanks!
Boomerang bug
Started by metallica3000, Jun 21 2012 06:59 PM
2 replies to this topic
#1
Posted 21 June 2012 - 06:59 PM
#2
Posted 21 June 2012 - 07:14 PM
set the variable to 2...
when you throw the first stick it becomes 1, when you throw the second stick it becomes 0. Then when the first stick is back - it becomes 1, when the second stick is back - it becomes 2. This way if you throw only one stick, the variable will be 1, and when the first stick is back - the variable will become 2 again...
Edit:
if this isn't what you are asking for - then i just don't understand your question.
when you throw the first stick it becomes 1, when you throw the second stick it becomes 0. Then when the first stick is back - it becomes 1, when the second stick is back - it becomes 2. This way if you throw only one stick, the variable will be 1, and when the first stick is back - the variable will become 2 again...
Edit:
if this isn't what you are asking for - then i just don't understand your question.
Edited by psycho666, 21 June 2012 - 07:16 PM.
#3
Posted 22 June 2012 - 09:19 AM
What this guy said above. Here's some pseudo-code:
CREATE EVENT:
STEP EVENT:
CREATE EVENT:
global.boomerangammo = 2;
STEP EVENT:
if (keyboard_check_pressed(attackbutton) and global.boomerangammo>0) {
// throw boomerang
global.boomerangammo -= 1;
}
if (boomerang_returned) {
global.boomerangammo += 1;
}
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











