Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Tap direction to run using events?

I'm curious as to how I could make a system where as you tap a certain key your character will excelerate slowly than as you continue to tap your charcater will maintain a running speed. I have no idea where to start on this one and any help would be apreiciated.
 

Star

Sponsor

Conditional Branch if Left Button is being pressed
>>> Change Game Variables 001 add +1
>>> Change Game Variables 002 == -1
>>> Change Game Variables 003 == -1
>>> Change Game Variables 004 == -1
Else
>>>Conditional Branch if Right is being pressed
>>>>>> Change Game Variables 001 == -1
>>>>>> Change Game Variables 002 add +1
>>>>>> Change Game Variables 003 == -1
>>>>>> Change Game Variables 004 == -1
>>>>>> Else
>>>>>> Conditional Branch if Down is being pressed
>>>>>>>>> Change Game Variables 001 == -1
>>>>>>>>> Change Game Variables 002 == -1
>>>>>>>>> Change Game Variables 003 add +1
>>>>>>>>> Change Game Variables 004 == -1
>>>>>>>>> Else
>>>>>>>>> Conditional Branch if Up is being pressed
>>>>>>>>>>>> Change Game Variables 001 == -1
>>>>>>>>>>>> Change Game Variables 002 == -1
>>>>>>>>>>>> Change Game Variables 003 == -1
>>>>>>>>>>>> Change Game Variables 004 add +1
>>>>>>>>>>>> Else
>>>>>>>>>>>> Change Game Variables 001 == 0
>>>>>>>>>>>> Change Game Variables 002 == 0
>>>>>>>>>>>> Change Game Variables 003 == 0
>>>>>>>>>>>> Change Game Variables 004 == 0

Conditional Branch if Game Variable 001 is Greater than 1
>>> Conditional Branch if Game Variable 001 is Less than 7
>>>>>> Set Move Route Player
>>>>>> Change Speed 4
>>>>>> Else
>>>>>> Conditional Branch if Game Variable 001 is Greater than 7
>>>>>>>>> Conditional Branch if Game Variable 001 is Less than 14
>>>>>>>>> Set Move Route Player
>>>>>>>>> Change Speed 5
>>>>>>>>> Else
>>>>>>>>> Conditional Branch is Game Variable 001 is Greater than 14
>>>>>>>>>>>> Set Move Route Player
>>>>>>>>>>>> Change Speed 6
Else
Conditional Branch if Game Variable 001 == 0
Change Speed 3

Conditional Branch if Game Variable 002 is Greater than 1
>>> Conditional Branch if Game Variable 002 is Less than 7
>>>>>> Set Move Route Player
>>>>>> Change Speed 4
>>>>>> Else
>>>>>> Conditional Branch if Game Variable 002 is Greater than 7
>>>>>>>>> Conditional Branch if Game Variable 002 is Less than 14
>>>>>>>>> Set Move Route Player
>>>>>>>>> Change Speed 5
>>>>>>>>> Else
>>>>>>>>> Conditional Branch is Game Variable 002 is Greater than 14
>>>>>>>>>>>> Set Move Route Player
>>>>>>>>>>>> Change Speed 6
Else
Conditional Branch if Game Variable 002 == 0
Change Speed 3

Conditional Branch if Game Variable 003 is Greater than 1
>>> Conditional Branch if Game Variable 003 is Less than 7
>>>>>> Set Move Route Player
>>>>>> Change Speed 4
>>>>>> Else
>>>>>> Conditional Branch if Game Variable 003 is Greater than 7
>>>>>>>>> Conditional Branch if Game Variable 003 is Less than 14
>>>>>>>>> Set Move Route Player
>>>>>>>>> Change Speed 5
>>>>>>>>> Else
>>>>>>>>> Conditional Branch is Game Variable 003 is Greater than 14
>>>>>>>>>>>> Set Move Route Player
>>>>>>>>>>>> Change Speed 6
Else
Conditional Branch if Game Variable 003 == 0
Change Speed 3

