Renamed binary_to_c to pack_tiles and made it convert tiles/*.png to various char arrays in tiles/tiles.c and tiles/tiles.h. Added fully functional graphical tiles to the SDL client by using the tile's id and tid to point to the appropriate arrays in tiles.c/tiles.h. Also added proper displaying of multiple tiles on a tile chain, tile movement via gameMoveTile, tile line drawing via drawLine, along with other touch-ups

netcode
kts 2013-10-15 18:54:23 -07:00
parent 6e414d9223
commit 33ab0f2af2
26 changed files with 252 additions and 142 deletions

View File

@ -3,18 +3,20 @@ PREFIX = ./
BINARY=timesynk
OBJS = main.o game.o context.o player.o tile.o map.o wall.o net/sockets.o helper.o
CURSES_OBJS = interface/curses.o
SDL_OBJS = interface/sdl.o
SDL_OBJS = interface/sdl.o tiles/tiles.o
DEBUG = -g
CFLAGS = -Wall -c $(DEBUG)
CURSES_LFLAGS = -lcurses
XCURSES_LFLAGS = -lXCurses
SDL_LFLAGS = -lSDL
SDL_LFLAGS = -lSDL -lSDL_image
LFLAGS = -Wall $(DEBUG)
$(BINARY): $(OBJS) $(CURSES_OBJS)
$(CC) $(OBJS) $(CURSES_OBJS) $(CURSES_LFLAGS) -o $(BINARY)
sdl: tiles $(OBJS) $(SDL_OBJS)
./pack_tiles
$(CC) $(CFLAGS) -c tiles/tiles.c
$(CC) $(OBJS) $(SDL_OBJS) $(SDL_LFLAGS) -o $(BINARY)
curses: $(OBJS) $(CURSES_OBJS)
@ -27,12 +29,14 @@ all: $(BINARY)
clean:
rm -f $(OBJS) $(CURSES_OBJS) $(SDL_OBJS) $(BINARY)
rm -f pack_tiles
binary_to_c: binary_to_c.c
$(CC) binary_to_c.c -o binary_to_c
pack_tiles: pack_tiles.c
$(CC) pack_tiles.c -o pack_tiles
tiles: binary_to_c
./binary_to_c
tiles: pack_tiles
./pack_tiles
$(CC) $(CFLAGS) -c tiles/tiles.c
main.o: main.c stubs.h wall.h wall.c context.h interface/curses.c net/sockets.c
$(CC) $(CFLAGS) -c main.c

Binary file not shown.

View File

@ -1,37 +0,0 @@
#include <stdio.h>
void convert(char *file_name, char *var_name) {
int i, n;
unsigned char buffer[16];
FILE *infile=fopen(file_name, "r");
printf("unsigned char %s[] = { ", var_name);
while ((n = fread(buffer, 1, 16, infile)))
{
for (i = 0; i < n; i++) printf("0x%2.2x,", buffer[i]);
//printf("\n");
}
printf(" };\n");
printf("unsigned int %s_len = %i;\n", var_name, ftell(infile));
}
int main(int argc, char **argv) {
convert("tiles/qusqu.png", "player_tiles");
/*int i, n;
unsigned char buffer[16];
FILE *infile=fopen(argv[1], "r");
printf("unsigned char %s[] = { ", argv[1]);
while ((n = fread(buffer, 1, 16, infile)))
{
for (i = 0; i < n; i++) printf("0x%2.2x,", buffer[i]);
//printf("\n");
}
printf(" };\n");
printf("unsigned int %s_len = %i;\n", argv[1], ftell(infile));
return 0;
*/
return 0;
}

48
game.c
View File

