- [FIX] Per a crear noves habitacions descartar clicks fora del canvas
- [FIX] Nomes crear nova habitació si s'està pulsant LCTRL - [NEW] Minimapa en l'editor
This commit is contained in:
@@ -8,6 +8,7 @@ font2.gif
|
|||||||
gat.gif
|
gat.gif
|
||||||
gat2.gif
|
gat2.gif
|
||||||
jailgames.gif
|
jailgames.gif
|
||||||
|
mapa.gif
|
||||||
objectes.gif
|
objectes.gif
|
||||||
obrer.gif
|
obrer.gif
|
||||||
roomaux.gif
|
roomaux.gif
|
||||||
|
|||||||
BIN
data/mapa.gif
Normal file
BIN
data/mapa.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 614 B |
@@ -1,14 +1,12 @@
|
|||||||
width: 3
|
width: 3
|
||||||
height: 1
|
height: 1
|
||||||
door-height-xp: 0
|
door-height-xp: 0
|
||||||
door-height-xn: 0
|
|
||||||
color: CYAN
|
color: CYAN
|
||||||
floor-texture: 0
|
floor-texture: 0
|
||||||
wall-texture: 2
|
wall-texture: 2
|
||||||
door-texture: 0
|
door-texture: 0
|
||||||
under-door-texture: 0
|
under-door-texture: 0
|
||||||
exit-xp: 1
|
exit-xp: 1
|
||||||
exit-xn: 4
|
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: MESITA
|
name: MESITA
|
||||||
@@ -20,36 +18,6 @@ actor{
|
|||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|
||||||
actor{
|
|
||||||
name: LLIT
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 48 0 57 47
|
|
||||||
bmp-offset: 11 32
|
|
||||||
pos: 8 16 0
|
|
||||||
size: 16 16 4
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: MESITA01
|
|
||||||
bmp: caixes.gif
|
|
||||||
bmp-rect: 0 64 32 32
|
|
||||||
bmp-offset: 0 32
|
|
||||||
pos: 24 16 0
|
|
||||||
size: 8 8 4
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
|
||||||
name: MANCUERNA
|
|
||||||
bmp: altres.gif
|
|
||||||
bmp-rect: 106 33 17 14
|
|
||||||
bmp-offset: -6 20
|
|
||||||
pos: 24 25 0
|
|
||||||
size: 6 4 2
|
|
||||||
movement: CW
|
|
||||||
}
|
|
||||||
|
|
||||||
actor{
|
actor{
|
||||||
name: FINESTRA01
|
name: FINESTRA01
|
||||||
bmp: altres.gif
|
bmp: altres.gif
|
||||||
@@ -79,3 +47,33 @@ actor{
|
|||||||
size: 6 6 16
|
size: 6 6 16
|
||||||
movement: CW
|
movement: CW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: LLIT
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 48 0 57 47
|
||||||
|
bmp-offset: 11 32
|
||||||
|
pos: 8 16 0
|
||||||
|
size: 16 16 4
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: MESITA01
|
||||||
|
bmp: caixes.gif
|
||||||
|
bmp-rect: 0 64 32 32
|
||||||
|
bmp-offset: 0 32
|
||||||
|
pos: 24 16 0
|
||||||
|
size: 8 8 4
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|
||||||
|
actor{
|
||||||
|
name: MANCUERNA
|
||||||
|
bmp: altres.gif
|
||||||
|
bmp-rect: 106 33 17 14
|
||||||
|
bmp-offset: -6 20
|
||||||
|
pos: 24 25 0
|
||||||
|
size: 6 4 2
|
||||||
|
movement: CW
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
width: 2
|
width: 3
|
||||||
height: 2
|
height: 2
|
||||||
door-height-xn: 0
|
door-height-xn: 0
|
||||||
door-height-yn: 0
|
door-height-yn: 0
|
||||||
color: CYAN
|
color: GREEN
|
||||||
floor-texture: 0
|
floor-texture: 0
|
||||||
wall-texture: 0
|
wall-texture: 0
|
||||||
door-texture: 0
|
door-texture: 0
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
width: 2
|
width: 2
|
||||||
height: 2
|
height: 3
|
||||||
door-height-xn: 0
|
door-height-xn: 0
|
||||||
door-height-yp: 0
|
door-height-yp: 0
|
||||||
color: CYAN
|
color: CYAN
|
||||||
@@ -7,5 +7,5 @@ floor-texture: 0
|
|||||||
wall-texture: 0
|
wall-texture: 0
|
||||||
door-texture: 0
|
door-texture: 0
|
||||||
under-door-texture: 0
|
under-door-texture: 0
|
||||||
exit-xn: 5
|
exit-xn: 4
|
||||||
exit-yp: 2
|
exit-yp: 2
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
width: 2
|
width: 2
|
||||||
height: 2
|
height: 2
|
||||||
door-height-xp: 0
|
door-height-xp: 0
|
||||||
|
door-height-xn: 0
|
||||||
color: CYAN
|
color: CYAN
|
||||||
floor-texture: 0
|
floor-texture: 0
|
||||||
wall-texture: 0
|
wall-texture: 0
|
||||||
door-texture: 0
|
door-texture: 0
|
||||||
under-door-texture: 0
|
under-door-texture: 0
|
||||||
exit-xp: 0
|
exit-xp: 3
|
||||||
|
exit-xn: 5
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
width: 2
|
width: 2
|
||||||
height: 2
|
height: 2
|
||||||
door-height-xp: 0
|
door-height-xp: 0
|
||||||
door-height-xn: 0
|
|
||||||
color: CYAN
|
color: CYAN
|
||||||
floor-texture: 0
|
floor-texture: 0
|
||||||
wall-texture: 0
|
wall-texture: 0
|
||||||
door-texture: 0
|
door-texture: 0
|
||||||
under-door-texture: 0
|
under-door-texture: 0
|
||||||
exit-xp: 3
|
exit-xp: 4
|
||||||
exit-xn: 6
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
width: 2
|
|
||||||
height: 2
|
|
||||||
door-height-xp: 0
|
|
||||||
color: CYAN
|
|
||||||
floor-texture: 0
|
|
||||||
wall-texture: 0
|
|
||||||
door-texture: 0
|
|
||||||
under-door-texture: 0
|
|
||||||
exit-xp: 5
|
|
||||||
109
source/m_editor_map.cpp
Normal file
109
source/m_editor_map.cpp
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
#include "m_editor_map.h"
|
||||||
|
#include "jdraw.h"
|
||||||
|
#include "jinput.h"
|
||||||
|
#include "misc.h"
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include "room.h"
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace editor_map
|
||||||
|
{
|
||||||
|
draw::surface *surf;
|
||||||
|
vec2_t scroll {0,0};
|
||||||
|
bool drawn[64];
|
||||||
|
int current_room;
|
||||||
|
|
||||||
|
struct miniroom_t
|
||||||
|
{
|
||||||
|
uint8_t w;
|
||||||
|
uint8_t h;
|
||||||
|
uint8_t color;
|
||||||
|
uint8_t exits[6];
|
||||||
|
};
|
||||||
|
miniroom_t minirooms[64];
|
||||||
|
|
||||||
|
void loadMiniRoom()
|
||||||
|
{
|
||||||
|
const int room = room::getCurrent();
|
||||||
|
if (drawn[room]) return;
|
||||||
|
drawn[room] = true;
|
||||||
|
|
||||||
|
minirooms[room].color = room::getColor(0);
|
||||||
|
minirooms[room].w = (room::getSize().x >> 1)-1;
|
||||||
|
minirooms[room].h = (room::getSize().y >> 1)-1;
|
||||||
|
for (int i=0; i<ZN; ++i) minirooms[room].exits[i] = room::getExit(i);
|
||||||
|
|
||||||
|
for (int i=0; i<ZN; ++i) {
|
||||||
|
const int next_room = minirooms[room].exits[i];
|
||||||
|
if ( (next_room >= 0) && (next_room <= 64) && (!drawn[next_room]) ) {
|
||||||
|
room::load(next_room);
|
||||||
|
loadMiniRoom();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
surf = draw::getSurface("mapa.gif");
|
||||||
|
scroll = {260,120};
|
||||||
|
draw::resetViewport();
|
||||||
|
for (int i=0;i<64;++i) drawn[i]=false;
|
||||||
|
|
||||||
|
current_room = room::getCurrent();
|
||||||
|
loadMiniRoom();
|
||||||
|
room::load(current_room);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawRoom(const int room, const int x, const int y)
|
||||||
|
{
|
||||||
|
if (drawn[room]) return;
|
||||||
|
drawn[room] = true;
|
||||||
|
if ( (x>=-32) && (x<520) && (y>=-16) && (y<240) )
|
||||||
|
{
|
||||||
|
draw::stencil::set(room);
|
||||||
|
draw::swapcol(1, minirooms[room].color);
|
||||||
|
draw::draw(x-16, y-8, 32, 16, minirooms[room].w*32, minirooms[room].h*16);
|
||||||
|
|
||||||
|
draw::swapcol(1, RED);
|
||||||
|
if (minirooms[room].exits[XN] != 255) draw::draw(x-4-(minirooms[room].w*2), y-5-(minirooms[room].w),4,5,0,64);
|
||||||
|
if (minirooms[room].exits[YN] != 255) draw::draw(x+(minirooms[room].h*2), y-5-(minirooms[room].h),4,5,3,64);
|
||||||
|
if (minirooms[room].exits[XP] != 255) draw::draw(x+(minirooms[room].w*2), y-3+(minirooms[room].w),4,5,0,64);
|
||||||
|
if (minirooms[room].exits[YP] != 255) draw::draw(x-4-(minirooms[room].h*2), y-3+(minirooms[room].h),4,5,3,64);
|
||||||
|
|
||||||
|
char num[] = "00"; num[0] = 48+(room/10); num[1] = 48+(room%10);
|
||||||
|
draw::print(num, x-4, y-3, LIGHT+(room==current_room?YELLOW:WHITE), BLACK);
|
||||||
|
}
|
||||||
|
if (minirooms[room].exits[XN] != 255) drawRoom(minirooms[room].exits[XN], x-24, y-12);
|
||||||
|
if (minirooms[room].exits[XP] != 255) drawRoom(minirooms[room].exits[XP], x+24, y+12);
|
||||||
|
if (minirooms[room].exits[YN] != 255) drawRoom(minirooms[room].exits[YN], x+24, y-12);
|
||||||
|
if (minirooms[room].exits[YP] != 255) drawRoom(minirooms[room].exits[YP], x-24, y+12);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loop()
|
||||||
|
{
|
||||||
|
for (int i=0;i<64;++i) drawn[i]=false;
|
||||||
|
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB)) return false;
|
||||||
|
|
||||||
|
draw::cls(2);
|
||||||
|
draw::setSource(surf);
|
||||||
|
|
||||||
|
draw::stencil::enable();
|
||||||
|
draw::stencil::clear(255);
|
||||||
|
|
||||||
|
drawRoom(room::getCurrent(), scroll.x, scroll.y);
|
||||||
|
draw::render();
|
||||||
|
|
||||||
|
if (input::mouseClk(1)) {
|
||||||
|
const int clicked = draw::stencil::query(input::mouseX(), input::mouseY());
|
||||||
|
if (clicked!=255) {
|
||||||
|
room::load(clicked);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
10
source/m_editor_map.h
Normal file
10
source/m_editor_map.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace modules
|
||||||
|
{
|
||||||
|
namespace editor_map
|
||||||
|
{
|
||||||
|
void init();
|
||||||
|
bool loop();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -265,16 +265,19 @@ namespace modules
|
|||||||
else
|
else
|
||||||
return GAME_MENU;
|
return GAME_MENU;
|
||||||
}
|
}
|
||||||
if (input::keyPressed(SDL_SCANCODE_TAB) || input::keyPressed(SDL_SCANCODE_GRAVE) ) console::toggle();
|
|
||||||
|
|
||||||
// WHILE EDITING...
|
// WHILE EDITING...
|
||||||
if (editor::isEditing())
|
if (editor::isEditing())
|
||||||
{
|
{
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_TAB)) return GAME_EDITOR_MAP;
|
||||||
|
|
||||||
editor_move_selected();
|
editor_move_selected();
|
||||||
actor::updateEditor(actor::getFirst());
|
actor::updateEditor(actor::getFirst());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (input::keyPressed(SDL_SCANCODE_TAB) || input::keyPressed(SDL_SCANCODE_GRAVE) ) console::toggle();
|
||||||
|
|
||||||
if (!console::update())
|
if (!console::update())
|
||||||
{
|
{
|
||||||
actor::update(actor::getFirst());
|
actor::update(actor::getFirst());
|
||||||
@@ -387,12 +390,32 @@ namespace modules
|
|||||||
if (input::mouseClk(1)) {
|
if (input::mouseClk(1)) {
|
||||||
const int mx = draw::getLocalX(input::mouseX());
|
const int mx = draw::getLocalX(input::mouseX());
|
||||||
const int my = draw::getLocalY(input::mouseY());
|
const int my = draw::getLocalY(input::mouseY());
|
||||||
if (mx<32 && my<24) room::load(room::editor::refExit(XN), XP);
|
if (mx>=0 && my>=0 && mx<320 && my<240) {
|
||||||
if (mx>288 && my<24) room::load(room::editor::refExit(YN), YP);
|
if (mx<32 && my<24) {
|
||||||
if (mx>288 && my>216) room::load(room::editor::refExit(XP), XN);
|
int room = room::editor::refExit(XN);
|
||||||
if (mx<32 && my>216) room::load(room::editor::refExit(YP), YN);
|
if (room>=0 || input::keyPressed(SDL_SCANCODE_LCTRL)) room::load(room, XP);
|
||||||
if (mx>144 && mx<176 && my<24) room::load(room::editor::refExit(ZP), ZN);
|
}
|
||||||
if (mx>144 && mx<176 && my>216) room::load(room::editor::refExit(ZN), ZP);
|
if (mx>288 && my<24) {
|
||||||
|
int room = room::editor::refExit(YN);
|
||||||
|
if (room>=0 || input::keyPressed(SDL_SCANCODE_LCTRL)) room::load(room, YP);
|
||||||
|
}
|
||||||
|
if (mx>288 && my>216) {
|
||||||
|
int room = room::editor::refExit(XP);
|
||||||
|
if (room>=0 || input::keyPressed(SDL_SCANCODE_LCTRL)) room::load(room, XN);
|
||||||
|
}
|
||||||
|
if (mx<32 && my>216) {
|
||||||
|
int room = room::editor::refExit(YP);
|
||||||
|
if (room>=0 || input::keyPressed(SDL_SCANCODE_LCTRL)) room::load(room, YN);
|
||||||
|
}
|
||||||
|
if (mx>144 && mx<176 && my<24) {
|
||||||
|
int room = room::editor::refExit(ZP);
|
||||||
|
if (room>=0 || input::keyPressed(SDL_SCANCODE_LCTRL)) room::load(room, ZN);
|
||||||
|
}
|
||||||
|
if (mx>144 && mx<176 && my>216) {
|
||||||
|
int room = room::editor::refExit(ZN);
|
||||||
|
if (room>=0 || input::keyPressed(SDL_SCANCODE_LCTRL)) room::load(room, ZP);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ui::start();
|
ui::start();
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace modules
|
|||||||
#define GAME_NONE -1
|
#define GAME_NONE -1
|
||||||
#define GAME_MENU 0
|
#define GAME_MENU 0
|
||||||
#define GAME_DEAD 1
|
#define GAME_DEAD 1
|
||||||
|
#define GAME_EDITOR_MAP 2
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
int loop();
|
int loop();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
#include "m_catslife.h"
|
#include "m_catslife.h"
|
||||||
#include "m_menu_tecles.h"
|
#include "m_menu_tecles.h"
|
||||||
#include "m_menu_audio.h"
|
#include "m_menu_audio.h"
|
||||||
|
#include "m_editor_map.h"
|
||||||
|
|
||||||
#define M_LOGO 0
|
#define M_LOGO 0
|
||||||
#define M_MENU 1
|
#define M_MENU 1
|
||||||
@@ -28,6 +29,8 @@
|
|||||||
#define M_CATSLIFE 5
|
#define M_CATSLIFE 5
|
||||||
#define M_MENU_TECLES 6
|
#define M_MENU_TECLES 6
|
||||||
#define M_MENU_AUDIO 7
|
#define M_MENU_AUDIO 7
|
||||||
|
#define M_EDITOR_MAP 8
|
||||||
|
#define M_EDITOR_TEMPLATES 9
|
||||||
|
|
||||||
int current_module = M_LOGO;
|
int current_module = M_LOGO;
|
||||||
int zoom = 3;
|
int zoom = 3;
|
||||||
@@ -134,9 +137,16 @@ bool game::loop()
|
|||||||
} else {
|
} else {
|
||||||
modules::gameover::init(); current_module = M_GAMEOVER;
|
modules::gameover::init(); current_module = M_GAMEOVER;
|
||||||
}
|
}
|
||||||
|
} else if (option==GAME_EDITOR_MAP) {
|
||||||
|
modules::editor_map::init(); current_module = M_EDITOR_MAP;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case M_EDITOR_MAP:
|
||||||
|
if (!modules::editor_map::loop()) {
|
||||||
|
current_module = M_GAME;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case M_INGAME:
|
case M_INGAME:
|
||||||
option = modules::ingame::loop();
|
option = modules::ingame::loop();
|
||||||
if (option != INGAME_NONE) {
|
if (option != INGAME_NONE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user