The Daily Click ::. Forums ::. Klik Coding Help ::. How do you make a weapon fire when you press a button, but not too fast?
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
26th January, 2011 at 10:32:25 -

so id like to make it so my pistols are shot when you press the button, not a press and hold kinda deal, but i did what seemed logical and it didnt work.
heres what the code looks like...
Object(Guninhand) Is faceing ->
Limit Condition for 0.30secs
+Upon Pressing D key
= Fire bullet

logically that would mean you can only shoot every 0.30 seconds, but what happens is you shoot once, and than it wont let you shoot in that direction again. also, there are each of those events for the other directions as well. the only reason i dont have hte bullet fireing in the direction the guninhand is pointing is because in order to have an arm pointed upward on the left side and on the right side, i had to use the 2 spots on the animation thing to the left and right of the UP slot, if that makes any sense. anyone know what i did incorrectly?

 
[Game design makes my brain feel like its gonna explode.]

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
26th January, 2011 at 13:10:09 -

Repeat while is pressed "Space"
+ Active.AltA = 0
Then
> Active.AltA = 10
> Fire Bullet

If Active.AltA > 0
Then
> Active.AltA = Active.AltA - 1



Where 10 is the cooldown time.

Edited by an Administrator

 
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

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
26th January, 2011 at 13:10:34 -

I'd use a flag or alterable value, depending on how long you want the pause to be.

Object is facing ->
+ Object flag 0 is off
+ Upon Pressing D key
= Fire bullet
+ Set Object flag 0 on

Every 0.30 seconds (Or always, or whatever)
= Set object flag 0 off

Edit: Bah! Too slow. Use AssaultAndy's method. It will work independent of the timer.

Edited by OMC

 

  		
  		

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
26th January, 2011 at 14:53:44 -

Eww thats not typical of you to recommend that sort of method, OMC.

 
n/a

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
26th January, 2011 at 19:10:36 -

Well, I was going to use an alterable value method, but I changed my mind for some reason.

Must not have been thinking straight this morning!

 

  		
  		

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
26th January, 2011 at 19:39:06 -

Then you would die if you saw my code Gamester...especially the code in OMC's game that I helped work on.

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
26th January, 2011 at 20:51:49 -

(for all the noobs and fellow novices out there)

I remember reading somewhere that using the Timer to have a set time for events isn't as effective as using an alterable value, as one machine may be able to keep up with the timer, but others might not. As I am not the best at coding, I tend to stick with using Alterable Values in all cases where a timer might do, simply because if there's a sequence of events based upon timers and/or regular intervals, they'll always keep pace with the way the rest of the game is running.

But most of y'all know this already. My point is that I just shy away from using the Timer object unless there are very, very few Active Objects and/or functions/events.

 
n/a

JetpackLover



Registered
  01/03/2007
Points
  212
26th January, 2011 at 23:38:39 -

Why not use TimeX and use the nloop function?

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
26th January, 2011 at 23:57:39 -


Originally Posted by s-m-r
(for all the noobs and fellow novices out there)

I remember reading somewhere that using the Timer to have a set time for events isn't as effective as using an alterable value, as one machine may be able to keep up with the timer, but others might not. As I am not the best at coding, I tend to stick with using Alterable Values in all cases where a timer might do, simply because if there's a sequence of events based upon timers and/or regular intervals, they'll always keep pace with the way the rest of the game is running.

But most of y'all know this already. My point is that I just shy away from using the Timer object unless there are very, very few Active Objects and/or functions/events.



For the perfectionist its also less accurate as you cannot reset the timer.

If you have an event that says

Z is pressed
+ Every 00.05
- Shoot

and you start pressing Z at 0.02 then the object shoots 00.02 seconds earlier

if that makes sense.

Negligible? Probably, but it bothers me. You can reset the alterable value if the player lets go of shoot.

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
27th January, 2011 at 01:11:56 -

I use no timer events at all. But...



If you have an event that says

Z is pressed
+ Every 00.05
- Shoot

and you start pressing Z at 0.02 then the object shoots 00.02 seconds earlier



It still makes me cringe because I know this has always been how it works, but I noticed in TGF2NE (only MMF2 product I've used) it's been "fixed".

Every 00.05 + While Z is pressed uses the frame timer,
While Z is pressed + Every 00.05 starts a unique count

So OMC's version should work as Object Flag 0 on + Every 00.30

It still sux because it uses the timer!

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
27th January, 2011 at 01:59:31 -

Wow seriously?

Thanks o_o.

but yeah timer = bleh

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
27th January, 2011 at 06:15:36 -

I still have a nasty habit of using timer events. I also have a nasty habit of stopping at a McDonalds and suddenly getting hungry. I know it's horrible for me, and when I think about it long enough, I go for the much better alternative. I think this is a pretty good analogy.

 
http://www.facebook.com/truediamondgame

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
27th January, 2011 at 08:54:44 -

thanks everyone! i think i gathered what info that i need to finish this little deal up. also, ive learned... Timer = evil.

 
[Game design makes my brain feel like its gonna explode.]

JetpackLover



Registered
  01/03/2007
Points
  212
27th January, 2011 at 09:21:06 -

TimeX is pretty gooooood.

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
27th January, 2011 at 10:59:37 -


Originally Posted by DudeHuge
TimeX is pretty gooooood.



Yeah it can be nice, as long as you manage to start the "nloop count" from when you want to, i.e the same difficulty as resetting the timer.

Alterable values are the best for most situations, and since MMF2 has a shitload of em in every object you can afford to use them.

He, that was always a blast in MMF1.2, trying to make A.I with three alterable values and the flags.

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image
   

Post Reply



 



Advertisement

Worth A Click