Legacy GM diagonal moving like flyup

L

Lgmsfan

Guest
trying to achieve diagonal movement left right with mouse left.

Hi all i am trying to do diagonal movement with mouse left button
like in the android game called fly up but am not succeeding so i
ask for the wisdom of the GMC for help.

Thanks guys heres what i tried

//in create event
global.diagnal=2;//

//in step event
if (global.diagnal==2)&&mouse_check_button(mb_left){
script0()}
if (global.diagnal==1)&&mouse_check_button(mb_left){
script1()
global.diagnal=2;
}
/////////////////////////////////////////////////////////////////////////////////////////////

//in scrpts

//script0
y-=4;//go up if pressing global mouse left
x+=2;
global.diagnal=1;

//in scrpt1
y-=4;//go up if pressing global mouse left
x-=2;
global.diagnal=2

//in global mouse left button event
if (global.diagnal==2){
global.diagnal=1;}
else
if (global.diagnal==1){
global.diagnal=2;
}

//////////////////////////////////////////////////////
no doubt i have over complicated how to do this but i am at a loss
how to get diagonal movement like the game fly up

https://play.google.com/store/apps/details?id=com.codevl.flyup

so any help would be great thanks.
 
L

Lgmsfan

Guest
the game only sees script0 never script1 even if global.diagnal==1.
 
G

Guest User

Guest
i think you can just invert the direction every time you push the mouse button

Create Event
Code:
dir = 1; /* this is your fly direction */
Step Event
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

y -= 4;
x += 2 * dir;
if you want it to only move up while pushing the mouse then perhaps this could work:
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

if(mouse_check_button(mb_left)) {
y -= 4;
x += 2 * dir; }
but i'm actually not sure what happens when you mix two different check_buttons for the same button it might not work as i think it will so you will have to experiment maybe
 
L

Lgmsfan

Guest
i think you can just invert the direction every time you push the mouse button

Create Event
Code:
dir = 1; /* this is your fly direction */
Step Event
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

y -= 4;
x += 2 * dir;
if you want it to only move up while pushing the mouse then perhaps this could work:
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

if(mouse_check_button(mb_left)) {
y -= 4;
x += 2 * dir; }
but i'm actually not sure what happens when you mix two different check_buttons for the same button it might not work as i think it will so you will have to experiment maybe

thanks ill give it a try
 
L

Lgmsfan

Guest
i think you can just invert the direction every time you push the mouse button

Create Event
Code:
dir = 1; /* this is your fly direction */
Step Event
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

y -= 4;
x += 2 * dir;
if you want it to only move up while pushing the mouse then perhaps this could work:
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

if(mouse_check_button(mb_left)) {
y -= 4;
x += 2 * dir; }
but i'm actually not sure what happens when you mix two different check_buttons for the same button it might not work as i think it will so you will have to experiment maybe
Thanks for the help it seems to work Thanks again but yes player always keeps moving up even with second way yes ill have to keep testing with it. Thanks
 
L

Lgmsfan

Guest
i think you can just invert the direction every time you push the mouse button

Create Event
Code:
dir = 1; /* this is your fly direction */
Step Event
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

y -= 4;
x += 2 * dir;
if you want it to only move up while pushing the mouse then perhaps this could work:
Code:
if(mouse_check_button_pressed(mb_left)) {
dir = -dir; }

if(mouse_check_button(mb_left)) {
y -= 4;
x += 2 * dir; }
but i'm actually not sure what happens when you mix two different check_buttons for the same button it might not work as i think it will so you will have to experiment maybe
all good now thanks again for your help GMC has such helping people : )
 
Top