Ok so I have been working on a game for a little and I get the cords and direction easy enough from memory, now to using those directions.
The way I see it I have 2 options to go with.
First is very similar to RoM in the way that you have 2 values and use the 2 values to work out which way you are pointing.
-1 0 North
0 1 West
1 0 South
0 -1 East
Second is another value which means direction which is very different for values but works in a similar way.
N -6627
W -6483
S 6627
E 6483
Values may be very slightly out as I am just looking at CE as I turn, the max values are -9270 which is NW and 9270 for SE with 0 for both NE and SW
There is another value which is very similar with 0 for NW and SE, SW 9270, NE -9270
So as far as calculations for direction goes which is easiest or best to use?
player direction
player direction
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Re: player direction
I used a few game editors those numbers you are showing in ce look like they are from unreal.
here is a article that talks about some of the ways. http://www.aclockworkberry.com/world-co ... al-engine/
here is a article that talks about some of the ways. http://www.aclockworkberry.com/world-co ... al-engine/
- Administrator
- Site Admin
- Posts: 5313
- Joined: Sat Jan 05, 2008 4:21 pm
Re: player direction
I think I would probably go with the first option, as it seems to represent a unit vector more easily, which you can then convert to an angle (in radians) using sine & cosine, as we did in RoM.
Re: player direction
copy pasted a bit of code from RoM and turning ended up like this.
Initial testing it is working pretty good, I'll tidy it up and add keys to my variables and such but it should do the job =)
No issues with calling virtualHold constantly, at the moment it's not checking if already held and so just keeps doing hold over and over again or should I add in checks for if held before doing Hold again ?
Code: Select all
playerupdate()
local angle = 0 --north
local angleDif = angleDifference(angle, playerdirection);
-- If more than X degrees off, correct before moving.
local rotateStartTime = os.time();
local turningDir = -1; -- 0 = left, 1 = right
if( angleDif > math.rad(5) ) then
if( os.difftime(os.time(), rotateStartTime) > 3.0 ) then
-- Sometimes both left and right rotate get stuck down.
-- Press them both to make sure they are fully released.
keyboard.virtualRelease(win,key.VK_Q);
keyboard.virtualRelease(win,key.VK_E);
rotateStartTime = os.time();
end
if( angleDifference(angle, playerdirection + 0.01) < angleDif ) then
-- rotate left
keyboard.virtualRelease( win,key.VK_E );
keyboard.virtualHold( win,key.VK_Q );
else
-- rotate right
keyboard.virtualRelease(win,key.VK_Q);
keyboard.virtualHold( win,key.VK_E );
end
else
keyboard.virtualRelease(win,key.VK_Q);
keyboard.virtualRelease(win,key.VK_E);
end
No issues with calling virtualHold constantly, at the moment it's not checking if already held and so just keeps doing hold over and over again or should I add in checks for if held before doing Hold again ?
Remember no matter you do in life to always have a little fun while you are at it
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
wiki here http://www.solarstrike.net/wiki/index.php?title=Manual
Who is online
Users browsing this forum: No registered users and 0 guests