Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Game.cpp
- * Holds info for main game loop
- *
- *
- *
- */
- #include <SDL2/SDL.h>
- #include <iostream>
- #include "Game.h"
- #include "Graphics.h"
- #include "functions.h"
- Game::Game() {
- if(SDL_Init(SDL_INIT_EVERYTHING) == -1){
- printError("SDL_Init()");
- SDL_Quit();
- }
- _isRunning= true;
- }
- Game::~Game() {
- SDL_Quit();
- }
- void Game::run(){
- Graphics graphics;
- Layer background(graphics.getRenderer(), graphics._windowWidth, graphics._windowHeight);
- while(_isRunning){
- while(SDL_PollEvent(&_ev) != 0){
- if(_ev.type == SDL_QUIT)
- _isRunning= false;
- }
- if(SDL_RenderClear(graphics.getRenderer()) == -1)
- printError("SDL_RenderClear()");
- if( SDL_RenderCopy(graphics.getRenderer(), background.getTexture(), NULL, NULL) == -1)
- printError("SDL_RenderCopy()");
- SDL_RenderPresent(graphics.getRenderer());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment