CODE
//player movement
if keyboard_check (68) direction -=1.5
if keyboard_check (65) direction +=1.5
{
if keyboard_check (87)
{
x += lengthdir_x(2, direction)
y += lengthdir_y(2, direction)
}
if keyboard_check (83)
{
x += lengthdir_x(1.5, direction + 180)
y += lengthdir_y(1.5, direction + 180)
}
if keyboard_check (69)
{
x += lengthdir_x(1.5, direction-90)
y += lengthdir_y(1.5, direction-90)
}
if keyboard_check (81)
{
x += lengthdir_x(1.5, direction+90)
y += lengthdir_y(1.5, direction+90)
}
}
//shooting
if weapon = 1
{
if keyboard_check_pressed(74) and pistol_timer = 0
{
instance_create(x, y, obj_bullet_pistol)
pistol_timer = 20
}
}
if weapon = 2
{
if keyboard_check(74) and mg_timer = 0
{
instance_create(x, y, obj_bullet_mg)
mg_timer = 6
}
}
//weapon timers
if pistol_timer > 0
{
pistol_timer -= 1
}
if mg_timer > 0
{
mg_timer -= 1
}
//weapon switching
if keyboard_check_pressed(90)
{
weapon += 1
}
if weapon = 3
{
weapon = 1
}
if keyboard_check (68) direction -=1.5
if keyboard_check (65) direction +=1.5
{
if keyboard_check (87)
{
x += lengthdir_x(2, direction)
y += lengthdir_y(2, direction)
}
if keyboard_check (83)
{
x += lengthdir_x(1.5, direction + 180)
y += lengthdir_y(1.5, direction + 180)
}
if keyboard_check (69)
{
x += lengthdir_x(1.5, direction-90)
y += lengthdir_y(1.5, direction-90)
}
if keyboard_check (81)
{
x += lengthdir_x(1.5, direction+90)
y += lengthdir_y(1.5, direction+90)
}
}
//shooting
if weapon = 1
{
if keyboard_check_pressed(74) and pistol_timer = 0
{
instance_create(x, y, obj_bullet_pistol)
pistol_timer = 20
}
}
if weapon = 2
{
if keyboard_check(74) and mg_timer = 0
{
instance_create(x, y, obj_bullet_mg)
mg_timer = 6
}
}
//weapon timers
if pistol_timer > 0
{
pistol_timer -= 1
}
if mg_timer > 0
{
mg_timer -= 1
}
//weapon switching
if keyboard_check_pressed(90)
{
weapon += 1
}
if weapon = 3
{
weapon = 1
}
Also, I did not implement wall objects, and I never used vectors before, so if collision detection is going to be an issue, or anyone has a better idea for the movement system, I'm open to suggestions.
