Cleaner menu system

This commit is contained in:
Pòsweg Blumenthal 2019-12-02 11:06:45 +01:00
parent eb41fb3f38
commit c15e4e48a5
2 changed files with 20 additions and 9 deletions

View File

@ -4,9 +4,16 @@
void Core::init(){ void Core::init(){
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
gWindow = SDL_CreateWindow("Platform Test!",SDL_WINDOWPOS_CENTERED,SDL_WINDOWPOS_CENTERED,SCREEN_WIDTH,SCREEN_HEIGHT,SDL_WINDOW_SHOWN); gWindow = SDL_CreateWindow(
gRenderer = SDL_CreateRenderer(gWindow,-1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); "Platform Test!",
SDL_SetRenderDrawColor(gRenderer,0xFF,0xFF,0xFF,0xFF); SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
SCREEN_WIDTH,SCREEN_HEIGHT, SDL_WINDOW_SHOWN
);
gRenderer = SDL_CreateRenderer(
gWindow, -1,
SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC
);
} }
void Core::close(){ void Core::close(){
@ -27,10 +34,16 @@ int Core::coreInit(){
//-1 = quit, 0 = Menu, 1 = playing, //-1 = quit, 0 = Menu, 1 = playing,
while(gamestate != -1){ while(gamestate != -1){
if(gamestate == 0) gamestate = menu(gRenderer); switch(gamestate){
else if(gamestate == 1) gamestate = maps.map("overworld"); case 0:
else gamestate = -1; gamestate = menu(gRenderer);
break;
case 1:
gamestate = maps.map("overworld");
break;
default:
gamestate = -1;
}
} }
close(); close();

View File

@ -161,8 +161,6 @@ void Player::move(){
float x = velocityX * dt * run; float x = velocityX * dt * run;
float y = velocityY * dt; float y = velocityY * dt;
std::cout << velocityY << " " << posY << " " << y << std::endl;
//Convert and set new int position //Convert and set new int position
posX += static_cast<int>(x); posX += static_cast<int>(x);
posY -= static_cast<int>(y+0.5); posY -= static_cast<int>(y+0.5);