mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-07-04 15:03:01 +02:00
feat: Adding readme and sprites/textures handling
This commit is contained in:
parent
862090b43f
commit
6d39483528
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>
|
||||
|
||||
// Paths
|
||||
const std::string PATH_TO_PLAYER_TEXTURE = "Textures/Player.png";
|
||||
|
||||
// Player constants
|
||||
const float PLAYER_RADIUS = 40;
|
||||
|
||||
@ -20,14 +20,19 @@ class Game
|
||||
bool mIsMovingDown = false;
|
||||
private:
|
||||
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.setFillColor(PLAYER_COLOR);
|
||||
}
|
||||
|
||||
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