@ -10,17 +10,24 @@
#include "display.h"
#include "tile.h"
#include "context.h"
#include "player.h"
int gameInit() {
null_tile.tid = 0;
player.tid = 1;
player.id = 12;
current_context = &walkContext;
allocateMap(&current_map, 32, 16);
floodMap(&current_map, TILE_REPLACE, FLOOR, STONE);
drawPath(&current_map, TILE_REPLACE, FLOOR, WOOD, 0, 0, 9, 9);
drawPath(&current_map, TILE_REPLACE, WALL, WOOD, 8, 0, 9, 9);
drawPath(&current_map, TILE_REPLACE, WALL, STEEL, 9, 4, 6, 9);
drawPath(&current_map, TILE_REPLACE, WALL, STONE, 4, 6, 14, 2);
replaceTile(&current_map->matrix[2][2], WALL, WALL_STEEL);
gameMoveTile(&player, 2, 2);
drawPath(&current_map, TILE_APPEND, WALL, STONE, 6, 1, 8, 12);
drawPath(&current_map, TILE_APPEND, WALL, STONE, 12, 4, 7, 13);
drawLine(&current_map, TILE_APPEND, WALL, STONE, 0, 0, 31, 0);
drawLine(&current_map, TILE_APPEND, WALL, STONE, 0, 15, 31, 15);
drawLine(&current_map, TILE_APPEND, WALL, STONE, 0, 0, 0, 15);
drawLine(&current_map, TILE_APPEND, WALL, STONE, 31, 0, 31, 15);
return SUCCESS;
}
@ -44,7 +51,7 @@ int gameCollision(target_x, target_y) {
return 1;
break;
case FLOOR:
return 0;
// return 0;
break;
}
debug_tile = debug_tile->next;
@ -52,6 +59,35 @@ int gameCollision(target_x, target_y) {
return 0;
}
void gameMoveTile(struct Tile *tile, int target_x, int target_y) {
// remove tile from chain and connect tile's neighbors to each other
if (tile->prev != NULL) {
if (tile->next != NULL) {
tile->prev->next = tile->next;
} else {
tile->prev->next = NULL;
}
}
if (tile->next != NULL) {
tile->next->prev = tile->prev;
}
// now add tile to the end of the target chain
struct Tile *target_loc;
target_loc = &(current_map->matrix[target_x][target_y]);
while (target_loc) {
if (!target_loc->next) { // last element
target_loc->next = tile;
tile->prev = target_loc;
tile->next = NULL;
break;
}
target_loc = target_loc->next;
}
// finally, update tile's x and y props
tile->x = target_x;
tile->y = target_y;
}
void gameUpdateTile(int x, int y) {
display_map[x][y] = 2;
}

1
game.h
View File

@ -21,5 +21,6 @@ void gameLoop();
void gameClose();
int gameCollision(int target_x, int target_y);
void gameMoveTile(struct Tile *tile, int target_x, int target_y);
#endif

View File

