- [NEW] Consola in-game
This commit is contained in:
124
source/main.cpp
124
source/main.cpp
@@ -8,6 +8,7 @@
|
||||
#include "editor.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "console.h"
|
||||
|
||||
enum sections { SECTION_GENERAL, SECTION_ROOM, SECTION_ACTOR };
|
||||
|
||||
@@ -31,23 +32,7 @@ int treeview_scroll = 0;
|
||||
void restart()
|
||||
{
|
||||
actor::hero::init();
|
||||
room::load(1); //room_w, room_h, room_xp, room_xn, room_yp, room_yn, room_color, room_floor, room_walls, room_doors, room_walldoors);
|
||||
|
||||
|
||||
/*
|
||||
box = actor::create("ASCENSOR",{16,32,0}, {8,8,4}, {64,0,32,24}, {0,24});
|
||||
box->flags = FLAG_MOVING;
|
||||
box->movement = MOV_Z;
|
||||
box->mov_push = PUSH_ZP;
|
||||
actor::setDirty(box, true);
|
||||
*/
|
||||
|
||||
|
||||
//box = actor::create("HERO", {16,32,8}, {8,8,12}, {0,32,20,32}, {-6,38});
|
||||
//box->flags = FLAG_HERO | FLAG_PUSHABLE | FLAG_GRAVITY | FLAG_ORIENTABLE | FLAG_ANIMATED;
|
||||
//actor::setDirty(box, true);
|
||||
|
||||
//actor::reorder();
|
||||
room::load(1);
|
||||
}
|
||||
|
||||
void game::init()
|
||||
@@ -56,8 +41,10 @@ void game::init()
|
||||
|
||||
if (editor::isDevMode())
|
||||
draw::init("The Pool", 520, 240, 3);
|
||||
else
|
||||
else {
|
||||
draw::init("The Pool", 320, 240, 3);
|
||||
console::init();
|
||||
}
|
||||
|
||||
//room::init();
|
||||
surf = draw::getSurface("test.gif");
|
||||
@@ -82,56 +69,29 @@ void game::init()
|
||||
|
||||
restart();
|
||||
|
||||
/*
|
||||
actor::actor_t *box = actor::create("BOX", {32,32,16}, {8,8,8}, "test.gif", {32,0,32,32}, {0,32});
|
||||
box->flags = FLAG_PUSHABLE | FLAG_GRAVITY;
|
||||
box->movement = MOV_CW;
|
||||
box->mov_push = PUSH_XN;
|
||||
actor::setDirty(box, true);
|
||||
|
||||
box = actor::create("BOX2", {32,32,0}, {8,8,8}, "test.gif", {32,0,32,32}, {0,32});
|
||||
box->flags = FLAG_PUSHABLE | FLAG_GRAVITY;
|
||||
box->movement = MOV_CW;
|
||||
box->mov_push = PUSH_XN;
|
||||
actor::setDirty(box, true);
|
||||
*/
|
||||
actor::select(actor::find("BOX"));
|
||||
}
|
||||
|
||||
int sx=1, sy=0;
|
||||
|
||||
void print(int x, int y, int num)
|
||||
{
|
||||
int digits=0;
|
||||
bool sign = num < 0;
|
||||
num = SDL_abs(num);
|
||||
int n = num;
|
||||
while (n>0) {n=n/10;digits++;}
|
||||
if (sign) digits++;
|
||||
x=x+digits*4;
|
||||
if (num==0) draw::draw(x+4,y,5,7,0,120);
|
||||
while (num>0)
|
||||
{
|
||||
draw::draw(x,y,5,7,(num%10)*5,120);
|
||||
num=num/10;
|
||||
x=x-4;
|
||||
}
|
||||
if (sign) draw::draw(x,y,5,7,50,120);
|
||||
}
|
||||
|
||||
/*const bool btn(const char* label, const int x, const int y, int &var, int min, int max)
|
||||
void print(int x, int y, int num)
|
||||
{
|
||||
char buffer[100];
|
||||
int result=0;
|
||||
draw::print(label, x, y+3, 15, 0);
|
||||
result=ui::button(SDL_itoa(var, buffer, 10), x+50, y, 28, 11, TEAL, LIGHT+TEAL, LIGHT+PURPLE);
|
||||
if (result)
|
||||
int digits=0;
|
||||
bool sign = num < 0;
|
||||
num = SDL_abs(num);
|
||||
int n = num;
|
||||
while (n>0) {n=n/10;digits++;}
|
||||
if (sign) digits++;
|
||||
x=x+digits*4;
|
||||
if (num==0) draw::draw(x+4,y,5,7,0,120);
|
||||
while (num>0)
|
||||
{
|
||||
var=SDL_max(min, SDL_min(max, var-(result-2)));
|
||||
return true;
|
||||
draw::draw(x,y,5,7,(num%10)*5,120);
|
||||
num=num/10;
|
||||
x=x-4;
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
if (sign) draw::draw(x,y,5,7,50,120);
|
||||
}
|
||||
|
||||
const bool btn_small(const int x, const int y, int &var, int min, int max)
|
||||
{
|
||||
@@ -159,26 +119,6 @@ const bool btn_small(const int x, const int y, int &var, int min, int max, int w
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void btn_check(const int x, const int y, const char* label, uint8_t &flags, const uint8_t value)
|
||||
{
|
||||
int result=0;
|
||||
if (flags & value) {
|
||||
result=ui::check(label, x, y, 12, 11, true);
|
||||
} else {
|
||||
result=ui::check(label, x, y, 12, 11, false);
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
if (flags & value) {
|
||||
flags = flags & ~value;
|
||||
} else {
|
||||
flags = flags | value;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
const bool btn_check(const int x, const int y, const char* label, int &flags, const uint16_t value, const int width=24)
|
||||
{
|
||||
int result=0;
|
||||
@@ -349,8 +289,14 @@ void editor_move_selected()
|
||||
|
||||
bool game::loop()
|
||||
{
|
||||
if (input::keyDown(SDL_SCANCODE_ESCAPE)) return false;
|
||||
|
||||
if (input::keyDown(SDL_SCANCODE_ESCAPE))
|
||||
{
|
||||
if (console::isEnabled())
|
||||
console::toggle();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
if (input::keyPressed(SDL_SCANCODE_TAB) || input::keyPressed(SDL_SCANCODE_GRAVE) ) console::toggle();
|
||||
|
||||
// WHILE EDITING...
|
||||
if (editor::isEditing())
|
||||
@@ -360,18 +306,21 @@ bool game::loop()
|
||||
}
|
||||
else
|
||||
{
|
||||
actor::update(actor::getFirst());
|
||||
actor::hero::useBoostGod();
|
||||
if (!console::update())
|
||||
{
|
||||
actor::update(actor::getFirst());
|
||||
actor::hero::useBoostGod();
|
||||
}
|
||||
}
|
||||
|
||||
actor::reorder();
|
||||
if (editor::isEditing()) editor_select_by_keyboard();
|
||||
|
||||
draw::resetViewport();
|
||||
draw::cls(2);
|
||||
|
||||
if (editor::isDevMode()) draw::setViewport(100,0,320,240);
|
||||
|
||||
actor::reorder();
|
||||
if (editor::isEditing()) editor_select_by_keyboard();
|
||||
|
||||
room::draw();
|
||||
actor::draw(actor::getFirst());
|
||||
room::draw2();
|
||||
@@ -407,6 +356,7 @@ bool game::loop()
|
||||
*/
|
||||
if (!editor::isDevMode())
|
||||
{
|
||||
console::draw();
|
||||
draw::render();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user