- Comencem a implementar els menus
This commit is contained in:
@@ -94,7 +94,7 @@ namespace modules
|
||||
{
|
||||
draw::fillrect(60+pixels[i].x*4, 106+pixels[i].y*4, 4*pixels[i].di, 4*pixels[i].di);
|
||||
}
|
||||
} else {
|
||||
} else if (steps>280) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
32
source/m_menu.cpp
Normal file
32
source/m_menu.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#include "m_menu.h"
|
||||
#include "jgame.h"
|
||||
#include "jinput.h"
|
||||
#include "jdraw.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace menu
|
||||
{
|
||||
void init()
|
||||
{
|
||||
::game::setUpdateTicks(64);
|
||||
|
||||
}
|
||||
|
||||
bool loop()
|
||||
{
|
||||
if (input::keyDown(SDL_SCANCODE_ESCAPE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
draw::cls(2);
|
||||
draw::color(1);
|
||||
|
||||
draw::print2("THE POOL", 16, 3, YELLOW, FONT_ZOOM_VERTICAL);
|
||||
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
source/m_menu.h
Normal file
10
source/m_menu.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
namespace modules
|
||||
{
|
||||
namespace menu
|
||||
{
|
||||
void init();
|
||||
bool loop();
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,12 @@
|
||||
#include "string.h"
|
||||
|
||||
#include "m_game.h"
|
||||
#include "m_menu.h"
|
||||
#include "m_logo.h"
|
||||
|
||||
#define M_LOGO 0
|
||||
#define M_GAME 1
|
||||
#define M_MENU 1
|
||||
#define M_GAME 2
|
||||
int current_module = M_LOGO;
|
||||
|
||||
void game::init()
|
||||
@@ -32,7 +34,10 @@ bool game::loop()
|
||||
switch(current_module)
|
||||
{
|
||||
case M_LOGO:
|
||||
if (!modules::logo::loop()) { modules::game::init(); current_module = M_GAME; }
|
||||
if (!modules::logo::loop()) { modules::menu::init(); current_module = M_MENU; }
|
||||
break;
|
||||
case M_MENU:
|
||||
if (!modules::menu::loop()) { modules::game::init(); current_module = M_GAME; }
|
||||
break;
|
||||
case M_GAME:
|
||||
return modules::game::loop();
|
||||
|
||||
Reference in New Issue
Block a user