Architheutis
Member
Hi Folks,
I`m an interested beginner in programming and using GMS2. I´ve already seen different
YT-Tutorials, f.e. making a Jump`N`Run game. I can follow all codes and steps. But I
hang up on a simple weapon behaviour. Maybe there is somebody can gimme a hint!?
I have a fully functional character with eight dirs over keyboard_check(vk_X).
But I don´t wanna use mouse (point_direction) for aiming with my weapon.
I just wanna use oGun and oBullet (each in a seperate layer, devided from oPlayer),
but following the oPlayer (x = oPlayer.x; and y = oPlayer.y. Now I just want to aim
and shot to the right, when oPlayer is looking right by last keypress). And aiming
and shooting to the left, when oPlayer is looking to the left by last keypress).
(Have a look down for the concerning code)
Hope I could explain my problem, well!?
Thankful for each hint.
Best wishes,
Architeuthis
Current code:
/// @desc Gun-Behaviour
x = oPlayer.x;
y = oPlayer.y;
if (keyboard_check(vk_left))
{
image_xscale = -1;
}
if (keyboard_check(vk_right))
{
image_xscale = 1;
}
firingdelay = firingdelay -1;
recoil = max(0,recoil - 1);
if (keyboard_check(vk_up)) && (firingdelay < 0)
{
recoil = 2;
firingdelay = 5;
with (instance_create_layer(x,y,"Drop",oDrop))
{
speed = 30;
direction = other.image_angle + random_range (-4,4);
}
}
I`m an interested beginner in programming and using GMS2. I´ve already seen different
YT-Tutorials, f.e. making a Jump`N`Run game. I can follow all codes and steps. But I
hang up on a simple weapon behaviour. Maybe there is somebody can gimme a hint!?
I have a fully functional character with eight dirs over keyboard_check(vk_X).
But I don´t wanna use mouse (point_direction) for aiming with my weapon.
I just wanna use oGun and oBullet (each in a seperate layer, devided from oPlayer),
but following the oPlayer (x = oPlayer.x; and y = oPlayer.y. Now I just want to aim
and shot to the right, when oPlayer is looking right by last keypress). And aiming
and shooting to the left, when oPlayer is looking to the left by last keypress).
(Have a look down for the concerning code)
Hope I could explain my problem, well!?
Thankful for each hint.
Best wishes,
Architeuthis
Current code:
/// @desc Gun-Behaviour
x = oPlayer.x;
y = oPlayer.y;
if (keyboard_check(vk_left))
{
image_xscale = -1;
}
if (keyboard_check(vk_right))
{
image_xscale = 1;
}
firingdelay = firingdelay -1;
recoil = max(0,recoil - 1);
if (keyboard_check(vk_up)) && (firingdelay < 0)
{
recoil = 2;
firingdelay = 5;
with (instance_create_layer(x,y,"Drop",oDrop))
{
speed = 30;
direction = other.image_angle + random_range (-4,4);
}
}
Last edited: