The Daily Click ::. Forums ::. Klik Coding Help ::. Shooting with limited events.
 

Post Reply  Post Oekaki 
 

Posted By Message

eyeangle



Registered
  12/06/2003
Points
  1683
23rd March, 2007 at 04:13:24 -

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.

Image Edited by the Author.

 
theonecardgame.com

Peblo

Custom ratings must be 50 characters or less

Registered
  05/07/2002
Points
  185

Game of the Week WinnerVIP MemberI'm on a Boat360 OwnerAttention GetterThe Cake is a LieCardboard BoxHero of TimePS3 OwnerIt's-a me, Mario!
I'm a Storm TrooperSonic SpeedStrawberryI like Aliens!Wii OwnerMushroomGhostbuster!
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

eyeangle



Registered
  12/06/2003
Points
  1683
23rd March, 2007 at 04:35:48 -

More reliable...

 
theonecardgame.com

jpSoul



Registered
  25/10/2003
Points
  1714
23rd March, 2007 at 04:50:00 -

you can reduce the number of events to 3, without using the shoot function on mmf:

upon pressing left => create "bullet", set value A to -1, set X bullet to X player, set Y bullet to Y player

upon pressing right => create "bullet", set value A to 1, set X bullet to X player, set Y bullet to Y player

Value A of "bullet" <>0 => set X position of bullet to X bullet + 4* value A


4 is the speed in pixels, you can use any value you want

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
23rd March, 2007 at 07:26:11 -

Why not:
[1] Direction right + pressed Ctrl --------> shoot right
[2] Direction left + pressed Ctrl --------> shoot left

I suppose you are using the default movement, causing you to shoot down wen u dont want to?

Image Edited by the Author.

 
n/a

vrba79



Registered
  17/03/2007
Points
  125
23rd March, 2007 at 10:53:07 -

Default movement makes me a saaaaaaaaad panda.

 
[Will watch Aquaman cartoons for beer money.]

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
23rd March, 2007 at 21:14:00 -

I'd do it the way you posted, but use a flag instead of an alt value.

Phanoo: That method doesn't take a fire button into account, and isn't a great way of handling bullet movement anyway.

Klikmaster: What if no direction is pressed?

 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
23rd March, 2007 at 22:43:27 -

Why is it better to use a flag in this case?

Image Edited by the Author.

 
theonecardgame.com

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
24th March, 2007 at 02:20:10 -

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.

Image Edited by the Author.

 
n/a

eyeangle



Registered
  12/06/2003
Points
  1683
24th March, 2007 at 08:25:39 -

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

 
theonecardgame.com

eyeangle



Registered
  12/06/2003
Points
  1683
24th March, 2007 at 08:37:34 -

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.

Simple is best!

 
theonecardgame.com

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
24th March, 2007 at 21:09:00 -

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.

 
n/a

Bibin

At least 9001

Registered
  01/07/2005
Points
  308

Silver Cup WinnerGOTW Winner!Has Donated, Thank You!VIP Member
24th March, 2007 at 22:15:11 -

Marginally-unrelated, if you're using a custom platform engine, please give it variable height jumps:

Add this, and substitute n with a negative number:

[X] When [jump button] pressed
+ and player's Y velocity <
then
set player's Y velocity to

 
n/a

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
25th March, 2007 at 02:09:28 -

Uh, what? Why? There's nothing wrong with constant height jumping if that's how the game is intended.

 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
25th March, 2007 at 19:39:49 -

I would have though this would work if you want one event

upon pressing fire 1 shoot bullet + use same direction as characters direction,

 
.

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
26th March, 2007 at 13:15:03 -

Um sorry but this whole thing is kinda retarded.. Flags would be a good idea until you want to expand the game.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
26th March, 2007 at 21:20:10 -

It isn't 'retarded' to using flags.

Explain how expanding the game would cause problems.

 
.

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
28th March, 2007 at 00:00:39 -

Yeah, please do.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
28th March, 2007 at 02:15:44 -

Please do, WillWill.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
28th March, 2007 at 05:15:56 -

Haha, completely working without booleans? That'd give you a hell of a lot of problems after a while...

 
Old member (~2004-2007).
   

Post Reply



 



Advertisement

Worth A Click