- Treballant en les portes

This commit is contained in:
2023-03-10 18:57:04 +01:00
parent 2ef01a14d9
commit 5a089b3333
3 changed files with 90 additions and 6 deletions

View File

@@ -161,15 +161,49 @@ namespace actor
vec3_t max = room::getMax(); vec3_t max = room::getMax();
bool moving = false; bool moving = false;
if (input::keyDown(SDL_SCANCODE_LEFT) && act->pos.x>min.x) { act->push |= PUSH_XN; act->orient=PUSH_XN; moving = true; } if ( input::keyDown(SDL_SCANCODE_LEFT) )
if (input::keyDown(SDL_SCANCODE_RIGHT) && act->pos.x<max.x) { act->push |= PUSH_XP; act->orient=PUSH_XP; moving = true; } {
if (input::keyDown(SDL_SCANCODE_UP) && act->pos.y>min.y) { act->push |= PUSH_YN; act->orient=PUSH_YN; moving = true; } act->orient=PUSH_XN;
if (input::keyDown(SDL_SCANCODE_DOWN) && act->pos.y<max.y) { act->push |= PUSH_YP; act->orient=PUSH_YP; moving = true; } if (act->pos.x>min.x)
if (input::keyDown(SDL_SCANCODE_SPACE) && act->react_mask==0 && (act->pos.z==0 || act->below)) { {
act->push |= PUSH_XN;
moving = true;
}
}
if ( input::keyDown(SDL_SCANCODE_RIGHT) )
{
act->orient=PUSH_XP;
if (act->pos.x<max.x)
{
act->push |= PUSH_XP;
moving = true;
}
}
if ( input::keyDown(SDL_SCANCODE_UP) )
{
act->orient=PUSH_YN;
if (act->pos.y>min.y)
{
act->push |= PUSH_YN;
moving = true;
}
}
if ( input::keyDown(SDL_SCANCODE_DOWN) )
{
act->orient=PUSH_YP;
if (act->pos.y<max.y)
{
act->push |= PUSH_YP;
moving = true;
}
}
if ( input::keyDown(SDL_SCANCODE_SPACE) && act->react_mask==0 && (act->pos.z==0 || act->below))
{
act->react_mask=1; act->react_mask=1;
act->react_push=0; act->react_push=0;
act->flags &= uint8_t(~FLAG_GRAVITY); act->flags &= uint8_t(~FLAG_GRAVITY);
if (act->below) { if (act->below)
{
act->below->above = nullptr; act->below->above = nullptr;
act->below = nullptr; act->below = nullptr;
} }

View File

@@ -9,6 +9,8 @@ namespace room
static vec3_t min = {0,0,0}; static vec3_t min = {0,0,0};
static vec3_t max = {56,56,56}; static vec3_t max = {56,56,56};
static uint8_t doors = DOOR_YP;
void load(int x, int y) void load(int x, int y)
{ {
size = {(x+1)*2,(y+1)*2,3}; size = {(x+1)*2,(y+1)*2,3};
@@ -20,13 +22,56 @@ namespace room
void draw() void draw()
{ {
if (doors & DOOR_YN)
{
draw::draw(164+4*16-(tmin.y-1)*16,84+4*8+(tmin.y-1)*8,16,15,144,49);
draw::draw(148+3*16-(tmin.y-1)*16,76+3*8+(tmin.y-1)*8,32,15,0,1);
draw::draw(148+4*16-(tmin.y-1)*16,76+4*8+(tmin.y-1)*8,32,15,0,1);
draw::draw(164+3*16-tmin.y*16,32+3*8+tmin.y*8,16,47,18,133);
draw::draw(164+4*16-tmin.y*16,28+4*8+tmin.y*8,24,55,34,137);
}
if (doors & DOOR_XN)
{
draw::draw(148+(tmin.x-1)*16-3*16,76+(tmin.x-1)*8+3*8,32,15,0,1);
draw::draw(148+(tmin.x-1)*16-4*16,76+(tmin.x-1)*8+4*8,32,15,0,1);
}
for (int x=tmin.x;x<=tmax.x;++x)
{
if ( !(doors & DOOR_YP) || (x!=3 && x!=4) ) draw::draw(148+x*16-tmax.y*16,84+x*8+tmax.y*8,16,15,128,49);
if ( !(doors & DOOR_YN) || (x!=3 && x!=4) ) draw::draw(164+x*16-tmin.y*16,36+x*8+tmin.y*8,16,48,128,16);
}
for (int y=tmin.y;y<=tmax.y;++y) for (int y=tmin.y;y<=tmax.y;++y)
{ {
if ( !(doors & DOOR_XP) || (y!=3 && y!=4) ) draw::draw(164+tmax.x*16-y*16,84+tmax.x*8+y*8,16,15,144,49);
if ( !(doors & DOOR_XN) || (y!=3 && y!=4) ) draw::draw(148+tmin.x*16-y*16,36+tmin.x*8+y*8,16,48,144,16);
for (int x=tmin.x;x<=tmax.x;++x) for (int x=tmin.x;x<=tmax.x;++x)
{ {
draw::draw(148+x*16-y*16,76+x*8+y*8,32,15,0,1); draw::draw(148+x*16-y*16,76+x*8+y*8,32,15,0,1);
} }
} }
if (doors & DOOR_YP)
{
draw::draw(164+4*16-(tmax.y+1)*16,84+4*8+(tmax.y+1)*8,16,15,144,49);
draw::draw(148+3*16-(tmax.y+1)*16,84+3*8+(tmax.y+1)*8,16,15,128,49);
draw::draw(148+4*16-(tmax.y+1)*16,84+4*8+(tmax.y+1)*8,16,15,128,49);
draw::draw(148+3*16-(tmax.y+1)*16,76+3*8+(tmax.y+1)*8,32,15,0,1);
draw::draw(148+4*16-(tmax.y+1)*16,76+4*8+(tmax.y+1)*8,32,15,0,1);
draw::draw(164+3*16-8-(tmax.y+1)*16,32+3*8+4+(tmax.y+1)*8,16,47,18,133);
draw::draw(164+4*16-8-(tmax.y+1)*16,28+4*8+4+(tmax.y+1)*8,24,55,34,137);
}
if (doors & DOOR_XP)
{
draw::draw(148+(tmax.x+1)*16-4*16,84+(tmax.x+1)*8+4*8,16,15,128,49);
draw::draw(164+(tmax.x+1)*16-3*16,84+(tmax.x+1)*8+3*8,16,15,144,49);
draw::draw(164+(tmax.x+1)*16-4*16,84+(tmax.x+1)*8+4*8,16,15,144,49);
draw::draw(148+(tmax.x+1)*16-3*16,76+(tmax.x+1)*8+3*8,32,15,0,1);
draw::draw(148+(tmax.x+1)*16-4*16,76+(tmax.x+1)*8+4*8,32,15,0,1);
}
} }
vec3_t getSize() vec3_t getSize()

View File

@@ -1,6 +1,11 @@
#pragma once #pragma once
#include "misc.h" #include "misc.h"
#define DOOR_XP 1
#define DOOR_XN 2
#define DOOR_YP 4
#define DOOR_YN 8
namespace room namespace room
{ {
void load(int x, int y); void load(int x, int y);