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.

Author
Message
Graysire
12
Years of Service
User Offline
Joined: 18th Oct 2013
Location:
Posted: 22nd Dec 2013 01:55
if inkey$()="W" then move object 1,MySpeed
if inkey$()="S" then move object 1,0-MySpeed
if inkey$()="A" then A1Y = wrapvalue(A1Y-(MySpeed/3))
if inkey$()="D" then A1Y = wrapvalue(A1Y+(MySpeed/3))
want to include wasd controls
but when you hit a key that isn't W while holding W you stop.
help?
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 22nd Dec 2013 02:50
Inkey$ only returns one keypress. You need the scancode/keystate commands.

pcRaider
19
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 22nd Dec 2013 03:25
` Example Code

cls
do
if upkey()=1 then print "upkey()"
if downkey()=1 then print "downkey()"
if leftkey()=1 then print "leftkey()"
if rightkey()=1 then print "rightkey()"
if keystate(17)=1 then print "W up"
if keystate(31)=1 then print "S down"
if keystate(30)=1 then print "A left"
if keystate(32)=1 then print "D right"
loop
end

windowsXp
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Dec 2013 12:46
Neat - except I think this works better:





Powered by Free Banners
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 22nd Dec 2013 15:20
You could simplify it further like so...



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 22nd Dec 2013 16:50
Quote: "You could simplify it further like so..."


Very true.



Powered by Free Banners
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 23rd Dec 2013 01:36
Even better...


"Get in the Van!" - Van B
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Dec 2013 14:17
@Sasuke
Nice one ..!!



I'm not a grumpy grandpa
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 23rd Dec 2013 14:57 Edited at: 23rd Dec 2013 14:58
Quote: "Nice one ..!!"

Cheers

MoveX/Z or Y (depending on your set up) are multipliers so you'd multiply them by your speed, example:

move object 1, moveZ# * speed#

Because of this:

moveZ# = (forward-backward)

If forward = 1 then moveZ = 1-0 which = 1. If backwards = 1 then moveZ = 0-1 which = -1. Because of this you don't need to put a - in front of moveX/Y/Z because it handles both directions. Example:



The move multipliers are handy because we can scale them for different speeds rather than using multiple speed variables. For instance if we were strafing while moving forward or backwards we'd want to scale down the speed because combining movements would slow the player down a little we can just scale the multipliers:



"Get in the Van!" - Van B

Login to post a reply

Server time is: 2026-07-07 11:21:44
Your offset time is: 2026-07-07 11:21:44