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.

Newcomers DBPro Corner / Please help with Newtonian like codesnippet...

Author
Message
Yskonyn
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: Netherlands
Posted: 29th Jan 2003 22:33
Hi guys!

Please help me out here. I have constructed a simple Newtonian like situation in which you can make the box accelerate and decelerate, however once in acceleration the program needs to be aware of other key inputs so that it can decelerate when I want it to. Currently you'll have to wait until the reference speed has been reached before you can input another command.
Does anyone have tips on how to make the program check for keyinputs all the time?

Many thanks!

make object box 1, 10, 10, 10
ref_spd# = 0
act_spd# = 0

START:

rem starting main loop en er wordt voor gezorgd dat de
rem waarde in een eventuele scan wordt aangehouden.
DO
move object 1,act_spd#
rem nu moeten we de thrust settings definieren en aan de
rem hand van een reference speed de actual speed laten
rem oplopen tot de actual speed gelijk is aan de ref spd

rem Waiting for input
print "Actual Speed: ",act_spd#
print "Reference Speed Set: ",ref_spd#

rem Assessing the input and commencing action...
TS01:
IF UPKEY()=1
ref_spd# = 1
REPEAT
print "Actual Speed: ",act_spd#
print "Reference Speed Set: ",ref_spd#
move object 1, act_spd#
act_spd# = act_spd# + 0.001
UNTIL act_spd# => 1
ENDIF

TS00:
IF DOWNKEY()=1
ref_spd# = 0
REPEAT
print "Actual Speed: ",act_spd#
print "Reference Speed Set: ",ref_spd#
move object 1, act_spd#
act_spd# = act_spd# - 0.001
UNTIL act_spd#
Yskonyn -
"It's better to wish down here you were up, then to wish up there you were down."
"The ONLY time you have too much fuel on board is when you are on fire."
D Man
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 29th Jan 2003 22:38
The code is not complete.
I think the only way is to check as often you can if an key was pressed.(by reading the pressed key into a variable; a$=inkey$())

"If you can't make it good
make it look good."
Bill Gates
Yskonyn
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: Netherlands
Posted: 29th Jan 2003 22:49


The code again...

Yskonyn -
"It's better to wish down here you were up, then to wish up there you were down."
"The ONLY time you have too much fuel on board is when you are on fire."
haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 29th Jan 2003 23:39
This might help, though i changed a lot of your code to fit my style.



Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
Yskonyn
21
Years of Service
User Offline
Joined: 19th Dec 2002
Location: Netherlands
Posted: 30th Jan 2003 13:18
Thanks haggisman, but you have altered the very principle of my idea.

The idea is that you set a thrust setting and the object has to accelerate until it has reached the speed you set (e.g. my ref_spd#) after that it has to keep that speed.
Like in games like MW4 and Spacesims, the 4 key for example sets 40% thrust.

My current code waits until the actual speed is the reference speed until it accepts new inputs. I only want to change the code so that it takes inputs all the time, so I have full control over the object.

I hope it is clear what I want?
Any other suggestions?

Yskonyn -
"It's better to wish down here you were up, then to wish up there you were down."
"The ONLY time you have too much fuel on board is when you are on fire."
haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Jan 2003 15:24
try this, though i coded this in college so there may be a few syntax errors :-


Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp
haggisman
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 30th Jan 2003 19:51
oops there was a problem



Specs:- 1GHZ athlon, Radeon8500, 192mb ram, winxp

Login to post a reply

Server time is: 2024-09-19 02:45:37
Your offset time is: 2024-09-19 02:45:37