예제 #1
0
파일: Player.cpp 프로젝트: mmilewski/magame
void Player::Draw() const {
    // wypisz informację o liczbie punktów zdobytych przez gracza
    Text scores_text;
    scores_text.SetSize(0.05, 0.05);
    scores_text.DrawText("Punkty " + IntToStr(GetScores()), .01, .9);
    scores_text.DrawText("Zycia " + IntToStr(GetLifesCount()), .65, .9);

    // jeżeli bohater jest nieśmiertelny, to miga (rysuj - nie rysuj)
    if (IsImmortal() && int(m_immortal_duration * 10) % 2 == 1) {
        return;
    }

    // pobierz szerokość i wysokość kafla na ekranie
    RendererPtr renderer = Engine::Get().GetRenderer();
    const double tile_width = renderer->GetTileWidth();
    const double tile_height = renderer->GetTileHeight();

    // wylicz pozycję gracza na ekranie
    const double pos_x = m_x * tile_width;
    const double pos_y = m_y * tile_height;

    switch (m_state) {
    case PS::Stand:
        m_stop->DrawCurrentFrame(pos_x, pos_y, tile_width, tile_height);
        break;
    case PS::GoLeft:
        m_left->DrawCurrentFrame(pos_x, pos_y, tile_width, tile_height);
        break;
    case PS::GoRight:
        m_right->DrawCurrentFrame(pos_x, pos_y, tile_width, tile_height);
        break;
    case PS::TurnLeft:
        m_left->SetCurrentFrame(0);
        m_left->DrawCurrentFrame(pos_x, pos_y, tile_width, tile_height);
        break;
    case PS::TurnRight:
        m_right->SetCurrentFrame(0);
        m_right->DrawCurrentFrame(pos_x, pos_y, tile_width, tile_height);
        break;
    }
}
예제 #2
0
bool Game_Battler::IsDead() const {
	return !IsHidden() && GetHp() == 0 && !IsImmortal();
}
예제 #3
0
파일: command.c 프로젝트: borlak/acmud
///////////////
// FUNCTIONS //
///////////////
void interpret(CREATURE *crit, char *buf)
{
	CREATURE *xcrit=0;
	OBJECT *obj=0;
	SOCIAL *social=0;
	EXIT *exit=0;
	ROOM *room=0;
	char command[MAX_BUFFER];
	char temp[MAX_BUFFER];
	char *pbuf = command;
	char **arguments;
	char **editargs;
	long i = 0, x = 0;
	long string = 0;
	bool found = 0;
	bool command_ok = 0;
	bool social_ok = 0;

	strcpy(temp,buf);

	while( isspace(*buf) )
		buf++;

	// check for one character commands without spaces to 
	// seperate arguments. - i.e. chat yo = .yo | pip
	if(ispunct(*buf))
		*pbuf++ = *buf++;
	else
	{
		while( !isspace(*buf) && *buf != '\0' )
			*pbuf++ = *buf++;
	}
	*pbuf = '\0';

	while( isspace(*buf) )
		buf++;

	// moved exits before other commands - pip.
	// insert full exit name for abbreviated one.
	for( i = 0; directions[i].abbr; i++)
	{
		if (directions[i].abbr[0] != '\0' && !strcasecmp(command,directions[i].abbr))
		{
			sprintf(command,"%s",directions[i].name);
			break;
		}
	}

	if(!IsDisabled(crit))
	{
		for(exit = crit->in_room->exits; exit; exit = exit->next )
		{
			if( !strindex(exit->name, command) )
			{
				if((room = hashfind_room(exit->to_vnum)) == 0)
				{
					sendcrit(crit,"That exit enters into a domain far too powerful for you to handle.");
					mudlog("exit(%s) in room(%s:%d) has bad to_vnum(%d)!",
						exit->name, crit->in_room->name, crit->in_room->vnum,
						exit->to_vnum);
					continue;
				}

				if (exit->door >= DOOR_CLOSED && !IsImmortal(crit))
				{
					sendcritf(crit,"The %s door is closed.",exit->name);
					return;
				}
				if (crit->rider)
				{
					sendcritf(crit,"You can't move on your own until %s dismounts you.",crit->rider->name);
					return;
				}
				// adding mounts!
				if (crit->mount)
					message("$n ride$x $p on $N.",crit,crit->mount,exit->name);
				else					
					message("$n leave$x $p.",crit,0,exit->name);
				trans(crit,room);
				if (crit->mount)
				{
					trans(crit->mount,crit);
					message("$n arrive$x riding $N.",crit,crit->mount,crit->in_room);
				}
				message("$n $v arrived.",crit,crit->in_room,0);
				interpret(crit,"look");
				return;
			}
		}
	}

	// check if they in editor and get a successful return (edited something)
	// otherwise let them use normal commands
	if(IsEditing(crit))
	{
		if(crit->socket->string)
		{
			if(!(string = string_editor(crit,temp)))
				return;
			
			str_dup(&(*crit->socket->variable), crit->socket->string);
			DeleteObject(crit->socket->string)
			return;
		}
		else
			temp[0] = '\0';

		if(!ValidString(command))
			strcat(temp,"");
		else
			sprintf(temp,"%s %s",command,buf);

		editargs = make_arguments(temp);
		if(editor(crit,editargs))
		{
			free_arguments(editargs);
			return;
		}
		free_arguments(editargs);
	}