Refactor / start SDL again master
authorwatkinsr <ryanwatkins54@gmail.com>
Sat, 13 Jun 2020 00:30:12 +0000 (01:30 +0100)
committerwatkinsr <ryanwatkins54@gmail.com>
Sat, 13 Jun 2020 00:30:12 +0000 (01:30 +0100)
include/SDL_Setup.h
src/GameLoop.cpp
src/GameLoop.h
src/Main.cpp
src/SDL_Setup.cpp

index 4a5b37b55987243c8ffc0e27b5d326094213043f..47e12cff7f22107c3ac74b5fd4e99c8eaef622e2 100644 (file)
@@ -3,11 +3,11 @@
 using namespace std;
 #include "stdafx.h"
 
-class CSDL_Setup
+class SDL_Setup
 {
 public:
-CSDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight);
-~CSDL_Setup(void);
+SDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight);
+~SDL_Setup(void);
 
 SDL_Renderer* GetRenderer();
 SDL_Event* GetMainEvent();
@@ -16,8 +16,6 @@ SDL_Window* GetWindow();
 void Begin();
 void End();
 
-
-
 private:
        SDL_Window* window;
        SDL_Renderer* renderer;
index 0a57fae811a58b4b666356a349cd76bfc6b56a50..91aafc071e698421ca28f89efa91aaf6257ba05a 100644 (file)
@@ -1,4 +1,4 @@
-#include "GameLoop.h"
+#include "../include/GameLoop.h"
 
 GameLoop::GameLoop(int sw, int sh){
        camera_x = 0;
@@ -8,7 +8,7 @@ GameLoop::GameLoop(int sw, int sh){
        screen_width = sw;
        screen_height = sh;
        
-       sdl_setup = new CSDL_Setup(&quit, screen_width, screen_height);
+       sdl = new SDL_Setup(&quit, screen_width, screen_height);
 
        Start();
 }
@@ -18,7 +18,7 @@ GameLoop::~GameLoop(void){
 }
 
 void GameLoop::Start(){
-while (!quit && csdl_setup->GetMainEvent()->type != SDL_QUIT && start != true)
+while (!quit && sdl_setup->GetMainEvent()->type != SDL_QUIT)
        {
                csdl_setup->Begin();
                SDL_GetMouseState(&MouseX,&MouseY);
@@ -28,11 +28,3 @@ while (!quit && csdl_setup->GetMainEvent()->type != SDL_QUIT && start != true)
                csdl_setup->End();
        }
 }
-
-//really, this should have loadMap() which inits vector of npcs, chests, other various entities such as enemies and so on.
-void GameLoop::Play(){
-       while (!quit && csdl_setup->GetMainEvent()->type != SDL_QUIT){
-               csdl_setup->Begin();
-               csdl_setup->End();      
-       }
-}
index 5c38c5bad3cb7e03a9ba1ed22355dbba67c3b177..f7a6141c033631c2fed95549e8a52fbc342e758e 100644 (file)
@@ -18,7 +18,7 @@ private:
        float camera_x;
        float camera_y;
 
-       CSDL_Setup* csdl_setup;
+       CSDL_Setup* sdl;
 
        int mouse_x;
        int mouse_y;
index 77ac10b39c4d04da40f1c93c2d578f704fd075fe..990e0dfd4e7a0fe42c1878604f01b424ceb252bb 100644 (file)
@@ -1,16 +1,12 @@
 #include "stdafx.h"
 //#include <vld.h>
-#include "GameLoop.h"
+#include "../include/SDL_Setup.h"
 
 using namespace std;
 
 int main()
 {
-       GameLoop*  mainGame = new GameLoop(640, 480);
-       // mainGame->Begin(false);
-
-       delete mainGame;
-
+  SDL_Setup* sdl = SDL_Setup(false, 640, 480)
        return 0;
 }
 
index c156410a51195818dd1be27bd90b920d46d533a2..ad9dbb7bd046245dabfcfde9e0eb02063a032dc7 100644 (file)
@@ -1,6 +1,6 @@
-#include "SDL_Setup.h"
+#include "../include/SDL_Setup.h"
 
-CSDL_Setup::CSDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight){
+SDL_Setup::SDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight){
        SDL_Init(SDL_INIT_VIDEO);
 
        window = NULL;
@@ -16,30 +16,29 @@ CSDL_Setup::CSDL_Setup(bool* quit, int ScreenWidth, int ScreenHeight){
        mainEvent = new SDL_Event();
 }
 
-CSDL_Setup::~CSDL_Setup(){
+SDL_Setup::~SDL_Setup(){
        SDL_DestroyWindow(window);
        SDL_DestroyRenderer(renderer);
        delete mainEvent;
 }
 
-SDL_Renderer* CSDL_Setup::GetRenderer(){
+SDL_Renderer* SDL_Setup::GetRenderer(){
        return renderer;
 }
 
-SDL_Event* CSDL_Setup::GetMainEvent(){
+SDL_Event* SDL_Setup::GetMainEvent(){
        return mainEvent;
 }
 
-void CSDL_Setup::Begin(){
+void SDL_Setup::Begin(){
        SDL_PollEvent(mainEvent);
        SDL_RenderClear(renderer);
 }
 
-void CSDL_Setup::End(){
+void SDL_Setup::End(){
        SDL_RenderPresent(renderer);
-
 }
 
-SDL_Window* CSDL_Setup::GetWindow(){
+SDL_Window* SDL_Setup::GetWindow(){
        return window;
-}
\ No newline at end of file
+}