leftKey = keyboard_check(ord("A"));
rightKey = keyboard_check(ord("D"));
xSpd = (rightKey - leftKey) * moveSpd;


function IsGrounded()
{
	var groundedBool = place_meeting(x, y + 1, oBubbleArray)
	return groundedBool;
}

if keyboard_check_pressed(vk_space)
{
	jumpKeyBufferTimer = bufferTime;
}
if jumpKeyBufferTimer > 0
{
	jumpKeyBuffered = true;
	jumpKeyBufferTimer--;
}
else
{
	jumpKeyBuffered = false;
}

if IsGrounded()
{
	sprite_index = sPlayer;
	groundedTimer = groundedTimerMax;
	if jumpKeyBuffered
	{
		sprite_index = sPlayerJump;
		ySpd = jumpSpd;
	}
}
else
{
	groundedTimer--;
	if groundedTimer < 0
	{
		room_goto(GameOverRoom);
	}
}

if ySpd < maxySpd
	{
		ySpd += grav;
	}

/*
if place_meeting(x + xSpd, y, oBubble)
	{
	var _pixelCheck = sign(xSpd);
	while !place_meeting(x + _pixelCheck, y, oBubble)
	{
		x += _pixelCheck
	}
	xSpd = 0
}

//y collision
if place_meeting(x + xSpd, y + ySpd, oBubble)
{
	var _pixelCheck = sign(ySpd)
	while !place_meeting(x + xSpd, y + _pixelCheck, oBubble)
	{
		y += _pixelCheck
	}
	ySpd = 0
}
*/

playerMaxY = int64(-((y - 320) / 100));

if playerMaxY > playerScore
{
	playerScore = playerMaxY;
}

x += xSpd;
y += ySpd;
