Browse Source

add player class (rendering triangle)

master
sauer2 2 years ago
parent
commit
5f0aff3eb6
5 changed files with 36 additions and 4 deletions
  1. +1
    -1
      Makefile
  2. +3
    -1
      game.cpp
  3. +3
    -2
      game.hpp
  4. +12
    -0
      player.cpp
  5. +17
    -0
      player.hpp

+ 1
- 1
Makefile View File

@@ -8,7 +8,7 @@ LDFLAGS = -L "SFML21/lib" -lsfml-system -lsfml-window -lsfml-graphics
# for Windows using MinGW
#LDFLAGS = -L "SFML21/lib" -lmingw32 -lsfml-main -lsfml-system -lsfml-window -lsfml-graphics

OBJ = game.o background.o mainmenu.o main.o
OBJ = game.o player.o background.o mainmenu.o main.o

game: $(OBJ)
$(CC) $(CFLAGS) -o game.bin $(OBJ) $(LDFLAGS)

+ 3
- 1
game.cpp View File

@@ -12,7 +12,9 @@ namespace Proto4 {
return AppState::Game;
}

void Game::draw(sf::RenderTarget &window, sf::RenderStates states) const {}
void Game::draw(sf::RenderTarget &window, sf::RenderStates states) const {
window.draw(player);
}

bool Game::start() { return true; }


+ 3
- 2
game.hpp View File

@@ -5,6 +5,8 @@

#include "main.hpp"

#include "player.hpp"

#pragma once

namespace Proto4 {
@@ -24,8 +26,7 @@ namespace Proto4 {

private:
GameState gamestate = GameState::Uninitialized;
//Player player{};
//Background background{};
Player player{};
uint32_t score = 0;

};

+ 12
- 0
player.cpp View File

@@ -0,0 +1,12 @@
#include "player.hpp"

namespace Proto4 {
Player::Player() {
triangle = sf::CircleShape(80,3);
triangle.setFillColor(sf::Color(100, 250, 50));
}

void Player::draw(sf::RenderTarget &window, sf::RenderStates states) const {
window.draw(triangle);
}
}

+ 17
- 0
player.hpp View File

@@ -0,0 +1,17 @@
#pragma once

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>


namespace Proto4 {
class Player : public sf::Drawable, public sf::Transformable {
sf::CircleShape triangle;

public:
Player();
virtual void draw(sf::RenderTarget &window,
sf::RenderStates states) const;
};
}

Loading…
Cancel
Save