The Daily Click ::. Forums ::. Klik Coding Help ::. Controller tapping
 

Post Reply  Post Oekaki 
 

Posted By Message

RenatoDep

The Ion Adventurer

Registered
  22/03/2003
Points
  804

KlikCast Star
25th July, 2006 at 22:56:37 -

I was wondering how would you do so when you tap the let's say, left button twice really fast, the character runs...

thank you in advance

 
http://www.galaxiachronicles.com
http://www.eivix.com

-Vinny-



Registered
  12/01/2005
Points
  436
26th July, 2006 at 00:21:13 -

well .... i haven't touched tgf for a while now but to accomplish something like that i would use a counter or alterable value + flags to determine the time inbetween button taps to allow for "double-tap: run"

something like this (note: this is not how the code would look like exactly as i haven't touched my tgf in a long whlile now but you should be able to code this in regardless)


always
alterable value a > 0
- subtract 1 from alterable value


alterable value a = 0
- flag 1: off


is flag 1 set to 'off'?
is [->] pressed? (held) (this is will be walk i guess)
- character x position = character x position + speed value (or whatever method of movement you use, it's up to you)


is [->] pressed? (not held)
- flag 1: on
- set alterable value a = 5


is flag 1 set to 'on'?
is [->] pressed? (held) (this will be run)
- character x position = character x position + speed value (or whatever method of movement you use, it's up to you)


this of course is untested but in theory should work (my theory anyways )
if this doesn't work, i'll fiddle with tgf until i get something taht works, heh

 
Vinny

RenatoDep

The Ion Adventurer

Registered
  22/03/2003
Points
  804

KlikCast Star
26th July, 2006 at 00:24:51 -

I have the character running by holding down another button, all I want is instead of that...when you tap the controler twice quick, he'd run...and take the button action out...

 
http://www.galaxiachronicles.com
http://www.eivix.com

Jakob37



Registered
  07/08/2005
Points
  541
26th July, 2006 at 05:10:30 -

Can you not use flags?

Image Edited by the Author.

 
n/a

-Vinny-



Registered
  12/01/2005
Points
  436
26th July, 2006 at 11:31:08 -

erhm ... yeah ... so i finally opened up tgf again and tried that out and it's some baaadd coding but i'm working on it, i'll get back to you when something works out

 
Vinny

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
26th July, 2006 at 11:33:29 -

where the key is pressed, try including a 'only one action when event loops'

 
My signature is never too big!!!

RenatoDep

The Ion Adventurer

Registered
  22/03/2003
Points
  804

KlikCast Star
26th July, 2006 at 12:08:48 -

I got it working using a timer, but it sucks because if you are walking, and you switch direction, it sees it sometimes as tapping, and he runs...so any ideas??

 
http://www.galaxiachronicles.com
http://www.eivix.com

Werbad



Registered
  18/09/2002
Points
  235
26th July, 2006 at 12:23:30 -

* Upon pressing "Right Arrow"
+ Value A > 0
- Set flag 0 on

* Value A > 0
- Sub 1 to Value A

* Upon pressing "Right Arrow"
+ Value A = 0
- Set flag 0 off
- Set Value A to 10

//walk
* Repeat while "Right Arrow" is pressed
+ Flag 0 is off
X = X + 1

//run
* Repeat while "Right Arrow" is pressed
+ Flag 0 is on
X = X + 3

 
n/a

-Vinny-



Registered
  12/01/2005
Points
  436
26th July, 2006 at 14:44:03 -

yupp that ^ works

now just add other conditions for collision detection now

Image Edited by the Author.

 
Vinny

RenatoDep

The Ion Adventurer

Registered
  22/03/2003
Points
  804

KlikCast Star
26th July, 2006 at 15:17:01 -

Wait sensation, which one works...your or his?

 
http://www.galaxiachronicles.com
http://www.eivix.com

-Vinny-



Registered
  12/01/2005
Points
  436
26th July, 2006 at 15:20:41 -

oh sorry, i meant his, heh

you will want to use loops and what not to make it more efficient though of course

i've managed to change that to for customizable speeds

and boo, hiss, i can't change my previous posts, mainly the one with my bad coding hehehe

Image Edited by the Author.

oh wait, i re read your second post

you want it to start running automatically with out a pressed key? like *tap tap* and take finger off rather than *tap hold*?

Image Edited by the Author.

 
Vinny

RenatoDep

The Ion Adventurer

Registered
  22/03/2003
Points
  804

KlikCast Star
26th July, 2006 at 15:47:11 -

Sweet, got it working Thank you guys

 
http://www.galaxiachronicles.com
http://www.eivix.com
   

Post Reply



 



Advertisement

Worth A Click