diff options
| author | esquizo <esquizo+noreply@esquizo.net> | 2026-06-03 19:24:29 -0300 |
|---|---|---|
| committer | esquizo <esquizo+noreply@esquizo.net> | 2026-06-03 19:24:29 -0300 |
| commit | 94bdded9102bc2e2b2e4bded8f180749efda1b72 (patch) | |
| tree | 1a1dac5472b2797980193ce1439a1ca24f47aabf | |
| parent | 022b9bd5f910629ecbf837b38b3cd761c2f703ea (diff) | |
game: adicionado entity teleporter
| -rw-r--r-- | dat.h | 15 | ||||
| -rw-r--r-- | game.c | 11 | ||||
| -rwxr-xr-x | img2map | 9 | ||||
| -rw-r--r-- | map.png | bin | 655 -> 905 bytes | |||
| -rw-r--r-- | sdl3_main.c | 5 |
5 files changed, 40 insertions, 0 deletions
@@ -12,6 +12,7 @@ typedef struct { EPLAYER, EGHOST, EBULLET, + ETELEPORTER, LASTEntity, } type; @@ -20,6 +21,8 @@ typedef struct { float time; float life; bool alive; + + int telex, teley; } Entity; typedef struct { @@ -51,9 +54,21 @@ extern float player_x, player_y; extern int ghostcount; extern float ghostpositions[][2]; +extern struct { + int ftx, fty; + int ttx, tty; +} telemap[]; +extern int telemapsize; + +extern struct { + float x, y; +} teles[]; +extern int telessize; + extern Entity *player; extern bool shot; extern int shotx, shoty; extern bool moveleft, moveright, moveup, movedown; + @@ -63,6 +63,17 @@ entinit() e->life = 2; e->alive = true; } + + for(int i = 0; i < telessize; i++) { + Entity *e = allocentity(); + e->type = ETELEPORTER; + e->body.pos[0] = teles[i].x * ENTITY_SIZE * 2; + e->body.pos[1] = teles[i].y * ENTITY_SIZE * 2; + e->body.size[0] = ENTITY_SIZE; + e->body.size[1] = ENTITY_SIZE; + e->telex = floorf(teles[i].x); + e->teley = floorf(teles[i].y); + } } void @@ -10,6 +10,7 @@ map_pixels = [ ] player_position = (0, 0) ghosts = [] +teles = [] for y in range(height): linha = [] @@ -25,6 +26,9 @@ for y in range(height): if (r == 0xFF) and (g == 0x00) and (b == 0x00): ghosts.append((x, y)) + if (r == 0xFF) and (g == 0xFF) and (b == 0x00): + teles.append((x, y)) + map_pixels.append(valor) print(f"int map_width = {width};") @@ -33,6 +37,11 @@ print(f"float player_x = {player_position[0]};") print(f"float player_y = {player_position[1]};") print(f"int ghostcount = {len(ghosts)};") +print(f"int telessize = {len(teles)};") +print("struct { float x, y; } teles[] = {") +print("".join([ f"{{ .x = {str(x[0])}, .y = {str(x[1])} }}, " for x in teles ])) +print("};") + print("float ghostpositions[][2] = {") print("".join([ f"{{ {str(x[0])}, {str(x[1])} }}, " for x in ghosts ])) print("};") Binary files differdiff --git a/sdl3_main.c b/sdl3_main.c index 9780e3d..873a862 100644 --- a/sdl3_main.c +++ b/sdl3_main.c @@ -109,6 +109,11 @@ render(void) SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0x00, 0xFF); renderrect(e->body.pos, e->body.size); break; + + case ETELEPORTER: + SDL_SetRenderDrawColor(renderer, 0xFF, 0x00, 0xFF, 0xFF); + renderrect(e->body.pos, e->body.size); + break; } } } |
