flawless map system
This commit is contained in:
parent
f106977f6b
commit
5a84257033
|
@ -4,6 +4,9 @@
|
|||
/*.g1a
|
||||
/*.g3a
|
||||
/hyperultra
|
||||
/src/*.o
|
||||
/src/*.d
|
||||
/map/*.h
|
||||
|
||||
# Python bytecode
|
||||
__pycache__/
|
||||
|
|
|
@ -7,6 +7,7 @@ project(MyAddin)
|
|||
include(GenerateG1A)
|
||||
include(GenerateG3A)
|
||||
include(Fxconv)
|
||||
include_directories(map)
|
||||
find_package(Gint 2.9 REQUIRED)
|
||||
|
||||
set(SOURCES
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
CC := gcc
|
||||
LD := $(CC)
|
||||
CFLAGS := -Os -std=c99 -Wall -Wextra -Imap -MMD
|
||||
LDFLAGS := -lm -lSDL2 -lSDL2_image -lSDL2_mixer
|
||||
NAME := hyperultra
|
||||
EMBED := $(patsubst %.json,%.h,$(wildcard map/*.json))
|
||||
OBJ := $(patsubst %.c,%.o,$(wildcard src/*.c))
|
||||
DEP := $(patsubst %.o,%.d,$(OBJ))
|
||||
|
||||
all:
|
||||
@make --no-print-directory $(EMBED)
|
||||
@make --no-print-directory $(NAME)
|
||||
|
||||
$(NAME): $(OBJ)
|
||||
$(LD) -o $(NAME) $(OBJ) $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
%.h: %.json
|
||||
able -e -i $< -o $@ 2&>/dev/null
|
||||
|
||||
run: re
|
||||
./$(NAME)
|
||||
|
||||
clean:
|
||||
rm -f $(NAME) $(OBJ) $(DEP) $(EMBED)
|
||||
|
||||
re:
|
||||
@make --no-print-directory clean
|
||||
@make --no-print-directory all
|
||||
|
||||
.PHONY: all run clean re
|
||||
|
||||
-include $(DEP)
|
3
build.sh
3
build.sh
|
@ -1,3 +0,0 @@
|
|||
#!/bin/sh
|
||||
gcc -std=c99 -Wall -Wextra -o hyperultra src/*.c \
|
||||
-lm -lSDL2 -lSDL2_image -lSDL2_mixer
|
|
@ -1,3 +1,4 @@
|
|||
-Wall
|
||||
-Wextra
|
||||
-std=c99
|
||||
-Imap
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]}
|
BIN
res/tset.png
BIN
res/tset.png
Binary file not shown.
Before Width: | Height: | Size: 68 B After Width: | Height: | Size: 132 B |
|
@ -2,7 +2,7 @@
|
|||
#include "cfg.h"
|
||||
#include <math.h>
|
||||
|
||||
static long tick = 0;
|
||||
long tick = 0;
|
||||
|
||||
static void
|
||||
rotate(double *x, double *y, double angle)
|
||||
|
|
|
@ -11,8 +11,8 @@ entity_collide(Entity *this, Game *g, int ox, int oy)
|
|||
const int y0 = this->pos[1] - this->height / 2 + oy;
|
||||
const int x1 = x0 + this->width - 1;
|
||||
const int y1 = y0 + this->height - 1;
|
||||
return (map_get_px(x0, y0) == '0' || map_get_px(x0, y1) == '0' ||
|
||||
map_get_px(x1, y0) == '0' || map_get_px(x1, y1) == '0');
|
||||
return (map_get_px(x0, y0) == 1 || map_get_px(x0, y1) == 1 ||
|
||||
map_get_px(x1, y0) == 1 || map_get_px(x1, y1) == 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
31
src/map.c
31
src/map.c
|
@ -1,30 +1,14 @@
|
|||
#include "map.h"
|
||||
#include "lzy.h"
|
||||
#include "cfg.h"
|
||||
|
||||
static const char *map =
|
||||
"0000000000000000000000000"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0"
|
||||
"0 0 0"
|
||||
"00000000000000000000 0"
|
||||
"0 0"
|
||||
"0 0 0"
|
||||
"0000000000000000000000000"
|
||||
;
|
||||
#include "00.h"
|
||||
|
||||
int
|
||||
map_get(int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= 25 || y >= 14)
|
||||
if (x < 0 || y < 0 || x >= map_00_json.width || y >= map_00_json.height)
|
||||
return 0;
|
||||
return map[x + y * 25];
|
||||
return map_00_json.data[x + y * map_00_json.width];
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -38,11 +22,12 @@ map_get_px(int x, int y)
|
|||
void
|
||||
map_draw(void)
|
||||
{
|
||||
extern long tick;
|
||||
const int tile_id = 1 + tick / 18 % 2;
|
||||
for (int y = 0; y < 14; y++)
|
||||
for (int x = 0; x < 25; x++)
|
||||
if (map[x + y * 25] == '0') {
|
||||
for (int x = 0; x < map_00_json.width; x++)
|
||||
if (map_00_json.data[x + y * map_00_json.width] == 1) {
|
||||
LZY_DrawSetColor(BLACK);
|
||||
LZY_DrawRect(x*16, y*16, 16, 16);
|
||||
LZY_DrawFillRect(x*16, y*16, 16, 16);
|
||||
LZY_DrawTile(tile_id, x * 16, y * 16);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ player_update(Entity *this, Game *g)
|
|||
}
|
||||
|
||||
entity_move(this, g);
|
||||
if (this->vel[0] == 0.0)
|
||||
if (this->vel[0] == 0.0 && this->vel[1] >= -0.0)
|
||||
this->player.dirx *= -1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue