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

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
27th January, 2011 at 14:30:13 -

Ah, the days of using the timer in jump events. Uncontrollable variable jumping lol.

 
.

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
27th January, 2011 at 18:30:06 -

Well, just so you guys can see, this is what i did.

+Object(Guninhand) Is faceing ->
+Alterable value A of Guninhand is lower or = to 0
+Upon Pressing D key
= Fire bullet
= add 20 to alterable value A of guninhand

and then...

+Every 0.1 seconds
+alterable value a of guninhand greater than 0
=subtract 0.1 from alterable value A

it works just fine too.

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

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
27th January, 2011 at 18:31:42 -

You should switch the every 0.1 seconds out for an always.

 

  		
  		

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
28th January, 2011 at 02:49:54 -


Originally Posted by OldManClayton
You should switch the every 0.1 seconds out for an always.


Always is faster then every 0.1 seconds.

 
http://www.facebook.com/truediamondgame

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
28th January, 2011 at 03:00:30 -

Which would be easily fixed by adding a higher number to the alterable value.

 

  		
  		

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
29th January, 2011 at 02:21:26 -

what would be the point in making it an always event? using the 0.1 secs makes it easier to moderate the amount of time between shots fired.
and i read something somewhere that said the fastest mmf2 can process events is 0.2 secs, is that true?

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

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

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!
29th January, 2011 at 05:25:59 -

No, MMF will process as fast as your computer can handle and within the frame rate limit.

OMC is right, the timer event may work fine on your computer, heck it may even run fine on every computer, but it's a bad habit to get into because once you start using larger amounts of time you'll start to have inconsistencies if the game runs at an inconsistent frame rate.

The Timer is based on real time, and not in-game time. That's the only real problem.

 
n/a

Duncan

Thelonious Dunc

Registered
  18/05/2002
Points
  552

VIP Member
29th January, 2011 at 13:23:45 -

Siven, once we've learned that the timer is evil, we use no timer at all!


and i read something somewhere that said the fastest mmf2 can process events is 0.2 secs, is that true?



Before MMF2 introduced framerate settings, all klik games ran at 50FPS. I.e., if the game was running at maximum speed (which it rarely would be), the events would run and the screen would be redrawn every 0.02 seconds (protip: this is completely different from every 0.2 seconds). The 'Always' event means 'every frame'.

Unless you use 'machine-independent speed', which I remember typically being gamebreaking, the game speed is going to fluctuate with framerate. The timer isn't, so it's a one-way ticket to inconsistency land.

 
n/a

Zephni

My other cars a Balrog

Registered
  17/10/2007
Points
  4019

Has Donated, Thank You!VIP MemberSonic Speed
30th January, 2011 at 11:27:20 -

So all in all.

This is is how your conditions and events should go:

+ Upon pressing "Fire button"
+ If guninhand is faceing direction 0
+ Active.altval = 0
- Fire bullet
- Set Active.altval to (time before you can shoot again, maybe 10)

+ While Active.altval > 0
- Active.altval = -1

 
dont make me divide by zero...

the Pilgrim



Registered
  31/05/2004
Points
  56
16th April, 2011 at 16:07:15 -


Originally Posted by Assault Andy
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.



Why haven't I figured this one out? This was just the one I needed for my comming new project! Thanks!

 
"I am always on the move, becuase I am a pilgrim in this world."

The Chris Street

Administrator
Unspeakably Lazy Admin

Registered
  14/05/2002
Points
  48487

Game of the Week WinnerClickzine StaffAcoders MemberKlikCast StarVIP MemberPicture Me This Round 35 Winner!Second GOTW AwardYou've Been Circy'd!Picture Me This Round 38 Winner!GOTM December Third Place!!
I am an April FoolKliktober Special Award Tag
16th April, 2011 at 16:16:19 -

I thought "Always" equated to "0.02" seconds.

 
n/a

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
19th April, 2011 at 12:29:30 -

I read an article that basically said 0.02 timer is equal to Always. Even if that's true it's just better habit to use always.

PS. How i'd do it.

code-------
+always
subtract from value 1

+Space key down
+value<=0
-Fire bullet
-set value=10
end code-------



 
thinking is like pong, it's easy, but you miss sometimes.

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
19th April, 2011 at 20:51:32 -


Originally Posted by The Chris Street
I thought "Always" equated to "0.02" seconds.

That's only when the framerate is 50. "Always" equates to FrameRate/100.0. The default framerate is 50, so by default, "Always" is "Every 0.02 seconds".

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

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
19th April, 2011 at 23:12:55 -

Yeah, I was gonna say. In-game loops are completely independent of time. This is precisely why timer events are a bad idea to use, because when the game slows down, timer events still fire on time. "Always" is based on in-game loops, so if you increased the framerate, naturally "always" would be a faster than 0.02 seconds. Likewise, if you slowed the framerate down, "always" would be slower than 0.02 seconds. Slow it down to 30fps and Always will literally fire 30x a second.

 
http://www.facebook.com/truediamondgame

Jacob!



Registered
  17/06/2011
Points
  153
24th April, 2011 at 06:01:16 -

No, you're all doing it wrong. The original poster had it almost right.

Repeat While "Fire" is pressed
Restrict Actions for 0.10 seconds
-Shoot Object

 
Have you even been far as decided to use even go want to do look more like?
   

Post Reply



 



Advertisement

Worth A Click