예제 #1
0
void Area::Render(sf::RenderTarget& target) {
	if (Game::Get()->GetSettings()->DebugHitboxes()) {
		for (unsigned int i = 0; i < GetHitboxCounter(); i++) {
			target.draw(GetHitbox(i));
			const sf::VertexArray& hbox = GetHitbox(i);
			if (hbox.getVertexCount() > 2) {
				sf::Vertex arr[] = {hbox[hbox.getVertexCount()-1],
									hbox[0]};
				target.draw(arr, 2, sf::PrimitiveType::Lines);
			}
		}
	}
}
예제 #2
0
bool Entity::CollidesWithTiles(vector3 velocity) {
	SDL_Rect box = GetHitbox();
	
	int nextX, nextY = 0;    
	if(velocity.x < 0) {
		nextX = floor(box.x + velocity.x);
	} else {
		nextX = ceil(box.x + velocity.x);
	}

	if(velocity.y < 0) {
		nextY = floor(box.y + velocity.y - 96);
	} else {
		nextY = ceil(box.y + velocity.y - 96);
	}

	box.x = nextX;
	box.y = nextY;

	Room* room = ((GameScene*)Scene)->CurrentLevel->CurrentRoom();
	for(int x = 0; x < room->TileCountX; x++) {
		for(int y = 0; y < room->TileCountY; y++) {
			if(room->Map[x][y]->Blocks) {
				SDL_Rect inter;
				if(Helper::SDL_IntersectRect(&box, &room->Map[x][y]->GetHitbox(), &inter)) {
					return true;
				}
			}
		}
	}

	return false;    
}
예제 #3
0
void CMovingPlatform::Move(CVector2f offset)
{
    GetHitbox().move(offset);
    
    if (mAttachedPlayer != NULL)
    {
        mAttachedPlayer->Move(offset);
    }
}
예제 #4
0
void Entity::Draw(Surface* surface, float deltaTime) {
	if(CurrentAnimation != 0) {
		CurrentAnimation->Update(deltaTime);
		Graphic = CurrentAnimation->GetCurrentSurface();
	}

	if(!Hidden && Graphic != 0) {
		Graphic->AlphaCopyTo(surface, Position.x + DrawOffset.x, Position.y + DrawOffset.y);
	}

	if(DrawHitbox && strcmp(Type, "") != 0) {
		SDL_Rect box = GetHitbox();
		surface->Box(box.x, box.y, box.x + box.w, box.y + box.h, 0xFF0000);
	}
}
void EnemyBulletObject::SetAllPositions(sf::Vector2f p_vPosition){
	setPosition(p_vPosition);
	m_xpSprite->SetPosition(getPosition());
	GetHitbox()->SetPosition(getPosition());
}