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

View File

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