A
AtomicBlade
Guest
As the title suggests, my player character can't shoot if you hold space and move sideways in the air. They also can't move sideways if space is held while shooting in the air as well as being unable to jump if they are moving sideways and shooting. It's very odd and I can't find any code that directly relates them all together. Here's the step (involved in movement and jumping) and begin step (involved with shooting) events. I'm sorry if it's too much, but I really don't know what is effecting each other.
Step event:
//Get_Player Input
if (hascontrol = true)
{
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
//key_jump = keyboard_check_pressed(vk_space) || keyboard_check_pressed(ord("W"));
}
else
{
key_right = 0;
key_left = 0;
key_jump = 0;
}
key_jump = keyboard_check_pressed(vk_space)
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
//Jumping
if (canjump > 0) && (key_jump)
{
vsp = -11;
canjump = 0;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,oWall)) || (place_meeting(x,y+vsp,oPlatform))
{
while (!place_meeting(x,y+sign(vsp),oWall)) && (!place_meeting(x,y+sign(vsp),oPlatform))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
// Weapon Use
if (keyboard_check(ord("E"))) && (GunSwitchTimeout = 0) {
WeaponOut = !WeaponOut;
GunSwitchTimeout = 10;
}
if (GunSwitchTimeout > 0) GunSwitchTimeout -= 1;
//Animation
if (!place_meeting(x,y+1,oWall)) && (!place_meeting(x,y+1,oPlatform))
{
if (WeaponOut = false) sprite_index = sSwatPFalling;
else if (WeaponOut) sprite_index = sSwatPFallingGun;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
canjump = canjump - 1;
}
else
{
canjump = 10;
image_speed = 1;
if (hsp == 0)
{
if (WeaponOut = false) sprite_index = sSwatP;
else if (WeaponOut) sprite_index = sSwatPGun;
}
else
{
if (WeaponOut = false) sprite_index = sSwatPWalk;
else if (WeaponOut) sprite_index = sSwatPWalkGun;
}
}
if (hsp != 0) image_xscale = sign(hsp);
with (oPlatform)
{
if (round(other.y + ((other.sprite_height/2)-16)) > y || keyboard_check_pressed(vk_down)) || keyboard_check_pressed(ord("S"))
{
mask_index = -1;
}
else
{
mask_index = sPlatform;
}
}
// Invinsiblity Frames
if (iFrames > 0) iFrames -= 1;
//Health System
if (!instance_exists(oHeart3)) && (hp = 3) {
instance_create_depth(x+25,y-40,0,oHeart3);
with (oHeart3) {
sprite_index = sHeartHeal;
image_speed = 1;
image_index = 0;
}
}
if (!instance_exists(oHeart2)) && (hp >= 2) {
instance_create_depth(x-25,y-40,0,oHeart2);
with (oHeart2) {
sprite_index = sHeartHeal;
image_speed = 1;
image_index = 0;
}
}
if (keyboard_check(ord("H"))) hp = 3;
//Directional Shooting
if (keyboard_check(ord("A"))) {dir_left = true}
else dir_left = false;
if (keyboard_check(ord("D"))) {dir_right = true}
else dir_right = false;
if (keyboard_check(ord("W"))) {dir_up = true}
else dir_up = false;
if (keyboard_check(ord("S"))) {dir_down = true}
else dir_down = false;
if (dir_left) {
image_xscale = -1;
bullet_facing = 180;
}
if (dir_right) {
image_xscale = 1;
bullet_facing = 0;
}
if (dir_up) {
bullet_facing = 90;
}
if (dir_down) {
bullet_facing = 270;
}
if (dir_up) && (dir_right) {
image_xscale = 1;
bullet_facing = 45;
}
if (dir_up) && (dir_left) {
image_xscale = -1;
bullet_facing = 135;
}
if (dir_down) && (dir_right) {
image_xscale = 1;
bullet_facing = 315;
}
if (dir_down) && (dir_left) {
image_xscale = -1;
bullet_facing = 225;
}
if(keyboard_check(vk_shift)) {
hascontrol = false;
}else hascontrol = true;
Begin Step Event:
if (WeaponOut) {
if (keyboard_check(vk_enter)) && (firingdelay = 0)
{
firingdelay = 10;
screenShake(2,25);
repeat(bullets) with(instance_create_layer(x,y-15,"Instances",oSpunk))
{
spd = 25;
direction = other.bullet_facing + random_range(-3*other.bullets,3*other.bullets);
image_angle = direction;
}
}
}
if (specialdelay > 0) specialdelay = specialdelay - 1;
// Special Use
if (WeaponOut = false) {
if (keyboard_check(ord("Q"))) && (specialdelay = 0)
{
specialdelay = fps*60;
screenShake(2,25);
repeat(specialBullets) with(instance_create_layer(x,y-15,"Instances",oSpecialSpunk))
{
spd = 25;
direction = other.bullet_facing + random_range(-3*other.specialBullets,3*other.specialBullets);
image_angle = direction;
}
}
}
Step event:
//Get_Player Input
if (hascontrol = true)
{
key_left = keyboard_check(vk_left) || keyboard_check(ord("A"));
key_right = keyboard_check(vk_right) || keyboard_check(ord("D"));
//key_jump = keyboard_check_pressed(vk_space) || keyboard_check_pressed(ord("W"));
}
else
{
key_right = 0;
key_left = 0;
key_jump = 0;
}
key_jump = keyboard_check_pressed(vk_space)
//Calculate Movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
//Jumping
if (canjump > 0) && (key_jump)
{
vsp = -11;
canjump = 0;
}
//Horizontal Collision
if (place_meeting(x+hsp,y,oWall))
{
while (!place_meeting(x+sign(hsp),y,oWall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//Vertical Collision
if (place_meeting(x,y+vsp,oWall)) || (place_meeting(x,y+vsp,oPlatform))
{
while (!place_meeting(x,y+sign(vsp),oWall)) && (!place_meeting(x,y+sign(vsp),oPlatform))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
// Weapon Use
if (keyboard_check(ord("E"))) && (GunSwitchTimeout = 0) {
WeaponOut = !WeaponOut;
GunSwitchTimeout = 10;
}
if (GunSwitchTimeout > 0) GunSwitchTimeout -= 1;
//Animation
if (!place_meeting(x,y+1,oWall)) && (!place_meeting(x,y+1,oPlatform))
{
if (WeaponOut = false) sprite_index = sSwatPFalling;
else if (WeaponOut) sprite_index = sSwatPFallingGun;
image_speed = 0;
if (sign(vsp) > 0) image_index = 1; else image_index = 0;
canjump = canjump - 1;
}
else
{
canjump = 10;
image_speed = 1;
if (hsp == 0)
{
if (WeaponOut = false) sprite_index = sSwatP;
else if (WeaponOut) sprite_index = sSwatPGun;
}
else
{
if (WeaponOut = false) sprite_index = sSwatPWalk;
else if (WeaponOut) sprite_index = sSwatPWalkGun;
}
}
if (hsp != 0) image_xscale = sign(hsp);
with (oPlatform)
{
if (round(other.y + ((other.sprite_height/2)-16)) > y || keyboard_check_pressed(vk_down)) || keyboard_check_pressed(ord("S"))
{
mask_index = -1;
}
else
{
mask_index = sPlatform;
}
}
// Invinsiblity Frames
if (iFrames > 0) iFrames -= 1;
//Health System
if (!instance_exists(oHeart3)) && (hp = 3) {
instance_create_depth(x+25,y-40,0,oHeart3);
with (oHeart3) {
sprite_index = sHeartHeal;
image_speed = 1;
image_index = 0;
}
}
if (!instance_exists(oHeart2)) && (hp >= 2) {
instance_create_depth(x-25,y-40,0,oHeart2);
with (oHeart2) {
sprite_index = sHeartHeal;
image_speed = 1;
image_index = 0;
}
}
if (keyboard_check(ord("H"))) hp = 3;
//Directional Shooting
if (keyboard_check(ord("A"))) {dir_left = true}
else dir_left = false;
if (keyboard_check(ord("D"))) {dir_right = true}
else dir_right = false;
if (keyboard_check(ord("W"))) {dir_up = true}
else dir_up = false;
if (keyboard_check(ord("S"))) {dir_down = true}
else dir_down = false;
if (dir_left) {
image_xscale = -1;
bullet_facing = 180;
}
if (dir_right) {
image_xscale = 1;
bullet_facing = 0;
}
if (dir_up) {
bullet_facing = 90;
}
if (dir_down) {
bullet_facing = 270;
}
if (dir_up) && (dir_right) {
image_xscale = 1;
bullet_facing = 45;
}
if (dir_up) && (dir_left) {
image_xscale = -1;
bullet_facing = 135;
}
if (dir_down) && (dir_right) {
image_xscale = 1;
bullet_facing = 315;
}
if (dir_down) && (dir_left) {
image_xscale = -1;
bullet_facing = 225;
}
if(keyboard_check(vk_shift)) {
hascontrol = false;
}else hascontrol = true;
Begin Step Event:
if (WeaponOut) {
if (keyboard_check(vk_enter)) && (firingdelay = 0)
{
firingdelay = 10;
screenShake(2,25);
repeat(bullets) with(instance_create_layer(x,y-15,"Instances",oSpunk))
{
spd = 25;
direction = other.bullet_facing + random_range(-3*other.bullets,3*other.bullets);
image_angle = direction;
}
}
}
if (specialdelay > 0) specialdelay = specialdelay - 1;
// Special Use
if (WeaponOut = false) {
if (keyboard_check(ord("Q"))) && (specialdelay = 0)
{
specialdelay = fps*60;
screenShake(2,25);
repeat(specialBullets) with(instance_create_layer(x,y-15,"Instances",oSpecialSpunk))
{
spd = 25;
direction = other.bullet_facing + random_range(-3*other.specialBullets,3*other.specialBullets);
image_angle = direction;
}
}
}