コード例 #1
0
bool Tournament::collide_with_tile(TestType type, Player *p,
    int last_falling_y_pos, double x, double y, double *friction, bool *killing)
{
    tilex = static_cast<int>(x) / tile_width;
    tiley = static_cast<int>(y) / tile_height;

    if (tilex < 0 || tiley < 0) {
        return false;
    }

    if (tilex > map_width - 1 || tiley > map_height - 1) {
        return false;
    }

    int index = map_array[tiley][tilex];
    if (index > -1) {
        Tile *t = tileset->get_tile(index);
        if (friction) {
            *friction = t->get_friction();
        }
        return tile_collision(type, p, last_falling_y_pos, t, killing);
    }

    return false;
}
コード例 #2
0
void player_update(entity *self)
{
	Vec2d new_pos = {self->position.x + self->velocity.x, self->position.y + self->velocity.y};
	if(!tile_collision(new_pos, player->boundBox))
	{
		player->position = new_pos;
	}
	player->position = new_pos;
	player->velocity.x = 0;
	player->velocity.y = 0;

	if(animCurrent == WALK){ //if walking, dont reset animation
		//player->sprite->fpl = PlayerEquip.body->image->fpl;
		return;
	}
	//checks if animation played through at least once
	if(player->frame_horizontal >= player->sprite->fpl)
	{
		player->frame_horizontal = 0;
		animCurrent = WALK;
		player->sprite = playerBody.image;
		player->sprite->fpl = playerBody.image->fpl;
		player->weapon->active = false;
	}
	else{
		player->frame_horizontal += 1;
	}
}