L
Lonster31185
Guest
Alright, so being a dumb dumb, and not really having alll the much experience programming in general....I have a question. I have attempted to find an answer, but the closest I could find was related to using your mouse and moving in that direction...although I may have missed something....
In GM2s help file, looking up switch you easily find how to use a switch statement? to use both arrow keys and WASD for movement. I want something more similar to tank controls, but more movement on a grid, like if you were exploring a first person dungeon crawler (games like Arcana, Eye of the Beholder, Legend of Grimrock 1+2, etc).
So I got the idea from the mouse and most other tutorials to set
image_angle = direction;
and then me in my, this sounds like a good idea! BUT I am not sure what I am doing decides to edit the switch statement to do.... (Bolded what I changed)
{
switch (keyboard_key)
{
case vk_left:
case ord("A"):
direction += 90;
break;
case vk_right:
case ord("D"):
direction -= 90;
break;
case vk_up:
case ord("W"):
y -= 4;
break;
case vk_down:
case ord("S"):
direction += 180;
break;
}}
...basically changing the direction of the image_angle to rotate? 90 degrees...now. So the obj_player would rotate left and right, and if you press down or s, you would rotate and look backwards the direction you were coming from. I now have two questions.
1. I have a horrible feeling its obviously not rotating in the 0-359 degree circle, and that adding 90 and 180 would be moving past that number range. Should I be worried about this. My first thoughts are YES, but I still don't know what I am doing exactly. (Guess I was wrong, it is staying in range. Using draw_text(x, y+256, direction); I threw the text on the screen of direction and it does remain in the 360 degrees >.<;; )
2. What would be the easy way of making W or the Up arrow move the obj_player in the current direction it is facing say 16 or 32 pixels in a grid? And SHOULD I be doing this another way?
In GM2s help file, looking up switch you easily find how to use a switch statement? to use both arrow keys and WASD for movement. I want something more similar to tank controls, but more movement on a grid, like if you were exploring a first person dungeon crawler (games like Arcana, Eye of the Beholder, Legend of Grimrock 1+2, etc).
So I got the idea from the mouse and most other tutorials to set
image_angle = direction;
and then me in my, this sounds like a good idea! BUT I am not sure what I am doing decides to edit the switch statement to do.... (Bolded what I changed)
{
switch (keyboard_key)
{
case vk_left:
case ord("A"):
direction += 90;
break;
case vk_right:
case ord("D"):
direction -= 90;
break;
case vk_up:
case ord("W"):
y -= 4;
break;
case vk_down:
case ord("S"):
direction += 180;
break;
}}
...basically changing the direction of the image_angle to rotate? 90 degrees...now. So the obj_player would rotate left and right, and if you press down or s, you would rotate and look backwards the direction you were coming from. I now have two questions.
2. What would be the easy way of making W or the Up arrow move the obj_player in the current direction it is facing say 16 or 32 pixels in a grid? And SHOULD I be doing this another way?
Last edited by a moderator: