Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / I need help about a speed jauger with joystick button hit

Years of Service
User Offline
Joined: 5th Dec 2010
Location: France
Posted: 2nd Feb 2018 17:51 Edited at: 2nd Feb 2018 17:59
Hi all,
the title of my post is not very clear lol
I'm going to try to explain my problem.
Just for fun, I wanted to program a short program to calculate at what speed I can hit and release a button, as it was used in video games like Decathlon on hyper sports. The faster you hit the button, the faster the screen caracter runs. I think it was very easy to do it but.... erg.... No way :/
I've tried this :

for i=1 to 50000
if joystick fire a() and a=0 then c=c+1:a=1
if joystick fire a()=0 and a=1 then c=c+1:a=0
print c
goto boucle

c is the variable that is counting how many times I hit and release the button. ... But I only got 1 or 2 for c when I try this.
I don't want the program to count on a long period, but on short period to use it as it's used in an Hypers Sports program :/

I don't know if my explanation is clear but I will be happy if someone can help me about this. Thanx !
DBPro Master
Years of Service
User Offline
Joined: 21st Nov 2007
Location: Austin, TX
Posted: 2nd Feb 2018 21:50 Edited at: 2nd Feb 2018 21:59
A lot of the hardware input commands only update once per sync I think, sticking all this in a for loop doesn't give the system much ability to update.

Also putting multiple commands with : after then can be buggy, it won't always execute all of them

Try something like this:

+ Code Snippet

A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.
Derek Darkly
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 2nd Feb 2018 23:40

Here u go my ninja.

+ Code Snippet
Send your parents to noisy sprite demo hell... enter the D-Zone
Years of Service
User Offline
Joined: 28th Jul 2016
Posted: 5th Feb 2018 09:00
I like to do it with functions. And i recommend to use a the timer function for time based events. A for loop can be inaccurate on different computers.
+ Code Snippet
may be cleaner if you use different buttons for different things
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit

Login to post a reply

Server time is: 2018-02-21 10:43:39
Your offset time is: 2018-02-21 10:43:39