• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Arrow keys movement

Status
Not open for further replies.
Level 3
Joined
Aug 18, 2004
Messages
60
Hey how do you move and turn using the arrow keys? Like say you wanted to make a map with a starfighter that always moved ford and you could feel like you were actully flying it by turn it and stuff?
Thanx
 
Level 7
Joined
Jul 30, 2004
Messages
451
Leinad said:
Hey how do you move and turn using the arrow keys? Like say you wanted to make a map with a starfighter that always moved ford and you could feel like you were actully flying it by turn it and stuff?
Thanx

roughly like this

Code:
event -
    player presses left key
actions -
    set bLeft = true

event -
    player releases left key
actions -
    set bLeft = false

//same with right etc...

event -
    periodical every 0.5 seconds
actions -
    if bLeft == true then
        make playerunit face (facing direction of playerunit + 10.00)
    if bRight == true then
        make playerunit face (facing direction of playerunit - 10.00)
    if bUp == true then
        order playerunit to move to position of playerunit offset by 128 towards facing direction of playerunit

thats the basic premise, of course what i just wrote is a rather bad version of it and u can improve it greatly, since it won't let u turn while in motion, but thats the basic way

if u want it multiplayer just use arrays and loops
note - multiplayer is bad with arrow keys since non-host players will have a substantial delay in arrow key pressing
 
Level 3
Joined
Aug 18, 2004
Messages
60
Thanx

Thanx, I will give it a shot. However I need it to turn while your moveing. I have seen it done very well befor on a map I think was called legasys tide of the serpent (sry about bad spelling). Anyway if anyone comes up with more ideas of how to make this work im all ears.(You can also give me ideas for the starfighter map if you want.)
 
Level 7
Joined
Jul 30, 2004
Messages
451
Re: Thanx

Leinad said:
Thanx, I will give it a shot. However I need it to turn while your moveing. I have seen it done very well befor on a map I think was called legasys tide of the serpent (sry about bad spelling). Anyway if anyone comes up with more ideas of how to make this work im all ears.(You can also give me ideas for the starfighter map if you want.)

ok, well this would be my way

Code:
event - 
    player X presses left key 
actions - 
    set bLeft[player number of triggering player] = true

event - 
    player X releases left key 
actions - 
    set bLeft[player number of triggering player] = false 
    set nLeft[player number of triggering player] = 0

//same with right

event -
    player X presses up key
actions -
    set bUp[player number of triggering player] = true

event -
    player X releases up key
actions -
    set bUp[player number of triggering player] = false
    set nUp[player number of triggering player] = 0

event - 
    periodical every 0.05 seconds 
actions - 
    for A = 1 to MaxPlayers
        if bUp[A] == true then
            set nUp[A] = nUp[A] + 1
            if nUp[A] >= 25 then
                set fSpeed[A] = fSpeed[A] + 5.00
            else
                set fSpeed[A] = fSpeed[A] + 2.50
        else
            set fSpeed[A] = fSpeed[A] - 10.00
            if fSpeed[A] < 0.00 then
                set fSpeed[A] = 0.00
        //--//--//
        if bLeft[A] == true then
            if nLeft[A] >= 25 then
                set fFace[A] = fFace[A] + 4.00
            else
                set fFace[A] = fFace[A] + 2.00
        if bRight[A] == true then 
            if nRight[A] >= 25 then
                set fFace[A] = fFace[A] - 4.00
            else
                set fFace[A] = fFace[A] - 2.00
        //--//--//
        if fSpeed[A] > 0.00 then
            set pointMoveTo[A] = position of unitPlayerUnit[A] offset by fSpeed[A] towards fFace[A]
            move unitPlayerUnit[A] to pointMoveTo[A] and make unit face fFace[A]
            call RemoveLocation( pointMoveTo[A] )

of course theres a lot of other things u can do, when i did it for driving i added collision, slamming around, skidding and braking and stuff, but i figured i'd just write out the basics since i don't even have the editor with me at the moment

also u can use the order-move command with a slower periodical for real movement if desired
 
Level 3
Joined
Aug 18, 2004
Messages
60
o boy...

:shock: HOLY COW THATS ALOTA STUFF!!! Uh I might not be a newbe to the world editor but in this case I'm lost! It might be easyer if you just made a map with nothing in it but the trigger and let me download it. But anyway Thanx. I will try to figer it out and hopefully get it to work.
Here is my main quition: Were is the action and what is it called (befor anything is in it) that I need to use. Also does the kind of variable I use mater (I just asummed it was boolean)
Thanx
 
Level 7
Joined
Jul 30, 2004
Messages
451
Re: o boy...

Leinad said:
:shock: HOLY COW THATS ALOTA STUFF!!! Uh I might not be a newbe to the world editor but in this case I'm lost! It might be easyer if you just made a map with nothing in it but the trigger and let me download it. But anyway Thanx. I will try to figer it out and hopefully get it to work.
Here is my main quition: Were is the action and what is it called (befor anything is in it) that I need to use. Also does the kind of variable I use mater (I just asummed it was boolean)
Thanx

i can't make the map right now i'm on vacation and have no editor here (actually i just have a 133 mHz right now)
as for ur question i can't answer it you have to be more specific, there are a lot of different actions in there, if u mean the "For A = 0 to MaxPlayers" thats "For Loop Integer A" action
and yes the type of variable u use matters, booleans can only be true and false, while integers can be numbers, and reals can be numbers with decimals. the other ones are self explanatory by the name mostly. and everything i have there is in array notation since thats made for multiplayer purposes, though u could not use arrays if it was for only a single unit. i denote booleans starting with b, integers starting with n, and reals starting with f
 
Level 3
Joined
Aug 18, 2004
Messages
60
Luckly I think I am starting to understand what all of that stuff ment. I also figerd out one of the main thing I was doing wrong. I guess I will play arownd with this thing for awhile and see if I can figer it out completly. Thank you for helping me with this. I hope you enjoy your vacation.
 
Level 3
Joined
Aug 18, 2004
Messages
60
uhg

I still cant get this to work right...
All it is suposta do is go ford when you press up(by means of order unit to move to regin blah so there is no need for a acseleration thing),and turn left or right only while you are moveing ford. Simple and effective is what I am going for. I think the problem is somewere in this trigger:
Events-every .5 seconds of game time
actions-(move region) Center region on posestion of starfighter offcet by ffaceing,200. When I have it like this and I press up key and the ship moves to the x and y of the map not the x and y of itself.. From what I gatherd in your tigger, when the left or right key is pressed it adds a amount to the variable. I am guessing that unit faceing angle needs to be put in somewere with the variable ffaceing somehow. How do I do this? Thank you in advaced, if you need more information to help with this please just ask for it.
 
Status
Not open for further replies.
Top