mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-20 16:52:20 +01:00
feat: Adding readme and sprites/textures handling
This commit is contained in:
parent
295de5292a
commit
5ff5476304
BIN
SFMLEngine/makingAGameTick/Textures/Player.png
Normal file
BIN
SFMLEngine/makingAGameTick/Textures/Player.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
|
// Paths
|
||||||
|
const std::string PATH_TO_PLAYER_TEXTURE = "Textures/Player.png";
|
||||||
|
|
||||||
// Player constants
|
// Player constants
|
||||||
const float PLAYER_RADIUS = 40;
|
const float PLAYER_RADIUS = 40;
|
||||||
|
|||||||
@ -20,14 +20,19 @@ class Game
|
|||||||
bool mIsMovingDown = false;
|
bool mIsMovingDown = false;
|
||||||
private:
|
private:
|
||||||
sf::RenderWindow mWindow;
|
sf::RenderWindow mWindow;
|
||||||
sf::CircleShape mPlayer;
|
sf::Texture mTexture;
|
||||||
|
sf::Sprite mPlayer;
|
||||||
};
|
};
|
||||||
|
|
||||||
Game::Game() : mWindow(sf::VideoMode(640, 480), "SFML Application"), mPlayer()
|
Game::Game() : mWindow(sf::VideoMode(640, 480), "SFML Application"), mTexture(), mPlayer()
|
||||||
{
|
{
|
||||||
mPlayer.setRadius(PLAYER_RADIUS);
|
if (!mTexture.loadFromFile(PATH_TO_PLAYER_TEXTURE))
|
||||||
|
{
|
||||||
|
std::cout << "NO FILE: " << PATH_TO_PLAYER_TEXTURE << std::endl;
|
||||||
|
mWindow.close();
|
||||||
|
}
|
||||||
|
mPlayer.setTexture(mTexture);
|
||||||
mPlayer.setPosition(PLAYER_X_POSITION, PLAYER_Y_POSITION);
|
mPlayer.setPosition(PLAYER_X_POSITION, PLAYER_Y_POSITION);
|
||||||
mPlayer.setFillColor(PLAYER_COLOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::run()
|
void Game::run()
|
||||||
|
|||||||
Binary file not shown.
2
SFMLEngine/readme.md
Normal file
2
SFMLEngine/readme.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Textures and Audio used:
|
||||||
|
Space Game Starter Set by hc - https://opengameart.org/content/space-game-starter-set
|
||||||
Loading…
Reference in New Issue
Block a user