feat(laser): created laser object
Created laser object without any collision detection
This commit is contained in:
@@ -7,21 +7,44 @@ int main()
|
||||
window.setVerticalSyncEnabled(true);
|
||||
|
||||
Player player(window);
|
||||
Inputs inputs(window, player);
|
||||
vector<RectangleShape> lasers;
|
||||
|
||||
Inputs inputs(player, lasers);
|
||||
|
||||
while (window.isOpen())
|
||||
{
|
||||
Event event;
|
||||
while (window.pollEvent(event))
|
||||
{
|
||||
inputs.HandleInputs(event);
|
||||
|
||||
window.clear(Color::Black);
|
||||
|
||||
player.DrawPlayer();
|
||||
|
||||
window.display();
|
||||
if (event.type == sf::Event::Closed)
|
||||
{
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Handle user's inputs
|
||||
inputs.HandleInputs();
|
||||
|
||||
window.clear(Color::Black);
|
||||
|
||||
// Draw everything
|
||||
player.drawPlayer();
|
||||
|
||||
for (vector<RectangleShape>::iterator it = lasers.begin(); it < lasers.end();) {
|
||||
window.draw(*it);
|
||||
it->move(0, -5);
|
||||
|
||||
if (it->getPosition().y < -it->getScale().y) {
|
||||
it = lasers.erase(it);
|
||||
}
|
||||
else {
|
||||
lasers[distance(lasers.begin(), it)] = *it;
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
// Display window
|
||||
window.display();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user