@ -34,7 +34,7 @@ Acceptable attributes (from manpage, curs_attr):
A_CHARTEXT Bit-mask to extract a character
*/
CursesTile ascii_walls[] = {
{'.', COLOR_WHITE, COLOR_BLACK, 0}, // 0=WALL_NULL
// {'.', COLOR_WHITE, COLOR_BLACK, 0}, // 0=WALL_NULL
{'#', COLOR_WHITE, COLOR_BLACK, 0}, // 0=WALL_STONE
{'#', COLOR_YELLOW, COLOR_BLACK, 0}, // 1=WALL_WOOD
{'#', COLOR_WHITE, COLOR_BLACK, A_BOLD} // 2=WALL_STEEL
@ -94,7 +94,7 @@ void interfaceDraw() {
step_y = player.y - 6;
while (step_y < end_y) {
//if (visible_matrix[step_x][step_y] & TILE_VISIBLE) {
if (step_x >= 0 && step_y >= 0 && step_x < current_map->width && step_y < current_map->height) {
if (step_x >= 0 && step_y >= 0 && step_x < current_map->width && step_y < current_map->height) {
short tile_id = current_map->matrix[step_x][step_y].id;
unsigned int type_id = current_map->matrix[step_x][step_y].tid;
int color;
@ -112,10 +112,7 @@ if (step_x >= 0 && step_y >= 0 && step_x < current_map->width && step_y < curren
attroff(COLOR_PAIR(color) | ascii_walls[tile_id].attr);
break;
}
}
//} else {
// mvwaddch(screen, step_y, step_x, '_');
//}
}
step_y++; // move down
}
step_x++; // move right

View File

@ -1,6 +1,6 @@
//#if !defined (__APPLE__)
#include <SDL/SDL.h>
#include <SDL_image.h>
#include <SDL/SDL_image.h>
//#endif
#include "sdl.h"
@ -22,7 +22,18 @@ int interfaceInit() {
SDL_WM_SetCaption(NAME, NULL);
camera_surface = SDL_CreateRGBSurface(screen->flags, 512, 512, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
player_image = IMG_Load_RW(SDL_RWFromMem(&player_png, player_png_len), 1);
player_spritesheet = IMG_Load_RW(SDL_RWFromMem(&player_images, player_images_length), 1);
wall_spritesheet = IMG_Load_RW(SDL_RWFromMem(&wall_images, wall_images_length), 1);
floor_spritesheet = IMG_Load_RW(SDL_RWFromMem(&floor_images, floor_images_length), 1);
shadow_spritesheet = IMG_Load_RW(SDL_RWFromMem(&shadow_images, shadow_images_length), 1);
int race, class;
SDL_Rect sprite_offset = {0, 0, TILE_WIDTH, TILE_HEIGHT};
for (race = 0; race < TOTAL_RACES;race++) {
for(class = 0; class < TOTAL_CLASSES;class++) {
player_sprites[race][class] = SDL_CreateRGBSurface(screen->flags, 16, 32, screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask);
SDL_BlitSurface(player_spritesheet, &sprite_offset, player_sprites[race][class], NULL);
}
}
// Fill our screen w/ black
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 32, 128, 64));
// Update!
@ -35,7 +46,6 @@ int interfaceInit() {
void cameraDraw() {
SDL_FillRect(camera_surface, NULL, SDL_MapRGB(camera_surface->format, 0, 0, 0));
SDL_Rect camera_rect = {0, 0, 512, 512};
SDL_Rect player_rect = {player.x*TILE_WIDTH, player.y*TILE_WIDTH, TILE_WIDTH, TILE_HEIGHT};
int step_x = player.x - 12;
int step_y = player.y - 12;
int end_x = player.x + 12;
@ -43,22 +53,32 @@ void cameraDraw() {
while (step_x < end_x) {
step_y = player.y - 6;
while (step_y < end_y) {
// draw our player in the "middle" layer
if (step_x == player.x && step_y == player.y) {
SDL_BlitSurface(player_image, NULL, camera_surface, &player_rect);
}
// TODO: draw the layer immediately in front of the player at partial translucency
if (step_x >= 0 && step_y >= 0 && step_x < current_map->width && step_y < current_map->height) {
short tile_id = current_map->matrix[step_x][step_y].id;
unsigned int type_id = current_map->matrix[step_x][step_y].tid;
SDL_Rect tile_rect = {step_x*TILE_WIDTH, step_y*TILE_WIDTH, TILE_WIDTH, TILE_HEIGHT};
switch (type_id) {
case WALL:
SDL_FillRect(camera_surface, &tile_rect, SDL_MapRGB(camera_surface->format, 128, 128, 128));
break;
case FLOOR:
//SDL_FillRect(camera_surface, &tile_rect, SDL_MapRGB(camera_surface->format, 32, 32, 32));
break;
struct Tile *current_tile;
current_tile = &(current_map)->matrix[step_x][step_y];
while(current_tile) {
int x_offset = current_tile->id / 16; // 16 tiles across in spritesheet
int y_offset = current_tile->id - (x_offset*16);
SDL_Rect sprite_offset = { x_offset*TILE_WIDTH, y_offset*TILE_HEIGHT, TILE_WIDTH, TILE_HEIGHT};
SDL_Rect tile_rect = {step_x*TILE_WIDTH, step_y*TILE_WIDTH, TILE_WIDTH, TILE_HEIGHT};
switch (current_tile->tid) {
case WALL:
SDL_BlitSurface(wall_spritesheet, &sprite_offset, camera_surface, &tile_rect);
break;
case FLOOR:
SDL_BlitSurface(floor_spritesheet, &sprite_offset, camera_surface, &tile_rect);
break;
case PLAYER:
y_offset = current_tile->id / TOTAL_CLASSES;
x_offset = current_tile->id - (y_offset*TOTAL_CLASSES);
sprite_offset.x = x_offset*TILE_WIDTH;
sprite_offset.y = y_offset*TILE_HEIGHT;
SDL_BlitSurface(shadow_spritesheet, NULL, camera_surface, &tile_rect);
SDL_BlitSurface(player_spritesheet, &sprite_offset, camera_surface, &tile_rect);
break;
}
current_tile = current_tile->next;
}
}
step_y++; // move down

View File

@ -1,7 +1,12 @@
#ifndef SDL_H
#define SDL_H
#include "../player.h" // for races/class totals
SDL_Surface* screen;
SDL_Surface* player_image; // replace with players array
SDL_Surface* player_spritesheet;
SDL_Surface* shadow_spritesheet;
SDL_Surface* wall_spritesheet;
SDL_Surface* floor_spritesheet;
SDL_Surface* player_sprites[TOTAL_RACES][TOTAL_CLASSES];
SDL_Surface* camera_surface;
SDL_Event event;
#endif

25
map.c
View File

@ -114,6 +114,13 @@ int allocateMap(struct Map** map, unsigned int width, unsigned int height) {
(*map)->height = height;
allocateMapTiles(&(*map)->matrix, width, height);
int x, y;
for (x=0;x<width;x++) {
for (y=0;y<height;y++) {
(*map)->matrix[x][y].next = NULL;
(*map)->matrix[x][y].prev = NULL;
}
}
return SUCCESS;
}
@ -180,3 +187,21 @@ void drawPath(struct Map** map, unsigned int operation, unsigned int tid, short
from_x += x_mod;
}
}
void drawLine(struct Map** map, unsigned int operation, unsigned int tid, short id, unsigned int from_x, unsigned int from_y, unsigned int to_x, unsigned int to_y) {
int x_inc = (from_x-to_x < 0 ? -1 : 1);
int y_inc = (from_y-to_y < 0 ? -1 : 1);
while(1) {
if (operation == TILE_REPLACE) {
replaceTile(&(*map)->matrix[from_x][from_y], tid, id);
} else if (operation == TILE_APPEND) {
appendTile(&(*map)->matrix[from_x][from_y], tid, id);
}
if (from_x == to_x && from_y == to_y)
break;
if (from_x != to_x)
from_x += x_inc;
if (from_y != to_y)
from_y += y_inc;
}
}

4
map.h
View File

@ -29,6 +29,10 @@ void freeMap(struct Map **map);
This function "walks" a path from from_x,from_y to to_x,to_y, populating each step with either a new tile or replacing the old one with a tile of tid and id. Note that Tile data is freed and the new tile's default properties are memcpy'd to a new malloc'd space.
***/
void drawPath(struct Map** map, unsigned int operation, unsigned int tid, short id, unsigned int from_x, unsigned int from_y, unsigned int to_x, unsigned int to_y);
/*** drawLine
This function simply draws a line from_x,from_y to to_x,to_y, populating each step with either a new tile or replacing the old one with a tile of tid and id. Note that Tile data is freed and the new tile's default properties are memcpy'd to a new malloc'd space.
***/
void drawLine(struct Map** map, unsigned int operation, unsigned int tid, short id, unsigned int from_x, unsigned int from_y, unsigned int to_x, unsigned int to_y);
/*** floodMap
floodMap does as is expected - it floods a given map with the given tid and id, memcpy-ing the new tile's default data. Can replace or append the tile.
***/

43
pack_tiles.c 100644
View File

@ -0,0 +1,43 @@
#include <stdio.h>
FILE *tiles_c;
FILE *tiles_h;
void convert(char *file_name, char *var_name) {
int i, n;
unsigned char buffer[16];
FILE *infile=fopen(file_name, "r");
fprintf(tiles_c, "unsigned char %s[] = {\n", var_name);
while ((n = fread(buffer, 1, 16, infile)))
{
for (i = 0; i < n; i++) {
fprintf(tiles_c, "0x%2.2x,", buffer[i]);
}
}
fprintf(tiles_c, "\n};\n");
fprintf(tiles_c, "unsigned int %s_length = %d;\n\n", var_name, ftell(infile));
fprintf(tiles_h, "extern unsigned char %s[];\n", var_name);
fprintf(tiles_h, "extern unsigned int %s_length;\n\n", var_name);
}
int main(int argc, char **argv) {
tiles_c = fopen("tiles/tiles.c", "w");
tiles_h = fopen("tiles/tiles.h", "w");
fprintf(tiles_h, "/** WARNING - THIS FILE IS AUTOGENERATED BY pack_tiles, EDITS TO THIS FILE MAY BE OVERWRITTEN **/\n");
fprintf(tiles_c, "/** WARNING - THIS FILE IS AUTOGENERATED BY pack_tiles, EDITS TO THIS FILE MAY BE OVERWRITTEN **/\n");
fprintf(tiles_h, "#ifndef TILES_H\n#define TILES_H\n");
fprintf(tiles_h, "#define TILE_WIDTH 16\n#define TILE_HEIGHT 32\n");
convert("tiles/players.png", "player_images");
convert("tiles/walls.png", "wall_images");
convert("tiles/floors.png", "floor_images");
convert("tiles/shadows.png", "shadow_images");
fprintf(tiles_h, "#endif\n");
fclose(tiles_c);
fclose(tiles_h);
return 0;
}

View File

@ -16,52 +16,43 @@ void playerMove(int direction, int distance) {
switch(direction) {
case NORTH:
if (!gameCollision(player.x, (player.y-distance))) {
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.y -= distance;
gameMoveTile(&player, player.x, player.y-distance);
}
break;
case NORTHWEST:
if (!gameCollision(player.x-distance, (player.y-distance))) {
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.y -= distance;
player.x -= distance;
gameMoveTile(&player, player.x-distance, player.y-distance);
}
break;
case NORTHEAST:
if (!gameCollision(player.x+distance, (player.y-distance))) {
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.y -= distance;
player.x += distance;
gameMoveTile(&player, player.x+distance, player.y-distance);
}
break;
case SOUTH:
if (!gameCollision(player.x, player.y+distance))
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.y += distance;
if (!gameCollision(player.x, player.y+distance)) {
gameMoveTile(&player, player.x, player.y+distance);
}
break;
case SOUTHWEST:
if (!gameCollision(player.x-distance, player.y+distance)) {
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.y += distance;
player.x -= distance;
gameMoveTile(&player, player.x-distance, player.y+distance);
}
break;
case SOUTHEAST:
if (!gameCollision(player.x+distance, player.y+distance)) {
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.y += distance;
player.x += distance;
gameMoveTile(&player, player.x+distance, player.y+distance);
}
break;
case EAST:
if (!gameCollision(player.x+distance, player.y))
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.x += distance;
if (!gameCollision(player.x+distance, player.y)) {
gameMoveTile(&player, player.x+distance, player.y);
}
break;
case WEST:
if (!gameCollision(player.x-distance, player.y))
//gameUpdateTile(player.x, player.y); // set old pos to be redrawn
player.x -= distance;
if (!gameCollision(player.x-distance, player.y)) {
gameMoveTile(&player, player.x-distance, player.y);
}
break;
}
}
@ -70,10 +61,11 @@ void playerLook(int x, int y) {
char string[32];
struct Tile* debug_tile;
if ((x < current_map->width && x >= 0) && (y < current_map->height && y >= 0)) {
if (current_map->matrix[x][y].tid != TILE_NULL) {
//if (current_map->matrix[x][y].tid != TILE_NULL) {
if (current_map->matrix[x][y].tid) {
int chain_count = 0;
debug_tile = &current_map->matrix[x][y];
while(debug_tile) {
while(debug_tile != NULL) {
//itoa(debug_tile->id, string, 10);
//strcat(string, " ");
strcat(string, "You see: ");

View File

@ -8,6 +8,21 @@
#define PLAYER_TUMBLE 3
#define PLAYER_LOOK 4
#define TOTAL_RACES 5
#define RACE_HUMAN 0
#define RACE_MANITOU 1
#define RACE_CAPRAN 2
#define RACE_QUOSQOY 3
#define RACE_QUOSQO 4
#define TOTAL_CLASSES 6
#define CLASS_WARRIOR 0
#define CLASS_WIZARD 1
#define CLASS_PRIEST 2
#define CLASS_ROGUE 3
#define CLASS_RANGER 4
#define CLASS_BARBARIAN 5
typedef struct {
char name[16];
} PlayerTile;
@ -16,10 +31,11 @@ typedef struct {
int x;
int y;
} player_struct;
player_struct player;
//player_struct player;
//player_struct player;
struct Tile player;
void (*player_commands[128]) (); // pointer to array of command functions
//void (*player_commands[128]) () = { NULL }; // pointer to array of command functions
/** playerSetCommand
This function ties a command function to a command id, as contained within the player_commands array. After tying a command to a function, a command can be directly called with the following syntax:

2
tile.h
View File

@ -24,6 +24,8 @@ struct Tile {
void *data; // pointer to the Tile's actual data, preferably a struct
};
struct Tile null_tile; // FIXME: temporary solution to next and prev pointers
struct BasicTile {
int collision;
char name[16];

BIN
tiles.o 100644

Binary file not shown.

BIN
tiles/floors.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

View File

@ -1,28 +0,0 @@
unsigned char player_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20,
0x02, 0x03, 0x00, 0x00, 0x00, 0x66, 0xe7, 0x10, 0x5f, 0x00, 0x00, 0x00,
0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0x09, 0x50, 0x4c, 0x54, 0x45, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0x0d, 0x52, 0xc8, 0x31, 0x00, 0x00, 0x00, 0x01, 0x74,
0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8, 0x66, 0x00, 0x00, 0x00, 0x01,
0x62, 0x4b, 0x47, 0x44, 0x00, 0x88, 0x05, 0x1d, 0x48, 0x00, 0x00, 0x00,
0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00, 0x0b,
0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74, 0x49,
0x4d, 0x45, 0x07, 0xdd, 0x0a, 0x04, 0x03, 0x14, 0x24, 0xb7, 0x4d, 0xa7,
0x7a, 0x00, 0x00, 0x00, 0x22, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d,
0x6d, 0x65, 0x6e, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64,
0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x20, 0x6f,
0x6e, 0x20, 0x61, 0x20, 0x4d, 0x61, 0x63, 0x87, 0xa8, 0x77, 0x43, 0x00,
0x00, 0x00, 0x56, 0x49, 0x44, 0x41, 0x54, 0x08, 0xd7, 0x63, 0x60, 0x40,
0x07, 0x4b, 0x80, 0x98, 0x29, 0x04, 0x48, 0x30, 0x4e, 0x01, 0x12, 0x9c,
0xa1, 0x40, 0x42, 0x33, 0xd4, 0x81, 0x81, 0x41, 0x6b, 0x2a, 0x90, 0x60,
0x05, 0x71, 0x99, 0x52, 0x40, 0xb2, 0x60, 0x25, 0x11, 0x40, 0x42, 0x6d,
0x29, 0x90, 0x98, 0x0a, 0x92, 0x0d, 0x03, 0xa9, 0x8b, 0x04, 0x11, 0xa1,
0xa8, 0xc4, 0xb2, 0xb4, 0x06, 0x06, 0x86, 0xa5, 0x53, 0x81, 0x04, 0xeb,
0x54, 0xa0, 0x62, 0xd6, 0x54, 0x06, 0xec, 0x2c, 0xce, 0x48, 0x20, 0xa1,
0x9a, 0x8a, 0xe4, 0x1a, 0x00, 0xa3, 0x7b, 0x13, 0x23, 0xd4, 0xd1, 0x1f,
0x5d, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60,
0x82
};
unsigned int player_png_len = 289;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

BIN
tiles/players.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 955 B

BIN
tiles/shadows.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,18 @@
/** WARNING - THIS FILE IS AUTOGENERATED BY pack_tiles, EDITS TO THIS FILE MAY BE OVERWRITTEN **/
#ifndef TILES_H
#define TILES_H
#define TILE_WIDTH 16
#define TILE_HEIGHT 32
extern unsigned char player_png[];
extern unsigned int player_png_len;
#endif
extern unsigned char player_images[];
extern unsigned int player_images_length;
extern unsigned char wall_images[];
extern unsigned int wall_images_length;
extern unsigned char floor_images[];
extern unsigned int floor_images_length;
extern unsigned char shadow_images[];
extern unsigned int shadow_images_length;
#endif

BIN
tiles/walls.png 100644

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

4
wall.c
View File

@ -1,14 +1,14 @@
#include "wall.h"
#include "tile.h"
WallTile walls[] = {
{ }, // 0 presumed to be empty
// { }, // 0 presumed to be empty
{ NO_PASS, "stone wall" }, // 1
{ NO_PASS, "wood wall" }, // 2
{ NO_PASS, "steel wall" } // 3
};
FloorTile floors[] = {
{},
// {},
{ PASS, "stone floor", 128},
{ PASS, "wood floor", 32},
{ PASS, "steel floor", 255}

14
wall.h
View File

@ -4,14 +4,14 @@
#define MATERIAL_STONE 0
#define MATERIAL_WOOD 1
#define MATERIAL_STEEL 2
#define WALL_NONE 0
#define WALL_STONE 1
#define WALL_WOOD 2
#define WALL_STEEL 3
//#define WALL_NONE 0
#define WALL_STONE 0
#define WALL_WOOD 1
#define WALL_STEEL 2
#define STONE 1
#define WOOD 2
#define STEEL 3
#define STONE 0
#define WOOD 1
#define STEEL 2
typedef struct {
int collision;