- Redistribució de gràfics en diferents GIFs
BIN
data/doors.gif
Normal file
|
After Width: | Height: | Size: 893 B |
BIN
data/floor.gif
|
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 205 B |
BIN
data/roomaux.gif
Normal file
|
After Width: | Height: | Size: 73 B |
BIN
data/test.gif
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
data/walls.gif
Normal file
|
After Width: | Height: | Size: 452 B |
16
source/colors.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define TRANSPARENT 0
|
||||||
|
#define INK 1
|
||||||
|
#define PAPER 2
|
||||||
|
|
||||||
|
#define LIGHT 8
|
||||||
|
|
||||||
|
#define BLACK 4
|
||||||
|
#define BLUE 5
|
||||||
|
#define RED 6
|
||||||
|
#define PURPLE 7
|
||||||
|
#define GREEN 8
|
||||||
|
#define TEAL 9
|
||||||
|
#define YELLOW 10
|
||||||
|
#define WHITE 11
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "colors.h"
|
||||||
|
|
||||||
#define DRAW_FLIP_NONE 0
|
#define DRAW_FLIP_NONE 0
|
||||||
#define DRAW_FLIP_HORIZONTAL 1
|
#define DRAW_FLIP_HORIZONTAL 1
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ namespace ui
|
|||||||
const int txt_size = strlen(label)*4;
|
const int txt_size = strlen(label)*4;
|
||||||
const int txt_x = x+(w-txt_size)/2;
|
const int txt_x = x+(w-txt_size)/2;
|
||||||
|
|
||||||
draw::color(inside?(btnDown?15:13):5);
|
draw::color(inside?(btnDown?15:LIGHT+TEAL):TEAL);
|
||||||
draw::fillrect(x, y, w, h);
|
draw::fillrect(x, y, w, h);
|
||||||
draw::print(label, 1+txt_x, y+3, 15, 8);
|
draw::print(label, 1+txt_x, y+3, LIGHT+WHITE, PAPER);
|
||||||
|
|
||||||
if (inside)
|
if (inside)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ int room_xp = -1;
|
|||||||
int room_xn = -1;
|
int room_xn = -1;
|
||||||
int room_yp = -1;
|
int room_yp = -1;
|
||||||
int room_yn = -1;
|
int room_yn = -1;
|
||||||
int room_color = 5;
|
int room_color = 9;
|
||||||
|
|
||||||
void restart()
|
void restart()
|
||||||
{
|
{
|
||||||
@@ -44,6 +44,8 @@ void restart()
|
|||||||
void game::init()
|
void game::init()
|
||||||
{
|
{
|
||||||
draw::init("The Pool", 420, 240, 3);
|
draw::init("The Pool", 420, 240, 3);
|
||||||
|
|
||||||
|
room::init();
|
||||||
surf = draw::loadSurface("test.gif");
|
surf = draw::loadSurface("test.gif");
|
||||||
draw::setSource(surf);
|
draw::setSource(surf);
|
||||||
draw::loadPalette("test.gif");
|
draw::loadPalette("test.gif");
|
||||||
@@ -95,7 +97,7 @@ bool game::loop()
|
|||||||
actor::update(actor::getFirst());
|
actor::update(actor::getFirst());
|
||||||
actor::reorder();
|
actor::reorder();
|
||||||
|
|
||||||
draw::cls(8);
|
draw::cls(2);
|
||||||
room::draw();
|
room::draw();
|
||||||
actor::draw(actor::getFirst());
|
actor::draw(actor::getFirst());
|
||||||
room::draw2();
|
room::draw2();
|
||||||
@@ -114,7 +116,7 @@ bool game::loop()
|
|||||||
btn("DOOR XN:", 330, 65, room_xn, -1, 5);
|
btn("DOOR XN:", 330, 65, room_xn, -1, 5);
|
||||||
btn("DOOR YP:", 330, 80, room_yp, -1, 5);
|
btn("DOOR YP:", 330, 80, room_yp, -1, 5);
|
||||||
btn("DOOR YN:", 330, 95, room_yn, -1, 5);
|
btn("DOOR YN:", 330, 95, room_yn, -1, 5);
|
||||||
btn("COLOR:", 330, 110, room_color, 3, 7);
|
btn("COLOR:", 330, 110, room_color, 5, 11);
|
||||||
|
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
|
|||||||
103
source/room.cpp
@@ -14,6 +14,23 @@ namespace room
|
|||||||
static uint8_t door_height[4];
|
static uint8_t door_height[4];
|
||||||
static uint8_t color = 5;
|
static uint8_t color = 5;
|
||||||
|
|
||||||
|
static uint8_t floor_type = 0;
|
||||||
|
static uint8_t walls_type = 0;
|
||||||
|
static uint8_t doors_type = 0;
|
||||||
|
|
||||||
|
static draw::surface *floor_surf = nullptr;
|
||||||
|
static draw::surface *walls_surf = nullptr;
|
||||||
|
static draw::surface *doors_surf = nullptr;
|
||||||
|
static draw::surface *aux_surf = nullptr;
|
||||||
|
|
||||||
|
void init()
|
||||||
|
{
|
||||||
|
floor_surf = draw::loadSurface("floor.gif");
|
||||||
|
walls_surf = draw::loadSurface("walls.gif");
|
||||||
|
doors_surf = draw::loadSurface("doors.gif");
|
||||||
|
aux_surf = draw::loadSurface("roomaux.gif");
|
||||||
|
}
|
||||||
|
|
||||||
void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col)
|
void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col)
|
||||||
{
|
{
|
||||||
color = col;
|
color = col;
|
||||||
@@ -51,6 +68,7 @@ namespace room
|
|||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
|
draw::pushSource();
|
||||||
draw::swapcol(1, color);
|
draw::swapcol(1, color);
|
||||||
|
|
||||||
// RUTINES DE PINTAT DE LA PORTA DE DALT A LA DRETA
|
// RUTINES DE PINTAT DE LA PORTA DE DALT A LA DRETA
|
||||||
@@ -58,17 +76,21 @@ namespace room
|
|||||||
{
|
{
|
||||||
// Si la porta està elevada, pintar la part frontal de baix de la porta
|
// Si la porta està elevada, pintar la part frontal de baix de la porta
|
||||||
if (door_height[3] > 0) {
|
if (door_height[3] > 0) {
|
||||||
draw::draw( 164+3*16-tmin.y*16, (36+3*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, 128, 16+(5-door_height[3])*8);
|
draw::setSource(walls_surf);
|
||||||
draw::draw( 164+4*16-tmin.y*16, (36+4*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, 128, 16+(5-door_height[3])*8);
|
draw::draw( 164+3*16-tmin.y*16, (36+3*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, walls_type*32, (5-door_height[3])*8);
|
||||||
|
draw::draw( 164+4*16-tmin.y*16, (36+4*8+tmin.y*8) + (5-door_height[3])*8, 16, 48-(5-door_height[3])*8, walls_type*32, (5-door_height[3])*8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pintem els dos tiles baix de la porta
|
// Pintem els dos tiles baix de la porta
|
||||||
draw::draw(164+4*16-(tmin.y-1)*16, -door_height[3]*8+84+4*8+(tmin.y-1)*8, 16, 15, 144, 49); // Vora
|
draw::setSource(walls_surf);
|
||||||
draw::draw(148+3*16-(tmin.y-1)*16, -door_height[3]*8+76+3*8+(tmin.y-1)*8, 32, 15, 0, 1); // Tile de Piso
|
draw::draw(164+4*16-(tmin.y-1)*16, -door_height[3]*8+84+4*8+(tmin.y-1)*8, 16, 15, 16+walls_type*32, 33); // Vora
|
||||||
draw::draw(148+4*16-(tmin.y-1)*16, -door_height[3]*8+76+4*8+(tmin.y-1)*8, 32, 15, 0, 1); // Tile de Piso
|
draw::setSource(floor_surf);
|
||||||
|
draw::draw(148+3*16-(tmin.y-1)*16, -door_height[3]*8+76+3*8+(tmin.y-1)*8, 32, 15, floor_type*32, 1); // Tile de Piso
|
||||||
|
draw::draw(148+4*16-(tmin.y-1)*16, -door_height[3]*8+76+4*8+(tmin.y-1)*8, 32, 15, floor_type*32, 1); // Tile de Piso
|
||||||
|
|
||||||
// Pintem la porta
|
// Pintem la porta
|
||||||
draw::draw(164+3*16-tmin.y*16, -door_height[3]*8+32+3*8+tmin.y*8,40,59,18,133);
|
draw::setSource(doors_surf);
|
||||||
|
draw::draw(164+3*16-tmin.y*16, -door_height[3]*8+32+3*8+tmin.y*8,40,59,doors_type*80,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// RUTINES DE PINTAT DE LA PORTA DE DALT A LA ESQUERRA
|
// RUTINES DE PINTAT DE LA PORTA DE DALT A LA ESQUERRA
|
||||||
@@ -76,77 +98,92 @@ namespace room
|
|||||||
{
|
{
|
||||||
// Si la porta està elevada, pintar la part frontal de baix de la porta
|
// Si la porta està elevada, pintar la part frontal de baix de la porta
|
||||||
if (door_height[1] > 0) {
|
if (door_height[1] > 0) {
|
||||||
draw::draw(148+tmin.x*16-3*16, (36+tmin.x*8+3*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, 144, 16+(5-door_height[1])*8);
|
draw::setSource(walls_surf);
|
||||||
draw::draw(148+tmin.x*16-4*16, (36+tmin.x*8+4*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, 144, 16+(5-door_height[1])*8);
|
draw::draw(148+tmin.x*16-3*16, (36+tmin.x*8+3*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, 16+walls_type*32, (5-door_height[1])*8);
|
||||||
|
draw::draw(148+tmin.x*16-4*16, (36+tmin.x*8+4*8)+(5-door_height[1])*8, 16, 48-(5-door_height[1])*8, 16+walls_type*32, (5-door_height[1])*8);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pintem els dos tiles baix de la porta
|
// Pintem els dos tiles baix de la porta
|
||||||
draw::draw(164+(tmin.x-1)*16-5*16, -door_height[1]*8+84+(tmin.x-1)*8+4*8, 16, 15, 128, 49); // Vora
|
draw::setSource(walls_surf);
|
||||||
draw::draw(148+(tmin.x-1)*16-3*16, -door_height[1]*8+76+(tmin.x-1)*8+3*8,32,15,0,1);
|
draw::draw(164+(tmin.x-1)*16-5*16, -door_height[1]*8+84+(tmin.x-1)*8+4*8, 16, 15, walls_type*32, 33); // Vora
|
||||||
draw::draw(148+(tmin.x-1)*16-4*16, -door_height[1]*8+76+(tmin.x-1)*8+4*8,32,15,0,1);
|
draw::setSource(floor_surf);
|
||||||
|
draw::draw(148+(tmin.x-1)*16-3*16, -door_height[1]*8+76+(tmin.x-1)*8+3*8,32,15,floor_type*32,1);
|
||||||
|
draw::draw(148+(tmin.x-1)*16-4*16, -door_height[1]*8+76+(tmin.x-1)*8+4*8,32,15,floor_type*32,1);
|
||||||
|
|
||||||
// Pintem la porta
|
// Pintem la porta
|
||||||
draw::draw(164+(tmin.x-1)*16-4*16-8, -door_height[1]*8+32+3*8+9+(tmin.x-1)*8, 40,59, 64,133);
|
draw::setSource(doors_surf);
|
||||||
|
draw::draw(164+(tmin.x-1)*16-4*16-8, -door_height[1]*8+32+3*8+9+(tmin.x-1)*8, 40,59, 40+doors_type*80,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
draw::setSource(walls_surf);
|
||||||
for (int x=tmin.x;x<=tmax.x;++x)
|
for (int x=tmin.x;x<=tmax.x;++x)
|
||||||
{
|
{
|
||||||
// Si hi ha porta en YP i està a altura 0, no pintem la vorera en eixos dos tiles
|
// Si hi ha porta en YP i està a altura 0, no pintem la vorera en eixos dos tiles
|
||||||
if ( !(doors & DOOR_YP) || (door_height[2] != 0) || (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_YP) || (door_height[2] != 0) || (x!=3 && x!=4) ) draw::draw(148+x*16-tmax.y*16,84+x*8+tmax.y*8,16,15,walls_type*32, 33);
|
||||||
|
|
||||||
// Si hi ha porta en YN, no pintem la pared en eixos dos tiles
|
// Si hi ha porta en YN, no pintem la pared en eixos dos tiles
|
||||||
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);
|
if ( !(doors & DOOR_YN) || (x!=3 && x!=4) ) draw::draw(164+x*16-tmin.y*16,36+x*8+tmin.y*8,16,48,walls_type*32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int y=tmin.y;y<=tmax.y;++y)
|
for (int y=tmin.y;y<=tmax.y;++y)
|
||||||
{
|
{
|
||||||
|
draw::setSource(walls_surf);
|
||||||
// Si hi ha porta en XP i està a altura 0, no pintem la vorera en eixos dos tiles
|
// Si hi ha porta en XP i està a altura 0, no pintem la vorera en eixos dos tiles
|
||||||
if ( !(doors & DOOR_XP) || (door_height[0] != 0) || (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_XP) || (door_height[0] != 0) || (y!=3 && y!=4) ) draw::draw(164+tmax.x*16-y*16,84+tmax.x*8+y*8,16,15,16+walls_type*32, 33);
|
||||||
|
|
||||||
// Si hi ha porta en XN, no pintem la pared en eixos dos tiles
|
// Si hi ha porta en XN, no pintem la pared en eixos dos tiles
|
||||||
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);
|
if ( !(doors & DOOR_XN) || (y!=3 && y!=4) ) draw::draw(148+tmin.x*16-y*16,36+tmin.x*8+y*8,16,48,16+walls_type*32,0);
|
||||||
|
|
||||||
// Pintem tots els tiles del piso
|
// Pintem tots els tiles del piso
|
||||||
|
draw::setSource(floor_surf);
|
||||||
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,floor_type*32,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
draw::popSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw2()
|
void draw2()
|
||||||
{
|
{
|
||||||
|
draw::pushSource();
|
||||||
draw::swapcol(1, color);
|
draw::swapcol(1, color);
|
||||||
|
|
||||||
if (doors & DOOR_YP)
|
if (doors & DOOR_YP)
|
||||||
{
|
{
|
||||||
// Pintem les voreres dels dos tiles extra per a la porta YP
|
// Pintem les voreres dels dos tiles extra per a la porta YP
|
||||||
draw::draw(164+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, 144, 17);
|
draw::setSource(walls_surf);
|
||||||
draw::draw(148+3*16-(tmax.y+1)*16, -door_height[2]*8+84+3*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, 128, 17);
|
draw::draw(164+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, 16+walls_type*32, 1);
|
||||||
draw::draw(148+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, 128, 17);
|
draw::draw(148+3*16-(tmax.y+1)*16, -door_height[2]*8+84+3*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walls_type*32, 1);
|
||||||
|
draw::draw(148+4*16-(tmax.y+1)*16, -door_height[2]*8+84+4*8+(tmax.y+1)*8, 16, 15+door_height[2]*8, walls_type*32, 1);
|
||||||
|
|
||||||
draw::draw(164+4*16-(tmax.y+1)*16, 91+4*8+(tmax.y+1)*8, 16, 8, 16, 24);
|
draw::setSource(aux_surf);
|
||||||
draw::draw(148+3*16-(tmax.y+1)*16, 91+3*8+(tmax.y+1)*8, 16, 8, 0, 24);
|
draw::draw(164+4*16-(tmax.y+1)*16, 91+4*8+(tmax.y+1)*8, 16, 8, 16, 0);
|
||||||
draw::draw(148+4*16-(tmax.y+1)*16, 91+4*8+(tmax.y+1)*8, 16, 8, 0, 24);
|
draw::draw(148+3*16-(tmax.y+1)*16, 91+3*8+(tmax.y+1)*8, 16, 8, 0, 0);
|
||||||
|
draw::draw(148+4*16-(tmax.y+1)*16, 91+4*8+(tmax.y+1)*8, 16, 8, 0, 0);
|
||||||
|
|
||||||
// Pintem la porta YP
|
// Pintem la porta YP
|
||||||
draw::draw(164+3*16-8-(tmax.y+1)*16, -door_height[2]*8+32+3*8+4+(tmax.y+1)*8,40,59,18,133);
|
draw::setSource(doors_surf);
|
||||||
|
draw::draw(164+3*16-8-(tmax.y+1)*16, -door_height[2]*8+32+3*8+4+(tmax.y+1)*8,40,59,doors_type*80,0);
|
||||||
}
|
}
|
||||||
if (doors & DOOR_XP)
|
if (doors & DOOR_XP)
|
||||||
{
|
{
|
||||||
// Pintem les voreres dels dos tiles extra per a la porta XP
|
// Pintem les voreres dels dos tiles extra per a la porta XP
|
||||||
draw::draw(148+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,128,17);
|
draw::setSource(walls_surf);
|
||||||
draw::draw(164+(tmax.x+1)*16-3*16, -door_height[0]*8+84+(tmax.x+1)*8+3*8,16,15+door_height[0]*8,144,17);
|
draw::draw(148+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,walls_type*32, 1);
|
||||||
draw::draw(164+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,144,17);
|
draw::draw(164+(tmax.x+1)*16-3*16, -door_height[0]*8+84+(tmax.x+1)*8+3*8,16,15+door_height[0]*8,16+walls_type*32, 1);
|
||||||
|
draw::draw(164+(tmax.x+1)*16-4*16, -door_height[0]*8+84+(tmax.x+1)*8+4*8,16,15+door_height[0]*8,16+walls_type*32, 1);
|
||||||
|
|
||||||
draw::draw(148+(tmax.x+1)*16-4*16, 91+(tmax.x+1)*8+4*8,16,8,0,24);
|
draw::setSource(aux_surf);
|
||||||
draw::draw(164+(tmax.x+1)*16-3*16, 91+(tmax.x+1)*8+3*8,16,8,16,24);
|
draw::draw(148+(tmax.x+1)*16-4*16, 91+(tmax.x+1)*8+4*8,16,8,0,0);
|
||||||
draw::draw(164+(tmax.x+1)*16-4*16, 91+(tmax.x+1)*8+4*8,16,8,16,24);
|
draw::draw(164+(tmax.x+1)*16-3*16, 91+(tmax.x+1)*8+3*8,16,8,16,0);
|
||||||
|
draw::draw(164+(tmax.x+1)*16-4*16, 91+(tmax.x+1)*8+4*8,16,8,16,0);
|
||||||
|
|
||||||
// Pintem la porta XP
|
// Pintem la porta XP
|
||||||
draw::draw( 164+(tmax.x+1)*16-4*16-16, -door_height[0]*8+32+3*8+4+(tmax.x+1)*8, 40,59, 64,133);
|
draw::setSource(doors_surf);
|
||||||
|
draw::draw( 164+(tmax.x+1)*16-4*16-16, -door_height[0]*8+32+3*8+4+(tmax.x+1)*8, 40,59, 40+doors_type*80,0);
|
||||||
}
|
}
|
||||||
|
draw::popSource();
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3_t getSize()
|
vec3_t getSize()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
namespace room
|
namespace room
|
||||||
{
|
{
|
||||||
|
void init();
|
||||||
void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col);
|
void load(int x, int y, int8_t xp, int8_t xn, int8_t yp, int8_t yn, uint8_t col);
|
||||||
void draw();
|
void draw();
|
||||||
void draw2();
|
void draw2();
|
||||||
|
|||||||