diff --git a/data/batman.gif b/data/batman.gif index e7e9b3a..742c987 100644 Binary files a/data/batman.gif and b/data/batman.gif differ diff --git a/data/gifs.txt b/data/gifs.txt index f2f9eef..ac16084 100644 --- a/data/gifs.txt +++ b/data/gifs.txt @@ -1,5 +1,6 @@ abad.gif altres.gif +batman.gif caixes.gif doors.gif floor.gif diff --git a/data/rooms/17.txt b/data/rooms/17.txt index d9b5389..ba9b374 100644 --- a/data/rooms/17.txt +++ b/data/rooms/17.txt @@ -1,5 +1,5 @@ -width: 2 -height: 2 +width: 3 +height: 3 door-height-yn: 0 color: CYAN floor-texture: 0 @@ -7,3 +7,96 @@ wall-texture: 0 door-texture: 0 under-door-texture: 0 exit-yn: 9 + +actor{ + name: BLOCMATA + bmp: altres.gif + bmp-rect: 0 133 32 27 + bmp-offset: 0 27 + pos: 16 16 0 + size: 8 8 6 + flags: REACTIVE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CW +} + +actor{ + name: BUBBLE + bmp: altres.gif + bmp-rect: 20 75 28 26 + bmp-offset: -2 28 + pos: 56 56 0 + size: 8 8 8 + flags: PUSHABLE INERTIA + movement: CW +} + +actor{ + name: CONV-XP + bmp: caixes.gif + bmp-rect: 0 128 32 32 + bmp-offset: 0 32 + pos: 0 0 0 + size: 8 8 4 + orient: XP + anim-cycle: MIN + flags: REACTIVE ANIMATED ORIENTABLE + react-mask: ZN + react-push: XP +} + +actor{ + name: GAT-BATMAN + bmp: gat.gif + bmp-rect: 0 0 24 28 + bmp-offset: -4 32 + pos: 48 1 0 + size: 8 8 8 + orient: YN + anim-wait: 1 + flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CW +} + +actor{ + name: SPECTRUM + bmp: caixes.gif + bmp-rect: 128 0 32 32 + bmp-offset: -4 34 + pos: 24 40 8 + size: 8 6 2 + flags: PUSHABLE + movement: CW +} + +actor{ + name: TAULA-A + bmp: caixes.gif + bmp-rect: 128 32 32 32 + bmp-offset: 0 32 + pos: 16 40 0 + size: 8 8 8 + movement: CW +} + +actor{ + name: TAULA-B + bmp: caixes.gif + bmp-rect: 160 32 32 32 + bmp-offset: 0 32 + pos: 24 40 0 + size: 8 8 8 + movement: CW +} + +actor{ + name: TV + bmp: caixes.gif + bmp-rect: 32 64 32 32 + bmp-offset: -4 34 + pos: 16 40 8 + size: 8 6 8 + flags: PUSHABLE + movement: CW +} diff --git a/data/templates.txt b/data/templates.txt index f0581f3..0e3e19f 100644 --- a/data/templates.txt +++ b/data/templates.txt @@ -2,30 +2,6 @@ category{ name: DEFAULT - actor{ - name: BOX - bmp: caixes.gif - bmp-rect: 32 0 32 32 - bmp-offset: 0 32 - pos: 32 32 0 - size: 8 8 8 - flags: PUSHABLE - movement: CW - } - - actor{ - name: BARREL - bmp: caixes.gif - bmp-rect: 96 64 18 32 - bmp-offset: -7 37 - pos: 25 9 0 - size: 6 6 12 - anim-cycle: SEQ - anim-wait: 1 - flags: PUSHABLE ANIMATED GRAVITY - movement: CW - } - actor{ name: NEVERA1 bmp: caixes.gif @@ -106,19 +82,6 @@ category{ movement: CW } - actor{ - name: GAT-NEGRE - bmp: gat.gif - bmp-rect: 0 0 24 28 - bmp-offset: -4 32 - pos: 8 8 0 - size: 8 8 8 - orient: XP - anim-wait: 2 - flags: MOVING ANIMATED ORIENTABLE - movement: CW - } - actor{ name: CUADRO bmp: altres.gif @@ -131,19 +94,6 @@ category{ movement: CW } - actor{ - name: ROOMBA - bmp: caixes.gif - bmp-rect: 160 0 32 32 - bmp-offset: 0 34 - pos: 32 32 0 - size: 8 8 2 - orient: XN - flags: REACTIVE MOVING DEADLY - react-mask: XP XN YP YN ZP ZN - movement: CCW - } - actor{ name: WC bmp: altres.gif @@ -164,6 +114,20 @@ category{ movement: CW } + actor{ + name: CONV-XP + bmp: caixes.gif + bmp-rect: 0 128 32 32 + bmp-offset: 0 32 + pos: 0 0 0 + size: 8 8 4 + orient: XP + anim-cycle: MIN + flags: REACTIVE ANIMATED ORIENTABLE + react-mask: ZN + react-push: XP + } + } category{ @@ -242,6 +206,26 @@ category{ movement: CW } + actor{ + name: TAULA-A + bmp: caixes.gif + bmp-rect: 128 32 32 32 + bmp-offset: 0 32 + pos: 32 40 0 + size: 8 8 8 + movement: CW + } + + actor{ + name: TAULA-B + bmp: caixes.gif + bmp-rect: 160 32 32 32 + bmp-offset: 0 32 + pos: 40 40 0 + size: 8 8 8 + movement: CW + } + } category{ @@ -326,3 +310,189 @@ category{ } } + +category{ + name: MALOTES + + actor{ + name: BLOCMATA + bmp: altres.gif + bmp-rect: 0 133 32 27 + bmp-offset: 0 27 + pos: 16 16 0 + size: 8 8 6 + flags: REACTIVE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CW + } + + actor{ + name: ROOMBA + bmp: caixes.gif + bmp-rect: 160 0 32 32 + bmp-offset: 0 34 + pos: 32 32 0 + size: 8 8 2 + orient: XN + flags: REACTIVE MOVING DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CCW + } + + actor{ + name: GAT-BATMAN + bmp: gat.gif + bmp-rect: 0 0 24 28 + bmp-offset: -4 32 + pos: 32 32 0 + size: 8 8 8 + orient: XP + anim-wait: 1 + flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CW + } + + actor{ + name: GAT-ROBIN + bmp: gat2.gif + bmp-rect: 0 0 24 28 + bmp-offset: -4 32 + pos: 32 32 0 + size: 8 8 8 + orient: XP + anim-wait: 1 + flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CW + } + + actor{ + name: ABAD + bmp: abad.gif + bmp-rect: 0 0 20 33 + bmp-offset: -6 38 + pos: 0 0 0 + size: 8 8 8 + orient: XP + anim-wait: 1 + flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CCW + } + + actor{ + name: BATMAN + bmp: batman.gif + bmp-rect: 0 0 21 32 + bmp-offset: -5 35 + pos: 0 0 0 + size: 8 8 8 + orient: YP + anim-wait: 1 + flags: REACTIVE MOVING ANIMATED ORIENTABLE DEADLY + react-mask: XP XN YP YN ZP ZN + movement: CCW + } + +} + +category{ + name: MISC + + actor{ + name: BARREL + bmp: caixes.gif + bmp-rect: 96 64 18 32 + bmp-offset: -7 37 + pos: 25 9 0 + size: 6 6 12 + anim-cycle: SEQ + anim-wait: 1 + flags: PUSHABLE ANIMATED GRAVITY + movement: CW + } + + actor{ + name: BUBBLE + bmp: altres.gif + bmp-rect: 20 75 28 26 + bmp-offset: -2 28 + pos: 48 32 0 + size: 8 8 8 + flags: PUSHABLE INERTIA + movement: CW + } + +} + +category{ + name: CAIXES + + actor{ + name: BOX-A + bmp: caixes.gif + bmp-rect: 0 0 32 32 + bmp-offset: 0 32 + pos: 32 32 0 + size: 8 8 8 + flags: PUSHABLE + movement: CW + } + + actor{ + name: BOX-B + bmp: caixes.gif + bmp-rect: 32 0 32 32 + bmp-offset: 0 32 + pos: 32 32 0 + size: 8 8 8 + flags: PUSHABLE + movement: CW + } + + actor{ + name: BOX-C + bmp: caixes.gif + bmp-rect: 64 0 32 32 + bmp-offset: 0 32 + pos: 32 32 0 + size: 8 8 8 + flags: PUSHABLE + movement: CW + } + + actor{ + name: NES + bmp: caixes.gif + bmp-rect: 96 0 32 32 + bmp-offset: -2 33 + pos: 0 0 0 + size: 8 7 6 + flags: PUSHABLE + movement: CW + } + + actor{ + name: SPECTRUM + bmp: caixes.gif + bmp-rect: 128 0 32 32 + bmp-offset: -4 34 + pos: 0 0 0 + size: 8 6 2 + flags: PUSHABLE + movement: CW + } + + actor{ + name: TV + bmp: caixes.gif + bmp-rect: 32 64 32 32 + bmp-offset: -4 34 + pos: 0 0 0 + size: 8 6 8 + flags: PUSHABLE + movement: CW + } + +} diff --git a/data/test.gif b/data/test.gif index ed7b382..f968fbe 100644 Binary files a/data/test.gif and b/data/test.gif differ diff --git a/source/actor.cpp b/source/actor.cpp index 4160a8b..32cb974 100644 --- a/source/actor.cpp +++ b/source/actor.cpp @@ -26,6 +26,7 @@ namespace actor draw::surface *brilli; int current_tag = 0; + bool floating_editing = false; void resetTag() { @@ -96,7 +97,7 @@ namespace actor { actor_t *new_act = createEmptyActor(); actor::templates::copy(new_act, act); - new_act->surface = draw::getSurface(new_act->bmp); + //new_act->surface = draw::getSurface(new_act->bmp); new_act->prev = new_act->next = new_act->above = new_act->below = nullptr; return new_act; } @@ -997,7 +998,7 @@ namespace actor // ...i encara està baix... if (is_above(act, act->below)) { // ...li pase a ell el push, neteje el meu flag, canvie direcció si pertoca i me ane - act->below->push |= push(act, act->below, PUSH_ZN); + act->push |= push(act, act->below, PUSH_ZN); // [RZC 20/09/2024] Canvie "act->below->push" per "act->push". Se li deu passar la reacció al que la inicia act->push &= ~PUSH_ZN; if ( (act->flags & FLAG_MOVING) && (act->movement==MOV_Z) ) changeMoving(act); return; @@ -1017,7 +1018,7 @@ namespace actor act->below = below; below->above = act; // ... i li passem el push, netejem el meu flag i gonnem - act->below->push |= push(act, act->below, PUSH_ZN); + act->push |= push(act, act->below, PUSH_ZN); // [RZC 20/09/2024] Canvie "act->below->push" per "act->push". Se li deu passar la reacció al que la inicia act->push &= ~PUSH_ZN; if ( (act->flags & FLAG_MOVING) && (act->movement==MOV_Z) ) changeMoving(act); return; @@ -1317,6 +1318,15 @@ namespace actor selected = nullptr; } + void setFloatingEditing(const bool value) + { + floating_editing = value; + } + + const bool getFloatingEditing() + { + return floating_editing; + } namespace templates { std::vector templates; @@ -1447,6 +1457,7 @@ namespace actor dest->react_push = source->react_push; dest->movement = source->movement; dest->template_category = source->template_category; + dest->surface = source->surface; } void add(actor_t *act) @@ -1454,8 +1465,7 @@ namespace actor // Fem una copia del actor actor_t new_template; copy(&new_template, act); - // Li fiquem la categoria per defecte - new_template.template_category = 0; + // Netejem el nom de numerets cleanName(&new_template); @@ -1464,9 +1474,11 @@ namespace actor { // ... la actualitzem amb les dades del actor seleccionat actor_t *existing_template = actor::templates::getByName(act->name); + new_template.template_category = existing_template->template_category; // Li fiquem la categoria que tenia abans copy(existing_template, &new_template); } else { // ... i sinó, afegim el actor seleccionat a la llista de plantilles + new_template.template_category = 0; // Li fiquem la categoria per defecte templates.push_back(new_template); } save(); diff --git a/source/actor.h b/source/actor.h index cde53b5..65a42cc 100644 --- a/source/actor.h +++ b/source/actor.h @@ -173,6 +173,10 @@ namespace actor void clear(const bool all = false); + void setFloatingEditing(const bool value); + + const bool getFloatingEditing(); + namespace templates { void load(); diff --git a/source/m_editor_bitmap.cpp b/source/m_editor_bitmap.cpp index e4d4f80..9276adf 100644 --- a/source/m_editor_bitmap.cpp +++ b/source/m_editor_bitmap.cpp @@ -56,6 +56,8 @@ namespace modules sel->bmp_rect.h += dy; } } + } else { + lastMB = false; } const int tx = (520-surf->w)/2; const int ty = (240-surf->h)/2; diff --git a/source/m_editor_bitmap_file.cpp b/source/m_editor_bitmap_file.cpp index 442c200..a5471f4 100644 --- a/source/m_editor_bitmap_file.cpp +++ b/source/m_editor_bitmap_file.cpp @@ -10,7 +10,7 @@ namespace modules { namespace editor_bitmap_file { - std::vector gifs = { "abad.gif", "altres.gif", "caixes.gif", "gat.gif", "gat2.gif", "objectes.gif", "obrer.gif" }; + std::vector gifs = { "abad.gif", "batman.gif", "altres.gif", "caixes.gif", "gat.gif", "gat2.gif", "objectes.gif", "obrer.gif" }; void init() { diff --git a/source/m_editor_templates.cpp b/source/m_editor_templates.cpp index b86aeea..ba947f7 100644 --- a/source/m_editor_templates.cpp +++ b/source/m_editor_templates.cpp @@ -61,7 +61,7 @@ namespace modules bool loop() { - if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB)) return false; + if (input::keyPressed(SDL_SCANCODE_ESCAPE) || input::keyPressed(SDL_SCANCODE_TAB) || input::keyPressed(SDL_SCANCODE_GRAVE)) return false; if (edit_mode == EDITING_NORMAL) { @@ -144,6 +144,7 @@ namespace modules actor::setUniqueName(new_act); actor::setDirty(new_act, true); actor::select(new_act); + actor::setFloatingEditing(true); room::editor::modify(); return false; diff --git a/source/m_game.cpp b/source/m_game.cpp index 97cd996..1bc7e11 100644 --- a/source/m_game.cpp +++ b/source/m_game.cpp @@ -19,6 +19,8 @@ namespace modules std::vector getGifs() { return gifs; } + vec2_t floating_position = {3,3}; + void init() { actor::clear(true); @@ -295,6 +297,31 @@ namespace modules if (editor::isDevMode()) draw::setViewport(100,0,320,240); room::draw(); + + actor::actor_t *selected = actor::getSelected(); + if (editor::isDevMode() && selected && input::keyPressed(SDL_SCANCODE_M)) actor::setFloatingEditing(true); + + if (editor::isDevMode() && actor::getFloatingEditing() && selected) { + draw::swapcol(1, GREEN+LIGHT); + draw::setSource(draw::getSurface("test.gif")); + const float px = draw::getLocalX(input::mouseX())-148-16; + const float py = draw::getLocalY(input::mouseY())-75; + const int x = int(py/16.0f + px/32.0f); + const int y = int(py/16.0f - px/32.0f); + + //draw::print2(x, -3, 1, 6, PURPLE, FONT_ZOOM_NONE); + //draw::print2(y, -3, 1, 7, PURPLE, FONT_ZOOM_NONE); + + if (x>=room::getTMin().x && y>=room::getTMin().y && xpos.x = floating_position.x*8; + selected->pos.y = floating_position.y*8; + } + draw::draw(148+floating_position.x*16-floating_position.y*16,75+floating_position.x*8+floating_position.y*8,32,16,160,0); + if (input::mouseClk(1)) actor::setFloatingEditing(false); + } + draw::stencil::enable(); draw::stencil::clear(255); actor::draw(actor::getFirst()); @@ -303,7 +330,8 @@ namespace modules draw::swapcol(1, WHITE+LIGHT); actor::draw(actor::getPicked(), false); - if (editor::isDevMode() && input::mouseBtn(1)) + // Si estem en el editor, fent click en els actors els seleccionem + if (editor::isDevMode() && input::mouseBtn(1) && !actor::getFloatingEditing()) { const uint8_t val = draw::stencil::query(input::mouseX(), input::mouseY()); if (val != 255) @@ -313,6 +341,7 @@ namespace modules } } + // Si estem jugant, o estem en el editor pero NO en mode edició, pinta els marcadors if (!editor::isEditing()) { const int col1 = room::getColor(1); @@ -350,6 +379,7 @@ namespace modules draw::stencil::disable(); + // Si estem en el editor, fent click en els skills del marcador els obtenim if (editor::isDevMode() && input::mouseClk(1)) { const uint8_t val = draw::stencil::query(input::mouseX(), input::mouseY()); @@ -364,6 +394,8 @@ namespace modules } } } + + /* print(0,0,input::mouseX()); print(0,20,input::mouseY()); @@ -371,6 +403,8 @@ namespace modules print(0,40,input::mouseBtn(2)?1:0); print(0,50,input::mouseBtn(3)?1:0); */ + + // Si no estem en el editor, pintem la consola (si es el cas), renderitzem i eixim if (!editor::isDevMode()) { console::draw(); @@ -378,6 +412,7 @@ namespace modules return GAME_NONE; } + // Si estem en el editor, pintem els numerets de les eixides draw::print2(room::getExit(XN), -2, 1, 1, TEAL, FONT_ZOOM_NONE); draw::print2(room::getExit(YN), -2, 38, 1, TEAL, FONT_ZOOM_NONE); draw::print2(room::getExit(XP), -2, 38, 28, TEAL, FONT_ZOOM_NONE); @@ -385,8 +420,11 @@ namespace modules draw::print2(room::getExit(ZP), -2, 19, 1, TEAL, FONT_ZOOM_NONE); draw::print2(room::getExit(ZN), -2, 19, 28, TEAL, FONT_ZOOM_NONE); + // ...i l'habitació actual draw::print2(room::getCurrent(), -2, 4, 3, WHITE, FONT_ZOOM_BOTH); + // ...i fent click en els numerets de les eixides anem a l'habitació corresponent + // Es més. Si no hi ha habitació enllaçada en una eixida i li fem ctrl+click, se crea una nova habitació per eixa eixida if (input::mouseClk(1)) { const int mx = draw::getLocalX(input::mouseX()); const int my = draw::getLocalY(input::mouseY()); @@ -419,6 +457,8 @@ namespace modules } } + // Pintem tota la UI del editor + // ================================================================================ ui::start(); actor::actor_t *act = nullptr; diff --git a/source/room.cpp b/source/room.cpp index 7525c00..3111470 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -466,6 +466,16 @@ namespace room return max; } + vec3_t getTMin() + { + return tmin; + } + + vec3_t getTMax() + { + return tmax; + } + int getDoors() { return doors; diff --git a/source/room.h b/source/room.h index db7be7e..0ae1380 100644 --- a/source/room.h +++ b/source/room.h @@ -32,6 +32,8 @@ namespace room vec3_t getSize(); vec3_t getMin(); vec3_t getMax(); + vec3_t getTMin(); + vec3_t getTMax(); int getDoors(); int getDoor(const int d); int getExit(const int d);