#include "cGamePlayer.h"

cGamePlayer::cGamePlayer(){
	bJumping = FALSE;
	dx = dy = 0;
}

cGamePlayer::~cGamePlayer(){

}

int cGamePlayer::Act(){
	if(bJumping){
		x += dx;
		y += dy;
		dy += 4;
		PicNo = 7;
		if(y > 400){
			y = 400;
			bJumping = FALSE;
			PicNo = 0;
		}
	}
	KeyboardControl();
	return ARV_NORMAL;
}

void cGamePlayer::KeyboardControl(){
	BOOL bLeft = GetAsyncKeyState(VK_LEFT) < 0,
		bRight = GetAsyncKeyState(VK_RIGHT) < 0,
		bUp = GetAsyncKeyState(VK_UP) < 0;

	if(bUp && !bJumping){ // Jump
		bJumping = TRUE;
		dx = 0;
		if(bLeft) dx -= 8;
		if(bRight) dx += 8;
		dy = -32;
	}

	if(bLeft) x -= 8;
	if(bRight) x += 8;
}
