You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
971 B

#include "player.h"
Player::Player(IMAGE* floor, Map* map) :Mover(floor, map)
{
score = 0;
move_status_max = 3;
ImportImage("image/Pacman.png");
}
int Player::TryEatBean()
{
int dx = (x % BLOCK_SIZE) - BLOCK_SIZE / 2;
int dy = (y % BLOCK_SIZE) - BLOCK_SIZE / 2;
if (abs(dx) < EAT_TOLERANCE && abs(dy) < EAT_TOLERANCE)
{
int bi = (x - dx - BLOCK_SIZE / 2) / BLOCK_SIZE;
int bj = (y - dy - BLOCK_SIZE / 2) / BLOCK_SIZE;
if (map->GetMap(bi, bj) ==1)
{
map->ClearBean(bi, bj);
score++;
DrawScore();
return 1;
}
else if (map->GetMap(bi, bj) == 2)
{
map->ClearBean(bi, bj);
score+=10;
DrawScore();
return 2;
}
}
return 0;
}
void Player::EatMonster()
{
score += 100;
DrawScore();
}
void Player::DrawScore()
{
string str;
str = "score: ";
str += num2str(score);
RECT r = { 0, GAME_HEIGHT, GAME_WIDTH, GAME_HEIGHT + SCORE_HEIGHT };
drawtext(_T(str2char(str)), &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}