ID:1480687
 
(See the best response by Kaiochao.)
This sets their direction when they press Z or X to rotate.
mob/player/var
currentDegree = 0
turning = 0

mob/player/verb
Rotate_Tank_Right()
if(!turning)
turning = 1
var/icon/I = 'Tank.dmi'
currentDegree += 5
if(currentDegree>=360)
currentDegree = 0
src.icon = turn(I, currentDegree)
sleep(1)
turning = 0


This is what moves them in the direction they're facing:
mob/player/Move()
if(canmove)
canmove = 0
if(src.class == "Tank") // Move them in the direction of their "currentDegree"
step(src, currentDegree, 0)
world << "Debug: Player moved"
sleep(1)
canmove = 1


Obviously I'm doing something wrong and I feel like a noob right now. I've tried multiple methods with step() and other procs. None seem to make them move. Perhaps I need ..()? Or wouldn't that just make them move normally?
You should be overriding client/Move to call mob.Move, or providing different arguments to the ..() call.
mob/player/Move()
if(canmove)
canmove = 0
if(src.class == "Tank") // Move them in the direction of their "currentDegree"
..(get_step(src, NORTH),NORTH)
sleep(1)
canmove = 1


When I set it to NORTH, they move properly. However, the tank should move in the direction it's rotated. How would I go about make it move in that direction in terms of pixel movement?
In response to Xirre
A step to the north is a translation of (0, step_size) pixels. You pass pixel movements as a change in step_x and/or step_y in ..().
Also, this is unrelated to the issue, but you really should use atom.transform to rotate the icon instead of icon.Turn().
Thanks for the atom.transform tip:
mob/var
currentDegree = 0
turning = 0

mob/verb
Rotate_Tank_Right()
if(!turning)
turning = 1
currentDegree += 5
if(currentDegree>=360)
currentDegree = 0
var/matrix/M = matrix()
M.Turn(currentDegree)
src.transform = M
sleep(1)
turning = 0

Rotate_Tank_Left()
if(!turning)
turning = 1
currentDegree -= 5
if(currentDegree<=0)
currentDegree = 360
var/matrix/M = matrix()
M.Turn(currentDegree)
src.transform = M
sleep(1)
turning = 0

It makes the turning look much more smooth and doesn't distort the pixels as much.

That's what I have so far. However, I read up on step_x/y again and it says that it represents the atoms position in relation to its tile. This wouldn't have a conflict with any projectiles that come its way? i.e. Pixel collision or something along the lines of that.

Additionally,
world
mob = /mob/player
fps = 60
view = 7
icon_size = 32

mob
step_size = 10
var
canmove = 1

obj
step_size = 1

mob/player/Move()
if(canmove)
canmove = 0
if(src.class == "Tank") // Move them in the direction of their "currentDegree"
..(get_step(src, currentDegree),currentDegree)
sleep(1)
canmove = 1

I'm unsure as to how I'd go about creation an algorithm that would also pass the correct step_y and step_x values in terms of a degree. Seems highly complicated to me. Or maybe I'm just over-complicating things.
In response to Xirre
Best response
It's actually pretty basic trigonometry to convert from polar coordinates (radius, angle) to rectangular coordinates (x, y).

It also depends on what kind of angles you're using.
If NORTH is 0 degrees and EAST is 90 degrees, you convert using (x, y) = (radius * sin(angle), radius * cos(angle)).
Or if EAST is 0 degrees and NORTH is 90 degrees, you swap the sin and cos.

Here's a link to my pixel movement helper library. It includes a proc, Project(), to move a movable atom by a certain distance and angle.
http://www.byond.com/developer/kaiochao/absolutepositions
Another thing not related to the issue, you're losing a lot of the smoothness you could be having at 60 frames per second by freezing actions by 1/10th of a second instead of allowing things to happen every frame.

Simply decrease your step_size, decrease your turn rate, and decrease your sleep delay to world.tick_lag.
In response to Kaiochao
Kaiochao wrote:
Another thing not related to the issue, you're losing a lot of the smoothness you could be having at 60 frames per second by freezing actions by 1/10th of a second instead of allowing things to happen every frame.

Simply decrease your step_size, decrease your turn rate, and decrease your sleep delay to world.tick_lag.

Yeah, sorry. Where you see obj step_size = 1, it was suppose to be mob step_size = 1. I added a 0 to the 1 to make it 10 because I was testing to see if the step_size was too small to be noticed as a difference since the code wasn't working at all. I forgot to change them both back. Thanks for the heads up though.
Well, I got it to work with your library. However, it seems a bit jittery.
mob/player/verb/Movement()
if(canmove)
canmove = 0
if(src.class == "Tank") // Move them in the direction of their "currentDegree"
src.Project(5,currentDegree)
sleep(1)
canmove = 1

What I did was that I just made a verb and used a macro that repeats over to allow the Movement verb to be ran multiple times. However, I can see that being an issue with multiple people down the road, being ran so much that is. The issue at hand is that it moves 1 pixel up/down then 1 pixel to the right/left and when at a certain angle it moves about 4 pixels in the directs its actually facing then 1 up or down (or left/right, depending on the angle).

It looks like it'll need some changing, but this does the trick.