Conditional Branch if Game Variable 004 is Greater than 1
>>> Conditional Branch if Game Variable 004 is Less than 7
>>>>>> Set Move Route Player
>>>>>> Change Speed 4
>>>>>> Else
>>>>>> Conditional Branch if Game Variable 004 is Greater than 7
>>>>>>>>> Conditional Branch if Game Variable 004 is Less than 14
>>>>>>>>> Set Move Route Player
>>>>>>>>> Change Speed 5
>>>>>>>>> Else
>>>>>>>>> Conditional Branch is Game Variable 004 is Greater than 14
>>>>>>>>>>>> Set Move Route Player
>>>>>>>>>>>> Change Speed 6
Else
Conditional Branch if Game Variable 004 == 0
Change Speed 3

Wait of 1 frames

Slap this on a parallel process
 

Zeriab

Sponsor

Alternatively you could try Punk's Double Tap Dash System which supposedly is plug 'n play. (I haven't tried it)
Edit: Oh wait, you want the player to slow down when you don't tap enough. I got the read the description properly >_<
I suggest you look at the systems present and see if you can come up with a design which solves your problem.
 

Jason

Awesome Bro

StarGGundam2":3lv2pw9r said:
Code:
 

Conditional Branch if Left Button is being pressed

>>> Change Game Variables 001 add +1

>>> Change Game Variables 002 == -1

>>> Change Game Variables 003 == -1

>>> Change Game Variables 004 == -1

Else

>>>Conditional Branch if Right is being pressed

>>>>>> Change Game Variables 001 == -1

>>>>>> Change Game Variables 002 add +1

>>>>>> Change Game Variables 003 == -1

>>>>>> Change Game Variables 004 == -1

>>>>>> Else

>>>>>> Conditional Branch if Down is being pressed

>>>>>>>>> Change Game Variables 001 == -1

>>>>>>>>> Change Game Variables 002 == -1

>>>>>>>>> Change Game Variables 003 add +1

>>>>>>>>> Change Game Variables 004 == -1

>>>>>>>>> Else

>>>>>>>>> Conditional Branch if Up is being pressed

>>>>>>>>>>>> Change Game Variables 001 == -1

>>>>>>>>>>>> Change Game Variables 002 == -1

>>>>>>>>>>>> Change Game Variables 003 == -1

>>>>>>>>>>>> Change Game Variables 004 add +1

>>>>>>>>>>>> Else

>>>>>>>>>>>> Change Game Variables 001 == 0

>>>>>>>>>>>> Change Game Variables 002 == 0

>>>>>>>>>>>> Change Game Variables 003 == 0

>>>>>>>>>>>> Change Game Variables 004 == 0

 

Conditional Branch if Game Variable 001 is Greater than 1 

>>> Conditional Branch if Game Variable 001 is Less than 7 

>>>>>> Set Move Route Player

>>>>>> Change Speed 4

>>>>>> Else

>>>>>> Conditional Branch if Game Variable 001 is Greater than 7

>>>>>>>>> Conditional Branch if Game Variable 001 is Less than 14

>>>>>>>>> Set Move Route Player

>>>>>>>>> Change Speed 5

>>>>>>>>> Else

>>>>>>>>> Conditional Branch is Game Variable 001 is Greater than 14

>>>>>>>>>>>> Set Move Route Player

>>>>>>>>>>>> Change Speed 6 

Else

Conditional Branch if Game Variable 001 == 0

Change Speed 3

 

Conditional Branch if Game Variable 002 is Greater than 1 

>>> Conditional Branch if Game Variable 002 is Less than 7 

>>>>>> Set Move Route Player

>>>>>> Change Speed 4

>>>>>> Else

>>>>>> Conditional Branch if Game Variable 002 is Greater than 7

>>>>>>>>> Conditional Branch if Game Variable 002 is Less than 14

>>>>>>>>> Set Move Route Player

>>>>>>>>> Change Speed 5

>>>>>>>>> Else

>>>>>>>>> Conditional Branch is Game Variable 002 is Greater than 14

>>>>>>>>>>>> Set Move Route Player

>>>>>>>>>>>> Change Speed 6 

Else

Conditional Branch if Game Variable 002 == 0

Change Speed 3

 

Conditional Branch if Game Variable 003 is Greater than 1 

>>> Conditional Branch if Game Variable 003 is Less than 7 

>>>>>> Set Move Route Player

>>>>>> Change Speed 4

>>>>>> Else

>>>>>> Conditional Branch if Game Variable 003 is Greater than 7

>>>>>>>>> Conditional Branch if Game Variable 003 is Less than 14

>>>>>>>>> Set Move Route Player

>>>>>>>>> Change Speed 5

>>>>>>>>> Else

>>>>>>>>> Conditional Branch is Game Variable 003 is Greater than 14

>>>>>>>>>>>> Set Move Route Player

>>>>>>>>>>>> Change Speed 6 

Else

Conditional Branch if Game Variable 003 == 0

Change Speed 3

 

Conditional Branch if Game Variable 004 is Greater than 1 

>>> Conditional Branch if Game Variable 004 is Less than 7 

>>>>>> Set Move Route Player

>>>>>> Change Speed 4

>>>>>> Else

>>>>>> Conditional Branch if Game Variable 004 is Greater than 7

>>>>>>>>> Conditional Branch if Game Variable 004 is Less than 14

>>>>>>>>> Set Move Route Player

>>>>>>>>> Change Speed 5

>>>>>>>>> Else

>>>>>>>>> Conditional Branch is Game Variable 004 is Greater than 14

>>>>>>>>>>>> Set Move Route Player

>>>>>>>>>>>> Change Speed 6 

Else

Conditional Branch if Game Variable 004 == 0

Change Speed 3

 

Wait of 1 frames

 

Slap this on a parallel process

Yeah, maybe you should wrap some code tags around that, and also, what the hell are Variables 1, 2, 3 and 4 ? For all LLaw knows, they could be Player HP, Player SP, Terrain Tag, and Map ID.

Maybe you should make your explanation more clear.
 

Star

Sponsor

jbrist":5m7w97d6 said:
Yeah, maybe you should wrap some code tags around that, and also, what the hell are Variables 1, 2, 3 and 4 ? For all LLaw knows, they could be Player HP, Player SP, Terrain Tag, and Map ID.

Maybe you should make your explanation more clear.
What was the point of your post? Zeriab already provided the OP with a source of a better script or event. That makes my post useless, and yours too. It does not matter what you name variables, as long as the same variable doesn't operate two different things unless you want them too. They aren't anything but values depending on what arrow key you're pressing and how long you're pressing it.
 

Zeriab

Sponsor

The event system I linked to solves a different problem. (Double tap => dash)
The problem presented here is tap => increase in speed. No tap => decrease in speed. (Within a specific range)
@LLawliet: What happens if the player changes direction? (Or tries to?)
Should the speed be as if nothing has happened?
Should the player just start at normal speed and increasing it with tap?
Anything else?

*hugs*
- Zeriab
 

Jason

Awesome Bro

StarGGundam2":25zf9eof said:
jbrist":25zf9eof said:
Yeah, maybe you should wrap some code tags around that, and also, what the hell are Variables 1, 2, 3 and 4 ? For all LLaw knows, they could be Player HP, Player SP, Terrain Tag, and Map ID.

Maybe you should make your explanation more clear.
What was the point of your post? Zeriab already provided the OP with a source of a better script or event. That makes my post useless, and yours too. It does not matter what you name variables, as long as the same variable doesn't operate two different things unless you want them too. They aren't anything but values depending on what arrow key you're pressing and how long you're pressing it.

The point of my post was to ask whats the point of your post pretty much, you used four variables but never stated what they were, and you made your post extremely long (Scrolling down it is annoying), when you could have put code brackets on as I suggested.
 

Zeriab

Sponsor

What are you talking about jbrist?
They are numbers. (Or rather contain numbers)
It's obvious from the context what they are used for.

I assumed LLawliet has basic understanding of variables and I am sure StarG did as well.
Explaining how it works is good suggestion (even though that's not exactly what you suggest) since some issues would most likely have been brought forth into the light.
I can break it down to you if you want though ^^
 

Jason

Awesome Bro

Zeriab":daelwlo7 said:
What are you talking about jbrist?
They are numbers. (Or rather contain numbers)
It's obvious from the context what they are used for.

I assumed LLawliet has basic understanding of variables and I am sure StarG did as well.
Explaining how it works is good suggestion (even though that's not exactly what you suggest) since some issues would most likely have been brought forth into the light.
I can break it down to you if you want though ^^

I mean though, he hasn't said what the variables contain, obviously some form of numbers, but how does LLaw know what;

Conditional Branch if Left Button is being pressed
>>> Change Game Variables 001 add +1
>>> Change Game Variables 002 == -1
>>> Change Game Variables 003 == -1
>>> Change Game Variables 004 == -1

Means if StarG didn't say what to set the variables up to include, are they just random numbers, does variable 2 contain Map ID ? No one knows cause he didn't explain.
 

Star

Sponsor

jbrist":19p4yjkj said:
I mean though, he hasn't said what the variables contain, obviously some form of numbers, but how does LLaw know what;

Conditional Branch if Left Button is being pressed
>>> Change Game Variables 001 add +1
>>> Change Game Variables 002 == -1
>>> Change Game Variables 003 == -1
>>> Change Game Variables 004 == -1

Means if StarG didn't say what to set the variables up to include, are they just random numbers, does variable 2 contain Map ID ? No one knows cause he didn't explain.
I see no sign of LLaw. I guess they figured out what they wanted. Anyway. I'll explain to you what the numbers are. They are Constants. You set them up under the Constant and there are four of them depending on what arrow key you are pressing.

Variables don't really have to equal a specific Object. You can make their value change depending on what function you do. Such as talking to someone more than once. It's just like a Multi Switch with endless possibilities

But it's really a rough system. Cause it doesn't take into fact that the OP wants to tap the arrow keys and it also doesn't work right with 8 directional movement
 

Jason

Awesome Bro

StarGGundam2":3544bhkr said:
jbrist":3544bhkr said:
I mean though, he hasn't said what the variables contain, obviously some form of numbers, but how does LLaw know what;

Conditional Branch if Left Button is being pressed
>>> Change Game Variables 001 add +1
>>> Change Game Variables 002 == -1
>>> Change Game Variables 003 == -1
>>> Change Game Variables 004 == -1

Means if StarG didn't say what to set the variables up to include, are they just random numbers, does variable 2 contain Map ID ? No one knows cause he didn't explain.
I see no sign of LLaw. I guess they figured out what they wanted. Anyway. I'll explain to you what the numbers are. They are Constants. You set them up under the Constant and there are four of them depending on what arrow key you are pressing.

Variables don't really have to equal a specific Object. You can make their value change depending on what function you do. Such as talking to someone more than once. It's just like a Multi Switch with endless possibilities

But it's really a rough system. Cause it doesn't take into fact that the OP wants to tap the arrow keys and it also doesn't work right with 8 directional movement

Yeah I know about increasing a variable when a button is pressed, even if it has no significant value, but I don't get why you're using four variables with one button press, thats what's confusing me here, lol.
 

Star

Sponsor

jbrist":2y4r324l said:
Yeah I know about increasing a variable when a button is pressed, even if it has no significant value, but I don't get why you're using four variables with one button press, thats what's confusing me here, lol.
Well if that's what you were concerned about you shoulda said so. I used four variables for one button press so that the following wouldn't come on if you are at least pressing one button

Else
Conditional Branch if Game Variable 001 == 0
Change Speed 3

Else
Conditional Branch if Game Variable 002 == 0
Change Speed 3

Else
Conditional Branch if Game Variable 003 == 0
Change Speed 3

Else
Conditional Branch if Game Variable 004 == 0
Change Speed 3

If they are set to -1 when you are at least pressing a button. These Zero values won't activate messing with your characters current speed
 

Zeriab

Sponsor

>>>>>>>>>>>> Else
>>>>>>>>>>>> Change Game Variables 001 == 0
>>>>>>>>>>>> Change Game Variables 002 == 0
>>>>>>>>>>>> Change Game Variables 003 == 0
>>>>>>>>>>>> Change Game Variables 004 == 0
:x

On a more progressive note let's try to analyze the system. We can do this even if there are parts we don't know yet.
I would suggest looking the system as having two components.
  • Registering taps component
  • Decreasing speed over time component

We don't know how exactly the first component will work, but we know it has to do with registering taps of a keys (as compared to key pressed)
What happens if an arrow key is tapped and then another arrow key is tapped we don't know.
For the latter component we could easily imagine it being counting down a variable and then determine the speed from the value of the variable. With this representation of decreasing the speed over the time we could increase the speed by increasing variable which could be the effect of a key tap. That could be a coupling between the two components.

Try to create the two component separately to start with and post your response :3
 

Star

Sponsor

Hmm... I feel like Zeriab is the Mushroom boy from Super Mario RPG. He's trying to show me some pointers on how to ride a barrel down stream.

Code:
Conditional Branch if Left Button is being pressed

>>> Conditional Branch if Variable 001 is Greater than or equal to 75

>>> Change Game Variables 001 == 75

>>> Else

>>> Change Game Variables 001 add +1

Else

>>>Conditional Branch if Right is being pressed

>>>>>> Conditional Branch if Variable 001 is Greater than or equal to 75

>>>>>> Change Game Variables 001 == 75

>>>>>> Else

>>>>>> Change Game Variables 001 add +1

>>>>>> Else

>>>>>> Conditional Branch if Down is being pressed

>>>>>>>>> Conditional Branch if Variable 001 is Greater than or equal to 75

>>>>>>>>> Change Game Variables 001 == 75

>>>>>>>>> Else

>>>>>>>>> Change Game Variables 001 add +1

>>>>>>>>> Else

>>>>>>>>> Conditional Branch if Up is being pressed

>>>>>>>>>>>> Conditional Branch if Variable 001 is Greater than or equal to 75

>>>>>>>>>>>> Change Game Variables 001 == 75

>>>>>>>>>>>> Else

>>>>>>>>>>>> Change Game Variables 001 add +1

>>>>>>>>>>>> Else

>>>>>>>>>>>> Conditional Branch if Variable 001 is Less than or equal to -75

>>>>>>>>>>>> Change Game Variables 001 == -75

>>>>>>>>>>>> Else

>>>>>>>>>>>> Change Game Variables 001 add -1

 

Conditional Branch if Game Variable 001 is Greater than - 99

>>> Conditional Branch if Game Variable 001 is Less than -25

>>>>>> Set Move Route Player

>>>>>> Change Speed 1

 

Conditional Branch if Game Variable 001 is Greater than or equal too - 25

>>> Conditional Branch if Game Variable 001 is Less than - 1

>>>>>> Set Move Route Player

>>>>>> Change Speed 2

 

Conditional Branch if Game Variable 001 is Greater than or equal too - 1

>>> Conditional Branch if Game Variable 001 is Less than + 10

>>>>>> Set Move Route Player

>>>>>> Change Speed 3

 

Conditional Branch if Game Variable 001 is Greater than or equal too +10

>>> Conditional Branch if Game Variable 001 is Less than + 30

>>>>>> Set Move Route Player

>>>>>> Change Speed 4

 

Conditional Branch if Game Variable 001 is Greater than or equal too +30

>>> Conditional Branch if Game Variable 001 is Less than + 50

>>>>>> Set Move Route Player

>>>>>> Change Speed 5

 

Conditional Branch if Game Variable 001 is Greater than or equal too +50

>>> Conditional Branch if Game Variable 001 is Less than + 99

>>>>>> Set Move Route Player

>>>>>> Change Speed 6

 

Wait of 5 frames

How many frog coins does this get me? :x I think I get it now ' - ' Does this look right?

*edit* Dangit. This still would work if you simply just held down an arrow key. Argh. I can't figure out this tapping business. Throw me a hint here Zeriab. I'm dying over here
 

Star

Sponsor

jbrist":3kp1rzps said:
Maybe you could put a wait on the end so it won't constantly go up/down, could work.
I thought about it. But still. If you were holding down the key or tapping. even if it waited to go constantly up and down. it would still go up and down just at a slower speed

I'm thinking maybe if there was a hidden timer. It could punish you for holding down the key to long
 

Zeriab

Sponsor

Since the topic starter hasn't replied yet I might as well try to teach you some eventing ^^
I believe you would learn better from doing it yourself rather than me giving you a solution.

You didn't understand what I meant by splitting the system up in two.
The reason is to simplify matters for yourself.
So let's start with the the decreasing speed over time part.
Assume that Game Variable 001 will magically be increased when the player taps.

Try to design that part.

*hugs*
- Zeriab
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top