Skip to content
Snippets Groups Projects
Commit ee0763b2 authored by j2-isaac's avatar j2-isaac
Browse files

Upload New File

parent 8fc20a89
Branches
No related tags found
No related merge requests found
game.h 0 → 100644
// game.h
#ifndef GAME_H
#define GAME_H
#include <SFML/Graphics.hpp>
#include <vector>
#include "Player.h"
#include "Enemy.h"
#include "Bullet.h"
class Game {
public:
Game();
void run();
private:
void processEvents();
void update();
void render();
sf::RenderWindow m_window;
Player m_player;
std::vector<Enemy> m_enemies;
std::vector<Bullet> m_bullets;
};
#endif
// game.cpp
#include "Game.h"
Game::Game() : m_window(sf::VideoMode(800, 600), "SFML Game") {
// Initialize player, enemies, bullets, etc.
}
void Game::run() {
while (m_window.isOpen()) {
processEvents();
update();
render();
}
}
void Game::processEvents() {
sf::Event event;
while (m_window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
m_window.close();
}
}
void Game::update() {
// Update game logic, move player, update enemy positions, check collisions, etc.
}
void Game::render() {
m_window.clear();
// Draw everything here: player, enemies, bullets, etc.
m_window.display();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment