SombraCakes
Member
Hello,
I've had a basic understanding of how I want my game to run, but although I've seen videos on how grid movement works and how to do it, it isn't exactly what I've been looking for. I'm basically looking for Pokemon Mystery Dungeon- like movement, where the character can choose between the 8 different input options. I've gotten the four inputs as seen,
And these are the scripts, I do have basic understanding on what's going on, I'm just not very good at figuring this stuff on my own yet.
Thanks for the help!
I've had a basic understanding of how I want my game to run, but although I've seen videos on how grid movement works and how to do it, it isn't exactly what I've been looking for. I'm basically looking for Pokemon Mystery Dungeon- like movement, where the character can choose between the 8 different input options. I've gotten the four inputs as seen,
GML:
/// @description Move Control
//-----GET KEYS INPUT
keyRight = keyboard_check(ord("D"));
keyUp = keyboard_check(ord("W"));
keyLeft = keyboard_check(ord("A"));
keyDown = keyboard_check(ord("S"));
//-----DRAW DEPTH
depth = -y;
//-----SET CURRENT POSITION FOR X AND Y
posXCurrent = x;
posYCurrent = y;
//----------GET DIRECTION INPUT
moveX = keyRight - keyLeft;
moveY = keyDown - keyUp;
//-----ONE AXIS MOVEMENT CONTROL
if moveX != 0
{
moveY = 0;
}
else if moveY != 0
{
moveX = 0;
}
//------Diagonal Movement
//-----IF DIRECTION INPUT
if moveX != 0 or moveY != 0
{
//-----IF NOT YET MOVING
if moving == false
{
//----------DIRECTION CHANGE
scr_dirControl();
//----------START MOVEMENT
scr_setMoving();
}
}
//-----CHECK IF MOVE GOAL REACHED
if moving == true
{
scr_isMoving();
image_speed = .5;
}
else
{
image_speed = 0;
}
Code:
function scr_dirControl() {
//If keyRight is pressed down
if moveX == 1
{
//Change Direction to 0(Right)
dir = 0;
}
//If keyUp is pressed down
else if moveY == -1
{
//Change Direction to 90(Up)
dir = 90;
}
//If keyLeft is pressed down
else if moveX == -1
{
//Change Direction to 180(Left)
dir = 180;
}
//If keyDown is pressed down
else if moveY == 1
{
//Change Direction to 270(Down)
dir = 270;
}
Code:
function scr_isMoving() {
//If there is No 'object_solid' at Goal Position
if !place_meeting(posXGoal,posYGoal,oWall)
{
//If Goal is reached
if posXCurrent == posXGoal and posYCurrent == posYGoal
{
//Stop Movement
scr_stopMoving();
}
}
// If there is 'object_solid' at Goal Position
else
{
//Stop Movement
scr_stopMoving();
}
}
Code:
function scr_setMoving() {
//Prepare Variables for Moving
//-----Set Start Position (Start Position is Current Position)
posXStart = posXCurrent;
posYStart = posYCurrent;
//-----Set Goal Position (Goal Position is Current Position + Direction * Size of Step)
posXGoal = posXCurrent + (moveX * stepSize);
posYGoal = posYCurrent + (moveY * stepSize);
//Start Movement
motion_set(dir,spd);
//Can't Prepare Movement
setMove = false;
//Is now Moving
moving = true;
}
Code:
function scr_stopMoving() {
//Stop Movement
motion_set(dir,0);
//Is not Moving
moving = false;
}