Init
This commit is contained in:
commit
f8f640ae89
|
@ -0,0 +1,72 @@
|
|||
# This file is used to ignore files which are generated
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
*~
|
||||
*.autosave
|
||||
*.a
|
||||
*.core
|
||||
*.moc
|
||||
*.o
|
||||
*.obj
|
||||
*.orig
|
||||
*.rej
|
||||
*.so
|
||||
*.so.*
|
||||
*_pch.h.cpp
|
||||
*_resource.rc
|
||||
*.qm
|
||||
.#*
|
||||
*.*#
|
||||
core
|
||||
!core/
|
||||
tags
|
||||
.DS_Store
|
||||
.directory
|
||||
*.debug
|
||||
Makefile*
|
||||
*.prl
|
||||
*.app
|
||||
moc_*.cpp
|
||||
ui_*.h
|
||||
qrc_*.cpp
|
||||
Thumbs.db
|
||||
*.res
|
||||
*.rc
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
|
||||
# qtcreator generated files
|
||||
*.pro.user*
|
||||
|
||||
# xemacs temporary files
|
||||
*.flc
|
||||
|
||||
# Vim temporary files
|
||||
.*.swp
|
||||
|
||||
# Visual Studio generated files
|
||||
*.ib_pdb_index
|
||||
*.idb
|
||||
*.ilk
|
||||
*.pdb
|
||||
*.sln
|
||||
*.suo
|
||||
*.vcproj
|
||||
*vcproj.*.*.user
|
||||
*.ncb
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.vcxproj
|
||||
*vcxproj.*
|
||||
|
||||
# MinGW generated files
|
||||
*.Debug
|
||||
*.Release
|
||||
|
||||
# Python byte code
|
||||
*.pyc
|
||||
|
||||
# Binaries
|
||||
# --------
|
||||
*.dll
|
||||
*.exe
|
|
@ -0,0 +1,3 @@
|
|||
# sfml-test
|
||||
|
||||
Just playing around with [sfml](https://www.sfml-dev.org/), since I have nothing better to do anyway.
|
|
@ -0,0 +1,28 @@
|
|||
#include "game.h"
|
||||
|
||||
Game::Game()
|
||||
{
|
||||
sf::Window window(sf::VideoMode(640, 480), "SFML-Test Application", sf::Style::Default);
|
||||
window.setActive();
|
||||
}
|
||||
|
||||
int Game::run()
|
||||
{
|
||||
clock = std::make_unique<sf::Clock>();
|
||||
|
||||
// On the game loop
|
||||
while (main_window.isOpen())
|
||||
{
|
||||
sf::Event event;
|
||||
while (main_window.pollEvent(event))
|
||||
{
|
||||
if (event.type == sf::Event::Closed)
|
||||
main_window.close();
|
||||
|
||||
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape))
|
||||
main_window.close();
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef GAME_H
|
||||
#define GAME_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <SFML/System/Time.hpp>
|
||||
#include <SFML/Window.hpp>
|
||||
|
||||
class Game
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<sf::Clock> clock;
|
||||
sf::Window main_window;
|
||||
|
||||
public:
|
||||
explicit Game();
|
||||
|
||||
// Start the game loop
|
||||
int run();
|
||||
};
|
||||
|
||||
#endif // GAME_H
|
|
@ -0,0 +1,25 @@
|
|||
#include "hero.h"
|
||||
|
||||
Hero::Hero(int initial_charges) :
|
||||
hero_charges(initial_charges)
|
||||
{}
|
||||
|
||||
void Hero::refillCharges(int append_charges)
|
||||
{
|
||||
hero_charges += append_charges;
|
||||
}
|
||||
|
||||
int Hero::charges() const noexcept
|
||||
{
|
||||
return hero_charges;
|
||||
}
|
||||
|
||||
bool Hero::useCharge()
|
||||
{
|
||||
if (hero_charges > 0) {
|
||||
--hero_charges;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef HERO_H
|
||||
#define HERO_H
|
||||
|
||||
class Hero
|
||||
{
|
||||
private:
|
||||
int hero_charges;
|
||||
|
||||
public:
|
||||
explicit Hero(int initial_charges = 0);
|
||||
|
||||
// Add more charges for hero to use
|
||||
inline void refillCharges(int append_charges);
|
||||
|
||||
// Get amount of charges
|
||||
inline int charges() const noexcept;
|
||||
|
||||
// Spend one charge on action
|
||||
inline bool useCharge();
|
||||
};
|
||||
|
||||
#endif // HERO_H
|
|
@ -0,0 +1,19 @@
|
|||
#ifndef LEVEL_H
|
||||
#define LEVEL_H
|
||||
|
||||
#include <array>
|
||||
|
||||
constexpr int side = 32;
|
||||
|
||||
using Map = std::array<std::array<int, side>, side>;
|
||||
|
||||
class Level
|
||||
{
|
||||
private:
|
||||
Map map;
|
||||
|
||||
public:
|
||||
Level();
|
||||
};
|
||||
|
||||
#endif // LEVEL_H
|
|
@ -0,0 +1,8 @@
|
|||
#include <iostream>
|
||||
#include "game.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
Game game;
|
||||
return game.run();
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
TEMPLATE = app
|
||||
CONFIG += c++17
|
||||
CONFIG -= console app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
SOURCES += \
|
||||
game.cpp \
|
||||
hero.cpp \
|
||||
level.cpp \
|
||||
main.cpp
|
||||
|
||||
HEADERS += \
|
||||
game.h \
|
||||
hero.h \
|
||||
level.h
|
||||
|
||||
# Only to highlight syntax when I am on Windows
|
||||
win32:INCLUDEPATH += d:\SFML-2.5.1\include
|
Loading…
Reference in New Issue