Began work on the client

This commit is contained in:
2015-08-02 03:20:59 +10:00
parent aa9081d9cf
commit 0150dbb929
17 changed files with 299 additions and 244 deletions
-40
View File
@@ -31,13 +31,6 @@ BaseScene::~BaseScene() {
//EMPTY
}
void BaseScene::RunFrame() {
FrameStart();
ProcessEvents();
Update();
FrameEnd();
}
void BaseScene::RenderFrame(SDL_Renderer* renderer) {
//EMPTY
}
@@ -66,39 +59,6 @@ void BaseScene::FrameStart() {
//EMPTY
}
void BaseScene::ProcessEvents() {
SDL_Event event;
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_QUIT:
QuitEvent();
break;
case SDL_MOUSEMOTION:
MouseMotion(event.motion);
break;
case SDL_MOUSEBUTTONDOWN:
MouseButtonDown(event.button);
break;
case SDL_MOUSEBUTTONUP:
MouseButtonUp(event.button);
break;
case SDL_KEYDOWN:
KeyDown(event.key);
break;
case SDL_KEYUP:
KeyUp(event.key);
break;
//TODO: joystick and controller events
}
}
}
void BaseScene::Update() {
//EMPTY
}
+5 -8
View File
@@ -30,20 +30,12 @@ public:
BaseScene();
virtual ~BaseScene();
virtual void RunFrame();
virtual void RenderFrame(SDL_Renderer*);
static void SetRenderer(SDL_Renderer*);
SceneSignal GetSceneSignal();
protected:
//control
static SDL_Renderer* GetRenderer();
void SetSceneSignal(SceneSignal);
//frame phases
virtual void FrameStart();
virtual void ProcessEvents();
virtual void Update();
virtual void FrameEnd();
@@ -58,6 +50,11 @@ protected:
//TODO: joystick and controller events
protected:
//control
static SDL_Renderer* GetRenderer();
void SetSceneSignal(SceneSignal);
private:
static SDL_Renderer* rendererHandle;
SceneSignal sceneSignal = SceneSignal::CONTINUE;
+154 -76
View File
@@ -24,22 +24,10 @@
#include "serial_packet.hpp"
#include "config_utility.hpp"
#include <stdexcept>
#include <chrono>
#include <iostream>
#include <sstream>
//-------------------------
//Scene headers
//-------------------------
//Add the custom scene headers here
#include "splash_screen.hpp"
#include "main_menu.hpp"
#include "options_menu.hpp"
#include "lobby_menu.hpp"
#include "world.hpp"
#include "disconnected_screen.hpp"
#include <stdexcept>
//-------------------------
//Public access members
@@ -53,34 +41,57 @@ void ClientApplication::Init(int argc, char* argv[]) {
config.Load("rsc/config.cfg", false, argc, argv);
//-------------------------
//Initialize the APIs
//-------------------------
//initialize SDL
if (SDL_Init(SDL_INIT_VIDEO)) {
std::ostringstream os;
os << "Failed to initialize SDL: " << SDL_GetError();
throw(std::runtime_error(os.str()));
}
std::cout << "Initialized SDL" << std::endl;
//initialize SDL_net
if (SDLNet_Init()) {
throw(std::runtime_error("Failed to initialize SDL_net"));
}
UDPNetworkUtility::GetSingleton().Open(0);
std::cout << "Initialized SDL_net" << std::endl;
//-------------------------
//Setup the screen
//create and check the window
//-------------------------
int w = config.Int("client.screen.w");
int h = config.Int("client.screen.h");
int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF;
int f = config.Bool("client.screen.f") ? SDL_WINDOW_FULLSCREEN : 0;
BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f);
std::cout << "Initialized the screen" << std::endl;
window = SDL_CreateWindow(argv[0], SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w ? w : 800, h ? h : 600, f);
if (!window) {
std::ostringstream msg;
msg << "Failed to create the window: " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
std::cout << "Initialized the window" << std::endl;
//-------------------------
//create and check the renderer
//-------------------------
renderer = SDL_CreateRenderer(window, -1, 0);
if (!renderer) {
std::ostringstream msg;
msg << "Failed to create the renderer: " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
//screen scaling
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best");
SDL_RenderSetLogicalSize(renderer, w, h);
//set the hook for the renderer
BaseScene::SetRenderer(renderer);
std::cout << "Initialized the renderer" << std::endl;
//-------------------------
//Initialize the APIs
//-------------------------
//initialize SDL_net
if (SDLNet_Init()) {
std::ostringstream msg;
msg << "Failed to initialize SDL_net: " << SDL_GetError();
throw(std::runtime_error(msg.str()));
}
UDPNetworkUtility::GetSingleton().Open(0);
std::cout << "Initialized SDL_net" << std::endl;
//-------------------------
//debug output
@@ -119,88 +130,155 @@ void ClientApplication::Init(int argc, char* argv[]) {
}
void ClientApplication::Proc() {
LoadScene(SceneList::FIRST);
//load the first scene
ProcessSceneSignal(SceneSignal::FIRST);
//prepare the time system
//fixed frame rate
typedef std::chrono::steady_clock Clock;
Clock::time_point simTime = Clock::now();
Clock::time_point realTime;
constexpr std::chrono::duration<int, std::milli> frameDelay(16); //~60FPS
//The main loop
while(activeScene->GetNextScene() != SceneList::QUIT) {
//switch scenes when necessary
if (activeScene->GetNextScene() != SceneList::CONTINUE) {
LoadScene(activeScene->GetNextScene());
//the game loop continues until the scenes signal QUIT
while(activeScene->GetSceneSignal() != SceneSignal::QUIT) {
//switch scenes if necessary
if(activeScene->GetSceneSignal() != SceneSignal::CONTINUE) {
ProcessSceneSignal(activeScene->GetSceneSignal());
continue;
}
//update the current time
realTime = Clock::now();
//simulate game time
//simulate the game or give the machine a break
if (simTime < realTime) {
while(simTime < realTime) {
//call each user defined function
activeScene->RunFrame();
//~60 FPS
simTime += std::chrono::duration<int, std::milli>(16);
//call the user defined functions
activeScene->FrameStart();
ProcessEvents();
activeScene->Update();
activeScene->FrameEnd();
//step to the next frame
simTime += frameDelay;
}
}
else {
//give the machine a break
SDL_Delay(10);
SDL_Delay(1);
}
//draw the game to the screen
activeScene->RenderFrame();
SDL_RenderClear(renderer);
activeScene->RenderFrame(renderer);
SDL_RenderPresent(renderer);
}
UnloadScene();
//cleanup
ClearScene();
}
void ClientApplication::Quit() {
//clean up after the program
std::cout << "Shutting down" << std::endl;
UDPNetworkUtility::GetSingleton().Close();
SDLNet_Quit();
SDL_Quit();
BaseScene::SetRenderer(nullptr);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
std::cout << "Clean exit" << std::endl;
}
//-------------------------
//Private access members
//Scene management
//-------------------------
void ClientApplication::LoadScene(SceneList sceneIndex) {
//BUG: #16 Resources are being reloaded between scenes
UnloadScene();
switch(sceneIndex) {
//add scene creation calls here
case SceneList::FIRST:
case SceneList::SPLASHSCREEN:
activeScene = new SplashScreen();
void ClientApplication::ProcessEvents() {
SDL_Event event;
while(SDL_PollEvent(&event)) {
switch(event.type) {
case SDL_QUIT:
activeScene->QuitEvent();
break;
case SceneList::MAINMENU:
activeScene = new MainMenu();
case SDL_MOUSEMOTION:
activeScene->MouseMotion(event.motion);
break;
case SceneList::OPTIONSMENU:
activeScene = new OptionsMenu();
case SDL_MOUSEBUTTONDOWN:
activeScene->MouseButtonDown(event.button);
break;
case SceneList::LOBBYMENU:
activeScene = new LobbyMenu(&clientIndex, &accountIndex);
case SDL_MOUSEBUTTONUP:
activeScene->MouseButtonUp(event.button);
break;
case SceneList::WORLD:
activeScene = new World(&clientIndex, &accountIndex);
case SDL_MOUSEWHEEL:
activeScene->MouseWheel(event.wheel);
break;
case SceneList::DISCONNECTEDSCREEN:
activeScene = new DisconnectedScreen();
case SDL_KEYDOWN:
activeScene->KeyDown(event.key);
break;
default:
throw(std::logic_error("Failed to recognize the scene index"));
case SDL_KEYUP:
activeScene->KeyUp(event.key);
break;
//TODO: joystick and controller events
//window events are handled internally
case SDL_WINDOWEVENT:
switch(event.window.event) {
case SDL_WINDOWEVENT_RESIZED:
SDL_RenderSetLogicalSize(renderer, event.window.data1, event.window.data2);
break;
}
break;
}
}
}
void ClientApplication::UnloadScene() {
//Add the custom scene headers here
#include "splash_screen.hpp"
#include "main_menu.hpp"
#include "options_menu.hpp"
#include "lobby_menu.hpp"
#include "world.hpp"
#include "disconnected_screen.hpp"
void ClientApplication::ProcessSceneSignal(SceneSignal signal) {
//BUG: #16 Resources are being reloaded between scenes
ClearScene();
switch(signal) {
//add scene creation calls here
case SceneSignal::FIRST:
case SceneSignal::SPLASHSCREEN:
activeScene = new SplashScreen();
break;
case SceneSignal::MAINMENU:
activeScene = new MainMenu();
break;
case SceneSignal::OPTIONSMENU:
activeScene = new OptionsMenu();
break;
case SceneSignal::LOBBYMENU:
activeScene = new LobbyMenu(&clientIndex, &accountIndex);
break;
case SceneSignal::WORLD:
activeScene = new World(&clientIndex, &accountIndex);
break;
case SceneSignal::DISCONNECTEDSCREEN:
activeScene = new DisconnectedScreen();
break;
default: {
std::ostringstream msg;
msg << "Failed to recognize the scene signal: " << signal;
throw(std::logic_error(msg.str()));
}
}
}
void ClientApplication::ClearScene() {
delete activeScene;
activeScene = nullptr;
}
+11 -9
View File
@@ -21,18 +21,15 @@
*/
#pragma once
#include "scene_list.hpp"
#include "base_scene.hpp"
#include "scene_signal.hpp"
#include "singleton.hpp"
#include "udp_network_utility.hpp"
#include "singleton.hpp"
#include <map>
#include "SDL2/SDL.h"
class ClientApplication: public Singleton<ClientApplication> {
public:
//public methods
void Init(int argc, char* argv[]);
void Proc();
void Quit();
@@ -43,12 +40,17 @@ private:
ClientApplication() = default;
~ClientApplication() = default;
//Private access members
void LoadScene(SceneList sceneIndex);
void UnloadScene();
//scene management
void ProcessEvents();
void ProcessSceneSignal(SceneSignal);
void ClearScene();
BaseScene* activeScene = nullptr;
//TODO: build a "window" class?
SDL_Window* window = nullptr;
SDL_Renderer* renderer = nullptr;
//shared parameters
int clientIndex = -1;
int accountIndex = -1;
+14 -16
View File
@@ -31,7 +31,6 @@
//graphics
#include "image.hpp"
#include "raster_font.hpp"
#include "button.hpp"
#include "tile_sheet.hpp"
@@ -54,21 +53,21 @@ public:
World(int* const argClientIndex, int* const argAccountIndex);
~World();
protected:
//Frame loop
void FrameStart();
void Update();
void FrameEnd();
void RenderFrame();
void Render(SDL_Surface* const);
void RenderFrame(SDL_Renderer* renderer) override;
//Event handlers
void QuitEvent();
void MouseMotion(SDL_MouseMotionEvent const&);
void MouseButtonDown(SDL_MouseButtonEvent const&);
void MouseButtonUp(SDL_MouseButtonEvent const&);
void KeyDown(SDL_KeyboardEvent const&);
void KeyUp(SDL_KeyboardEvent const&);
private:
//frame phases
void FrameStart() override;
void Update() override;
void FrameEnd() override;
//input events
void MouseMotion(SDL_MouseMotionEvent const& event) override;
void MouseButtonDown(SDL_MouseButtonEvent const& event) override;
void MouseButtonUp(SDL_MouseButtonEvent const& event) override;
void MouseWheel(SDL_MouseWheelEvent const& event) override;
void KeyDown(SDL_KeyboardEvent const& event) override;
void KeyUp(SDL_KeyboardEvent const& event) override;
//handle incoming traffic
void HandlePacket(SerialPacket* const);
@@ -132,7 +131,6 @@ protected:
//graphics
Image buttonImage;
RasterFont font;
TileSheet tileSheet;
//map
+1
View File
@@ -44,6 +44,7 @@ int main(int argc, char* argv[]) {
app.Proc();
app.Quit();
//control the position of the app's destructor
ClientApplication::DeleteSingleton();
//delete the singletons
+11 -7
View File
@@ -1,5 +1,5 @@
#include directories
INCLUDES+=SDL . client_utilities entities gameplay_scenes menu_scenes ../common/debugging ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet_types ../common/ui ../common/utilities
INCLUDES+=. client_utilities entities gameplay_scenes menu_scenes ../common/debugging ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet_types ../common/ui ../common/utilities
#libraries
#the order of the $(LIBS) is important, at least for MinGW
@@ -7,10 +7,14 @@ LIBS+=client.a ../libcommon.a -lSDL_net
ifeq ($(OS),Windows_NT)
LIBS+=-lwsock32 -liphlpapi -lmingw32
endif
LIBS+=-lSDLmain -lSDL -lSDL2_image -lSDL2_ttf
LIBS+=-lSDL2main -lSDL2 -lSDL2_image -lSDL2_ttf
#flags
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
ifeq ($(shell uname), Linux)
#read data about the current install
CXXFLAGS+=$(shell sdl-config --cflags --static-libs)
endif
#source
CXXSRC=$(wildcard *.cpp)
@@ -25,11 +29,11 @@ OUT=$(addprefix $(OUTDIR)/,client)
#targets
all: $(OBJ) $(OUT)
$(MAKE) -C client_utilities
$(MAKE) -C entities
$(MAKE) -C gameplay_scenes
$(MAKE) -C menu_scenes
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
# $(MAKE) -C client_utilities
# $(MAKE) -C entities
# $(MAKE) -C gameplay_scenes
# $(MAKE) -C menu_scenes
# $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
$(OBJ): | $(OBJDIR)
+13 -9
View File
@@ -65,6 +65,10 @@ DisconnectedScreen::~DisconnectedScreen() {
//Frame loop
//-------------------------
void DisconnectedScreen::FrameStart() {
//
}
void DisconnectedScreen::Update() {
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(10)) {
SetNextScene(SceneList::MAINMENU);
@@ -74,10 +78,14 @@ void DisconnectedScreen::Update() {
while(UDPNetworkUtility::GetSingleton().Receive());
}
void DisconnectedScreen::Render(SDL_Surface* const screen) {
void DisconnectedScreen::FrameEnd() {
//
}
void DisconnectedScreen::RenderFrame(SDL_Renderer* renderer) {
ConfigUtility& config = ConfigUtility::GetSingleton();
backButton.DrawTo(screen);
backButton.DrawTo(renderer);
font.DrawStringTo(config["client.disconnectMessage"], screen, 50, 30);
}
@@ -85,10 +93,6 @@ void DisconnectedScreen::Render(SDL_Surface* const screen) {
//Event handlers
//-------------------------
void DisconnectedScreen::QuitEvent() {
SetNextScene(SceneList::QUIT);
}
void DisconnectedScreen::MouseMotion(SDL_MouseMotionEvent const& motion) {
backButton.MouseMotion(motion);
}
@@ -98,15 +102,15 @@ void DisconnectedScreen::MouseButtonDown(SDL_MouseButtonEvent const& button) {
}
void DisconnectedScreen::MouseButtonUp(SDL_MouseButtonEvent const& button) {
if (backButton.MouseButtonUp(button) == Button::State::HOVER) {
SetNextScene(SceneList::MAINMENU);
if (backButton.MouseButtonUp(button) == Button::State::RELEASED) {
SetSceneSignal(SceneSignal::MAINMENU);
}
}
void DisconnectedScreen::KeyDown(SDL_KeyboardEvent const& key) {
switch(key.keysym.sym) {
case SDLK_ESCAPE:
SetNextScene(SceneList::MAINMENU);
SetSceneSignal(SceneSignal::MAINMENU);
break;
}
}
+14 -15
View File
@@ -23,7 +23,6 @@
//graphics
#include "image.hpp"
#include "raster_font.hpp"
#include "button.hpp"
//client
@@ -38,24 +37,24 @@ public:
DisconnectedScreen();
~DisconnectedScreen();
protected:
//Frame loop
void Update();
void Render(SDL_Surface* const);
void RenderFrame(SDL_Renderer* renderer) override;
//Event handlers
void QuitEvent();
void MouseMotion(SDL_MouseMotionEvent const&);
void MouseButtonDown(SDL_MouseButtonEvent const&);
void MouseButtonUp(SDL_MouseButtonEvent const&);
void KeyDown(SDL_KeyboardEvent const&);
void KeyUp(SDL_KeyboardEvent const&);
protected:
//frame phases
void FrameStart() override;
void Update() override;
void FrameEnd() override;
//input events
void MouseMotion(SDL_MouseMotionEvent const& event) override;
void MouseButtonDown(SDL_MouseButtonEvent const& event) override;
void MouseButtonUp(SDL_MouseButtonEvent const& event) override;
void MouseWheel(SDL_MouseWheelEvent const& event) override;
void KeyDown(SDL_KeyboardEvent const& event) override;
void KeyUp(SDL_KeyboardEvent const& event) override;
//graphics
Image image;
RasterFont font;
//UI
Button backButton;
//auto return
+9 -5
View File
@@ -99,13 +99,13 @@ void LobbyMenu::FrameEnd() {
//
}
void LobbyMenu::Render(SDL_Surface* const screen) {
void ExampleScene::RenderFrame(SDL_Renderer* renderer) {
//TODO: (2) I need a proper UI system for the entire client and the editor
//UI
search.DrawTo(screen);
join.DrawTo(screen);
back.DrawTo(screen);
search.DrawTo(renderer);
join.DrawTo(renderer);
back.DrawTo(renderer);
//TODO: (3) draw headers for the server list
//TODO: (3) ping/delay displayed in the server list
@@ -173,10 +173,14 @@ void LobbyMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
}
}
void LobbyMenu::MouseWheel(SDL_MouseWheelEvent const& event) {
//
}
void LobbyMenu::KeyDown(SDL_KeyboardEvent const& key) {
switch(key.keysym.sym) {
case SDLK_ESCAPE:
SetNextScene(SceneList::MAINMENU);
SetSceneSignal(SceneSignal::MAINMENU);
break;
}
}
+14 -14
View File
@@ -23,7 +23,6 @@
//graphics & ui
#include "image.hpp"
#include "raster_font.hpp"
#include "button.hpp"
#include "bounding_box.hpp"
@@ -44,19 +43,21 @@ public:
LobbyMenu(int* const argClientIndex, int* const argAccountIndex);
~LobbyMenu();
protected:
//Frame loop
void FrameStart();
void Update();
void FrameEnd();
void Render(SDL_Surface* const);
void RenderFrame(SDL_Renderer* renderer) override;
//Event handlers
void MouseMotion(SDL_MouseMotionEvent const&);
void MouseButtonDown(SDL_MouseButtonEvent const&);
void MouseButtonUp(SDL_MouseButtonEvent const&);
void KeyDown(SDL_KeyboardEvent const&);
void KeyUp(SDL_KeyboardEvent const&);
protected:
//frame phases
void FrameStart() override;
void Update() override;
void FrameEnd() override;
//input events
void MouseMotion(SDL_MouseMotionEvent const& event) override;
void MouseButtonDown(SDL_MouseButtonEvent const& event) override;
void MouseButtonUp(SDL_MouseButtonEvent const& event) override;
void MouseWheel(SDL_MouseWheelEvent const& event) override;
void KeyDown(SDL_KeyboardEvent const& event) override;
void KeyUp(SDL_KeyboardEvent const& event) override;
//Network handlers
void HandlePacket(SerialPacket* const);
@@ -79,7 +80,6 @@ protected:
//members
Image image;
RasterFont font;
Button search;
Button join;
Button back;
+14 -14
View File
@@ -24,7 +24,6 @@
#include "base_scene.hpp"
#include "image.hpp"
#include "raster_font.hpp"
#include "button.hpp"
class MainMenu : public BaseScene {
@@ -33,23 +32,24 @@ public:
MainMenu();
~MainMenu();
protected:
//Frame loop
void FrameStart();
void Update();
void FrameEnd();
void Render(SDL_Surface* const);
void RenderFrame(SDL_Renderer* renderer) override;
//Event handlers
void MouseMotion(SDL_MouseMotionEvent const&);
void MouseButtonDown(SDL_MouseButtonEvent const&);
void MouseButtonUp(SDL_MouseButtonEvent const&);
void KeyDown(SDL_KeyboardEvent const&);
void KeyUp(SDL_KeyboardEvent const&);
protected:
//frame phases
void FrameStart() override;
void Update() override;
void FrameEnd() override;
//input events
void MouseMotion(SDL_MouseMotionEvent const& event) override;
void MouseButtonDown(SDL_MouseButtonEvent const& event) override;
void MouseButtonUp(SDL_MouseButtonEvent const& event) override;
void MouseWheel(SDL_MouseWheelEvent const& event) override;
void KeyDown(SDL_KeyboardEvent const& event) override;
void KeyUp(SDL_KeyboardEvent const& event) override;
//members
Image image;
RasterFont font;
Button startButton;
Button optionsButton;
Button quitButton;
+14 -14
View File
@@ -24,7 +24,6 @@
#include "base_scene.hpp"
#include "image.hpp"
#include "raster_font.hpp"
#include "button.hpp"
//NOTE: The options screen needs to be USED
@@ -34,22 +33,23 @@ public:
OptionsMenu();
~OptionsMenu();
protected:
//Frame loop
void FrameStart();
void Update();
void FrameEnd();
void Render(SDL_Surface* const);
void RenderFrame(SDL_Renderer* renderer) override;
//Event handlers
void MouseMotion(SDL_MouseMotionEvent const&);
void MouseButtonDown(SDL_MouseButtonEvent const&);
void MouseButtonUp(SDL_MouseButtonEvent const&);
void KeyDown(SDL_KeyboardEvent const&);
void KeyUp(SDL_KeyboardEvent const&);
private:
//frame phases
void FrameStart() override;
void Update() override;
void FrameEnd() override;
//input events
void MouseMotion(SDL_MouseMotionEvent const& event) override;
void MouseButtonDown(SDL_MouseButtonEvent const& event) override;
void MouseButtonUp(SDL_MouseButtonEvent const& event) override;
void MouseWheel(SDL_MouseWheelEvent const& event) override;
void KeyDown(SDL_KeyboardEvent const& event) override;
void KeyUp(SDL_KeyboardEvent const& event) override;
//members
Image image;
RasterFont font;
Button backButton;
};
+6 -4
View File
@@ -40,12 +40,14 @@ SplashScreen::~SplashScreen() {
//Frame loop
//-------------------------
void SplashScreen::Update() {
void SplashScreen::FrameStart() {
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(1)) {
SetNextScene(SceneList::MAINMENU);
SetSceneSignal(SceneSignal::MAINMENU);
}
}
void SplashScreen::Render(SDL_Surface* const screen) {
logo.DrawTo(screen, (screen->w - logo.GetClipW()) / 2, (screen->h - logo.GetClipH()) / 2);
void SplashScreen::RenderFrame(SDL_Renderer* renderer) {
int w = 0, h = 0;
SDL_GetLogicalSize(renderer, &w, &h);
logo.DrawTo(renderer, (w - logo.GetClipW()) / 2, (h - logo.GetClipH()) / 2);
}
+4 -3
View File
@@ -33,10 +33,11 @@ public:
SplashScreen();
~SplashScreen();
protected:
void RenderFrame(SDL_Renderer* renderer) override;
private:
//Frame loop
void Update();
void Render(SDL_Surface* const);
void FrameStart() override;
//members
std::chrono::steady_clock::time_point startTick;
+6 -1
View File
@@ -28,5 +28,10 @@ enum SceneSignal {
FIRST = 1,
//custom scenes
EXAMPLE_SCENE
SPLASHSCREEN,
MAINMENU,
OPTIONSMENU,
LOBBYMENU,
WORLD,
DISCONNECTEDSCREEN,
};
+1 -1
View File
@@ -8,7 +8,7 @@ OUTDIR=out
all: $(OUTDIR)
$(MAKE) -C common
$(MAKE) -C server
# $(MAKE) -C server
$(MAKE) -C client
debug: export CXXFLAGS+=-g