How many events can you use to make a platform character shoot?
I'm looking for the safest- least amount of events to have player shoot left and right.
I've got my version down to 4 using an alterable value "Shooting", dunno if it's the best way to go about it though.
[1] Repeat while pressing Right. -Set Player "Shooting" to 1
[2] Repeat while pressing Left. -Set Player "Shooting" to -1
[3] Pressed Ctrl.
"Shooting" of Player = 1 -Shoot bullet right at speed 100
[4] Pressed Ctrl.
"Shooting" of Player = -1 -Shoot bullet left at speed 100
Please let me know if I should do it this way.
Edited by the Author.
theonecardgame.com
Peblo Custom ratings must be 50 characters or less
Registered 05/07/2002
Points 185
23rd March, 2007 at 04:32:57 -
So... you want a slacker way of shooting?
"Isn't it always amazing how we characterize a person's intelligence by how closely their thinking matches ours?"
~Belgarath
Your character can only face one of two directions, so you're storing boolean data. There's no real functional difference besides not needing to initialise it to avoid the possibility of Shooting=0, but it's just good practice to use a flag in this case. You did ask for the safest solution.
My main point was that your original code is better than what's been suggested so far. I could get it down to one event if you're using custom movement, though.
Thanks Radix, I've changed it to flags. So for all those platformers out there; use these events for shooting if you want the best results. That's of course only if you want!
I had to add 1 more event to the list because I wanted him shooting in the right direction as soon as the frame started.
[1] Start of Frame ---> Set internal flag 0 on
[2] Repeat while pressing Right ---> Set internal flag 0 on
[3] Repeat while pressing Left ---> Set internal flag 0 off
[4] Pressed Ctrl.
Player: internal flag 0 is on ---> Shoot bullet right at speed 100
[5] Pressed Ctrl.
Player: internal flag 0 is off ---> Shoot bullet left at speed 100
I tried Klikmaster's way and it's actually pretty good. I suppose it's better keeping things simple.
I don't know why Klikmaster thought I was using the default movement. I'm using DavidN's tutorial and it's bloody great!
Anyway I made it so my player's initial direction was right so he shoots right at the start of frame.
You don't need to initialise the flag, just swap your events so flag off is right and flag on is left.
I'm not familiar with Wong's tutorial, but since you're using a custom engine it should be possible to simplify these events further. For example, by seeing how the engine stores directions then using this value in a calculation for the direction of the bullet, which gets you down to one event. But it's up to you, there's nothing wrong with using a couple more events if the end result is the same.