summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/map/03
-rw-r--r--src/body.c30
-rw-r--r--src/body.h43
-rw-r--r--src/game.c912
-rw-r--r--src/game.h2
-rw-r--r--src/globals.c1
-rw-r--r--src/globals.h9
-rw-r--r--src/main.c31
-rw-r--r--src/map.c442
-rw-r--r--src/map.h3
-rw-r--r--src/player.c156
-rw-r--r--src/player.h28
-rw-r--r--src/room.c8
-rw-r--r--src/room.h14
14 files changed, 880 insertions, 802 deletions
diff --git a/data/map/0 b/data/map/0
index d6b0cd4..b4da7ea 100644
--- a/data/map/0
+++ b/data/map/0
@@ -1,7 +1,7 @@
0
.1..
r0r4r4r4r4r4r4r4r4r4r4r4r4r4r4r4r4r4r4r1
-r7= . . . . . . . . . . . . . . . . . r5
+r7= . . . . . . = . . . . . . . . . . r5
r7= . . . . . . . $1. . ^3. . . . . . r5
r7. . ^1. . . . . . . . . . . . . . . r5
r7. . . . . . . k . . . . . . . . . . r5
@@ -17,6 +17,7 @@ r7. . . . ^ . . . . . . . . . . . . . r5
r7. . . . . . . . . . . . . . . . . . r5
r2r6r6r6r6r6r6r6r6r6r6r6r6r6r6r6r6r6r6r3
+000+000=Save = F5
++000+000=Fullscreen = F11
+000+000=Load = F6
+000+000
+000+000
diff --git a/src/body.c b/src/body.c
index d0e7938..ef020df 100644
--- a/src/body.c
+++ b/src/body.c
@@ -1,9 +1,8 @@
#include "body.h"
-#include <SDL2/SDL_ttf.h>
-#include "room.h"
#include "globals.h"
-
+#include "room.h"
+#include <SDL2/SDL_ttf.h>
static void move(tt_body *b, int d)
{
@@ -15,11 +14,10 @@ static void move(tt_body *b, int d)
b->yrem = b->yrem % 1000;
}
-
void tt_body_move(int d)
{
tt_room *r = ttplayer.room;
- int i, j;
+ int i, j;
for (i = 0; i != TT_ROOM_H; ++i) {
for (j = 0; j != TT_ROOM_W; ++j) {
tt_body *w = r->walls[i][j];
@@ -29,38 +27,38 @@ void tt_body_move(int d)
for (i = 0; i != r->bodies_count; ++i) {
tt_body *b = r->bodies + i;
b->rem += d;
- int ex = b->x;
+ int ex = b->x;
int exr = b->xrem;
- int ey = b->y;
+ int ey = b->y;
int eyr = b->yrem;
move(b, d);
{
- SDL_Rect box = { b->x + 5, b->y + 2, 22, 28 };
+ SDL_Rect box = {b->x + 5, b->y + 2, 22, 28};
if (!tt_room_collide(r, &box) && !tt_room_out(r, &box)) continue;
}
- b->x = ex;
- b->y = ey;
+ b->x = ex;
+ b->y = ey;
b->xrem = exr;
b->yrem = eyr;
b->xvel *= -1;
move(b, d);
{
- SDL_Rect box = { b->x + 5, b->y + 2, 22, 28 };
+ SDL_Rect box = {b->x + 5, b->y + 2, 22, 28};
if (!tt_room_collide(r, &box) && !tt_room_out(r, &box)) continue;
}
- b->x = ex;
- b->y = ey;
+ b->x = ex;
+ b->y = ey;
b->xrem = exr;
b->yrem = eyr;
b->xvel *= -1;
b->yvel *= -1;
move(b, d);
{
- SDL_Rect box = { b->x + 5, b->y + 2, 22, 28 };
+ SDL_Rect box = {b->x + 5, b->y + 2, 22, 28};
if (!tt_room_collide(r, &box) && !tt_room_out(r, &box)) continue;
}
- b->x = ex;
- b->y = ey;
+ b->x = ex;
+ b->y = ey;
b->xrem = exr;
b->yrem = eyr;
b->xvel *= -1;
diff --git a/src/body.h b/src/body.h
index 33cab2f..1204c9c 100644
--- a/src/body.h
+++ b/src/body.h
@@ -1,33 +1,32 @@
#ifndef TT_INCLUDED_BODY
#define TT_INCLUDED_BODY
-
-enum { colact_grib = 1,
- colact_gulag,
- colact_instgulag,
- colact_key,
- colact_door };
+enum {
+ colact_grib = 1,
+ colact_gulag,
+ colact_instgulag,
+ colact_key,
+ colact_door
+};
typedef struct tt_body {
- int x;
- int y;
- int xrem;
- int yrem;
- int xvel;
- int yvel;
- int txrrow;
- int txrcol;
- int rem;
- int anim;
- int rate;
- int collision_act;
+ int x;
+ int y;
+ int xrem;
+ int yrem;
+ int xvel;
+ int yvel;
+ int txrrow;
+ int txrcol;
+ int rem;
+ int anim;
+ int rate;
+ int collision_act;
char *msg;
- int msglen;
- int isdoor;
+ int msglen;
+ int isdoor;
} tt_body;
-
void tt_body_move(int d);
-
#endif
diff --git a/src/game.c b/src/game.c
index c9b3fb2..1347fbc 100644
--- a/src/game.c
+++ b/src/game.c
@@ -1,26 +1,26 @@
#include "game.h"
+#include "globals.h"
+#include "map.h"
#include <SDL2/SDL.h>
#include <stdio.h>
-#include "map.h"
-#include "globals.h"
-
-int magic = 0;
+int magic = 0;
int first_gulag = 1;
+int fullscreen = 0;
static int ticks;
static char *readline(FILE *f)
{
- int c = fgetc(f);
- char *res = 0;
- int reslen = 0;
+ int c = fgetc(f);
+ char *res = 0;
+ int reslen = 0;
while (c != EOF && c != '\n') {
++reslen;
- res = realloc(res, reslen + 1);
+ res = realloc(res, reslen + 1);
res[reslen - 1] = c;
- c = fgetc(f);
+ c = fgetc(f);
}
res[reslen] = 0;
return res;
@@ -48,11 +48,11 @@ static void outnum(FILE *f, int n)
static int readnum(FILE *f)
{
int sign = 1;
- int n = 0;
- int c = fgetc(f);
+ int n = 0;
+ int c = fgetc(f);
if (c == '-') {
sign = -1;
- c = fgetc(f);
+ c = fgetc(f);
}
while (c != EOF && c != '\n') {
n *= 10;
@@ -66,11 +66,15 @@ static void save()
{
FILE *f = fopen("save", "w");
outnum(f, first_gulag);
- if (curmus == grib) fputs("g\n", f);
- else if (curmus == ussr) fputs("u\n", f);
- else if (curmus == stalin) fputs("s\n", f);
- else if (curmus == lenin) fputs("l\n", f);
- else fputs("0\n", f);
+ if (curmus == grib) fputs("g\n", f);
+ else if (curmus == ussr)
+ fputs("u\n", f);
+ else if (curmus == stalin)
+ fputs("s\n", f);
+ else if (curmus == lenin)
+ fputs("l\n", f);
+ else
+ fputs("0\n", f);
fputc(ttplayer.room - ttmap, f);
fputc('\n', f);
outnum(f, ttplayer.x);
@@ -101,7 +105,8 @@ static void save()
outnum(f, r->y);
outnum(f, r->w);
outnum(f, r->h);
- } else fputc('\n', f);
+ } else
+ fputc('\n', f);
tt_body *w = ttmap[i].walls[p][q];
if (w) {
fputs("1\n", f);
@@ -121,7 +126,8 @@ static void save()
outnum(f, w->msglen);
if (w->msg) fputs(w->msg, f);
fputc('\n', f);
- } else fputc('\n', f);
+ } else
+ fputc('\n', f);
}
}
outnum(f, ttmap[i].bodies_count);
@@ -154,9 +160,9 @@ static void save()
static void load()
{
- FILE *f = fopen("save", "r");
+ FILE *f = fopen("save", "r");
first_gulag = readnum(f);
- int c = fgetc(f);
+ int c = fgetc(f);
if (c == 'g') {
if (curmus != grib) {
curmus = grib;
@@ -184,22 +190,22 @@ static void load()
fgetc(f);
ttplayer.room = ttmap + fgetc(f);
fgetc(f);
- ttplayer.x = readnum(f);
- ttplayer.y = readnum(f);
- ttplayer.xrem = readnum(f);
- ttplayer.yrem = readnum(f);
- ttplayer.variant = readnum(f);
- ttplayer.rem = readnum(f);
- ttplayer.money = readnum(f);
- ttplayer.keys[0] = readnum(f);
- ttplayer.keys[1] = readnum(f);
- ttplayer.tobein_gulag = readnum(f);
- ttplayer.until_gulag = readnum(f);
- ttplayer.lenin_pos = readnum(f);
+ ttplayer.x = readnum(f);
+ ttplayer.y = readnum(f);
+ ttplayer.xrem = readnum(f);
+ ttplayer.yrem = readnum(f);
+ ttplayer.variant = readnum(f);
+ ttplayer.rem = readnum(f);
+ ttplayer.money = readnum(f);
+ ttplayer.keys[0] = readnum(f);
+ ttplayer.keys[1] = readnum(f);
+ ttplayer.tobein_gulag = readnum(f);
+ ttplayer.until_gulag = readnum(f);
+ ttplayer.lenin_pos = readnum(f);
ttplayer.lenin_pos_rem = readnum(f);
- ttplayer.lenin_vel = readnum(f);
- ttplayer.lenin_zhiv = readnum(f);
- ttplayer.lenin_rem = readnum(f);
+ ttplayer.lenin_vel = readnum(f);
+ ttplayer.lenin_zhiv = readnum(f);
+ ttplayer.lenin_rem = readnum(f);
tt_map_free();
int i;
for (i = '0'; i != '~'; ++i) {
@@ -207,54 +213,56 @@ static void load()
for (p = 0; p != TT_ROOM_H; ++p) {
for (q = 0; q != TT_ROOM_W; ++q) {
if (readnum(f)) {
- ttmap[i].floor[p][q] = malloc(sizeof(SDL_Rect));
+ ttmap[i].floor[p][q] = malloc(sizeof(SDL_Rect));
ttmap[i].floor[p][q]->x = readnum(f);
ttmap[i].floor[p][q]->y = readnum(f);
ttmap[i].floor[p][q]->w = readnum(f);
ttmap[i].floor[p][q]->h = readnum(f);
- } else ttmap[i].floor[p][q] = 0;
+ } else
+ ttmap[i].floor[p][q] = 0;
if (readnum(f)) {
tt_body *b = ttmap[i].walls[p][q] = malloc(sizeof(*b));
- b->x = readnum(f);
- b->y = readnum(f);
- b->xrem = readnum(f);
- b->yrem = readnum(f);
- b->xvel = readnum(f);
- b->yvel = readnum(f);
- b->txrrow = readnum(f);
- b->txrcol = readnum(f);
- b->rem = readnum(f);
- b->anim = readnum(f);
- b->rate = readnum(f);
- b->collision_act = readnum(f);
- b->isdoor = readnum(f);
- b->msglen = readnum(f);
+ b->x = readnum(f);
+ b->y = readnum(f);
+ b->xrem = readnum(f);
+ b->yrem = readnum(f);
+ b->xvel = readnum(f);
+ b->yvel = readnum(f);
+ b->txrrow = readnum(f);
+ b->txrcol = readnum(f);
+ b->rem = readnum(f);
+ b->anim = readnum(f);
+ b->rate = readnum(f);
+ b->collision_act = readnum(f);
+ b->isdoor = readnum(f);
+ b->msglen = readnum(f);
if (b->msglen) b->msg = readline(f);
else {
b->msg = 0;
fgetc(f);
}
- } else ttmap[i].walls[p][q] = 0;
+ } else
+ ttmap[i].walls[p][q] = 0;
}
}
ttmap[i].bodies_count = readnum(f);
- ttmap[i].bodies = malloc(ttmap[i].bodies_count * sizeof(tt_body));
+ ttmap[i].bodies = malloc(ttmap[i].bodies_count * sizeof(tt_body));
for (p = 0; p != ttmap[i].bodies_count; ++p) {
- tt_body *b = ttmap[i].bodies + p;
- b->x = readnum(f);
- b->y = readnum(f);
- b->xrem = readnum(f);
- b->yrem = readnum(f);
- b->xvel = readnum(f);
- b->yvel = readnum(f);
- b->txrrow = readnum(f);
- b->txrcol = readnum(f);
- b->rem = readnum(f);
- b->anim = readnum(f);
- b->rate = readnum(f);
+ tt_body *b = ttmap[i].bodies + p;
+ b->x = readnum(f);
+ b->y = readnum(f);
+ b->xrem = readnum(f);
+ b->yrem = readnum(f);
+ b->xvel = readnum(f);
+ b->yvel = readnum(f);
+ b->txrrow = readnum(f);
+ b->txrcol = readnum(f);
+ b->rem = readnum(f);
+ b->anim = readnum(f);
+ b->rate = readnum(f);
b->collision_act = readnum(f);
- b->isdoor = readnum(f);
- b->msglen = readnum(f);
+ b->isdoor = readnum(f);
+ b->msglen = readnum(f);
if (b->msglen) b->msg = readline(f);
else {
b->msg = 0;
@@ -274,7 +282,7 @@ static const char *gulagmsg = " GULAG HAS YOU";
static void directly_gulag(tt_body *b)
{
gulagmsg = " Communism is Indestructable";
- magic = tt_gotogulag;
+ magic = tt_gotogulag;
Mix_PlayMusic(ussr, -1);
curmus = ussr;
}
@@ -282,12 +290,12 @@ static void directly_gulag(tt_body *b)
static void togulag(tt_body *b)
{
ttplayer.tobein_gulag = 1;
- b->collision_act = 0;
- b->anim = 1;
- b->txrrow = 0;
- b->txrcol = 15;
- b->msg = 0;
- b->msglen = 0;
+ b->collision_act = 0;
+ b->anim = 1;
+ b->txrrow = 0;
+ b->txrcol = 15;
+ b->msg = 0;
+ b->msglen = 0;
}
static void gribtake(tt_body *b)
@@ -295,55 +303,56 @@ static void gribtake(tt_body *b)
curmus = grib;
Mix_PlayMusic(grib, -1);
b->collision_act = 0;
- b->anim = 1;
- b->txrrow = 0;
- b->txrcol = 15;
- b->msg = 0;
- b->msglen = 0;
+ b->anim = 1;
+ b->txrrow = 0;
+ b->txrcol = 15;
+ b->msg = 0;
+ b->msglen = 0;
ttplayer.variant = 1;
- magic = tt_gotofirstroom;
+ magic = tt_gotofirstroom;
}
static void keytake(tt_body *b)
{
ttplayer.keys[b->txrcol]++;
b->collision_act = 0;
- b->txrrow = 0;
- b->txrcol = 15;
- b->msg = 0;
- b->msglen = 0;
+ b->txrrow = 0;
+ b->txrcol = 15;
+ b->msg = 0;
+ b->msglen = 0;
}
static void doorcol(tt_body *b)
{
if (ttplayer.keys[b->txrrow - 4]) {
- int i;
- tt_room *r = ttplayer.room;
+ int i;
+ tt_room *r = ttplayer.room;
tt_body *part = 0;
for (i = 0; i != r->bodies_count; i++) {
- part = r->bodies + i;
+ part = r->bodies + i;
int dx = (part->x - b->x) / 32;
int xe = (part->x - b->x) % 32;
int dy = (part->y - b->y) / 32;
int ye = (part->y - b->y) % 32;
if (part->isdoor && !xe && !ye &&
- ((dx == 1 || dx == -1) ^ (dy == 1 || dy == -1))) break;
+ ((dx == 1 || dx == -1) ^ (dy == 1 || dy == -1)))
+ break;
}
free(r->walls[b->y / 32][b->x / 32]);
r->walls[b->y / 32][b->x / 32] = 0;
free(r->walls[part->y / 32][part->x / 32]);
r->walls[part->y / 32][part->x / 32] = 0;
ttplayer.keys[b->txrrow - 4]--;
- b->collision_act = 0;
- b->txrrow = 0;
- b->txrcol = 15;
- b->msg = 0;
- b->msglen = 0;
+ b->collision_act = 0;
+ b->txrrow = 0;
+ b->txrcol = 15;
+ b->msg = 0;
+ b->msglen = 0;
part->collision_act = 0;
- part->txrrow = 0;
- part->txrcol = 15;
- part->msg = 0;
- part->msglen = 0;
+ part->txrrow = 0;
+ part->txrcol = 15;
+ part->msg = 0;
+ part->msglen = 0;
}
}
@@ -351,9 +360,7 @@ static void step(int d)
{
int xw = ttplayer.xwalk * 200;
int yw = ttplayer.ywalk * 200;
- if (xw || yw) {
- ttplayer.rem += d;
- }
+ if (xw || yw) { ttplayer.rem += d; }
if (ttplayer.lenin_zhiv) {
int oldpos = ttplayer.lenin_pos;
ttplayer.lenin_rem += d;
@@ -369,30 +376,30 @@ static void step(int d)
if (!lenin_grib) {
lenin_grib = 1;
ttplayer.room->bodies_count++;
- ttplayer.room->bodies = realloc(
- ttplayer.room->bodies,
- sizeof(tt_body) * ttplayer.room->bodies_count
- );
- tt_body *b = ttplayer.room->bodies +
- ttplayer.room->bodies_count - 1;
- b->x = ttplayer.lenin_pos;
- b->y = 32;
- b->xrem = 0;
- b->yrem = 0;
- b->rem = 0;
- b->txrrow = 8;
- b->txrcol = rand() % 4;
- b->anim = 4;
- b->rate = 150 + (rand() % 50 - 25);
+ ttplayer.room->bodies =
+ realloc(ttplayer.room->bodies,
+ sizeof(tt_body) * ttplayer.room->bodies_count);
+ tt_body *b =
+ ttplayer.room->bodies + ttplayer.room->bodies_count - 1;
+ b->x = ttplayer.lenin_pos;
+ b->y = 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->rem = 0;
+ b->txrrow = 8;
+ b->txrcol = rand() % 4;
+ b->anim = 4;
+ b->rate = 150 + (rand() % 50 - 25);
b->collision_act = colact_instgulag;
- b->msg = 0;
- b->msglen = 0;
- b->yvel = rand() % 100 - 50;
- b->yvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50;
- b->xvel = rand() % 100 - 50;
- b->xvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50;
+ b->msg = 0;
+ b->msglen = 0;
+ b->yvel = rand() % 100 - 50;
+ b->yvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50;
+ b->xvel = rand() % 100 - 50;
+ b->xvel = b->yvel < 0 ? b->yvel - 50 : b->yvel + 50;
}
- } else if (lenin_grib) lenin_grib = 0;
+ } else if (lenin_grib)
+ lenin_grib = 0;
}
if (ttplayer.tobein_gulag && ttplayer.until_gulag > 0) {
if (first_gulag) {
@@ -421,21 +428,21 @@ static void step(int d)
ttplayer.xrem = ttplayer.xrem % 1000;
ttplayer.yrem = ttplayer.yrem % 1000;
{
- SDL_Rect box = { ttplayer.x, ttplayer.y, 32, 32 };
- int out = tt_room_out(ttplayer.room, &box);
+ SDL_Rect box = {ttplayer.x, ttplayer.y, 32, 32};
+ int out = tt_room_out(ttplayer.room, &box);
if (out) {
ttplayer.money--;
if (ttplayer.room->neighbours[out - 1] == ttmap + 'L') {
Mix_PauseMusic();
curmus = 0;
- magic = tt_mausoleum;
+ magic = tt_mausoleum;
} else {
magic = tt_changeroom + out - 1;
}
}
}
{
- SDL_Rect box = { ttplayer.x, ttplayer.y, 32, 32 };
+ SDL_Rect box = {ttplayer.x, ttplayer.y, 32, 32};
if (tt_room_collide(ttplayer.room, &box)) {
ttplayer.x = x;
ttplayer.y = y;
@@ -443,30 +450,30 @@ static void step(int d)
}
tt_body_move(d);
{
- int i;
- SDL_Rect box = { ttplayer.x, ttplayer.y, 32, 32 };
+ int i;
+ SDL_Rect box = {ttplayer.x, ttplayer.y, 32, 32};
for (i = 0; i != ttplayer.room->bodies_count; ++i) {
tt_body *b = ttplayer.room->bodies + i;
if (b->isdoor) {
- SDL_Rect body = { b->x - 2, b->y - 2, 36, 36 };
+ SDL_Rect body = {b->x - 2, b->y - 2, 36, 36};
if (SDL_HasIntersection(&body, &box)) {
switch (b->collision_act) {
- case colact_grib: gribtake(b); break;
- case colact_gulag: togulag(b); break;
+ case colact_grib: gribtake(b); break;
+ case colact_gulag: togulag(b); break;
case colact_instgulag: directly_gulag(b); break;
- case colact_key: keytake(b); break;
- case colact_door: doorcol(b); break;
+ case colact_key: keytake(b); break;
+ case colact_door: doorcol(b); break;
}
}
} else {
- SDL_Rect body = { 4 + b->x, 4 + b->y, 24, 24 };
+ SDL_Rect body = {4 + b->x, 4 + b->y, 24, 24};
if (SDL_HasIntersection(&body, &box)) {
switch (b->collision_act) {
- case colact_grib: gribtake(b); break;
- case colact_gulag: togulag(b); break;
+ case colact_grib: gribtake(b); break;
+ case colact_gulag: togulag(b); break;
case colact_instgulag: directly_gulag(b); break;
- case colact_key: keytake(b); break;
- case colact_door: doorcol(b); break;
+ case colact_key: keytake(b); break;
+ case colact_door: doorcol(b); break;
}
}
}
@@ -474,11 +481,10 @@ static void step(int d)
}
}
-
static int q = 0;
static int keyw, keys, keya, keyd, arru, arrr, arrd, arrl;
-static int min(int a, int b) { return a < b ? a : b; }
+static int min(int a, int b) { return a < b ? a : b; }
static void gotofirstroom()
{
@@ -487,45 +493,62 @@ static void gotofirstroom()
int newticks = SDL_GetTicks();
SDL_SetRenderDrawBlendMode(ttrdr, SDL_BLENDMODE_BLEND);
while (!q && newticks < ticks + 800) {
- int delta = newticks - ticks;
+ int delta = newticks - ticks;
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) q = 1;
else if (e.type == SDL_KEYDOWN) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 1;
- else if (code == SDL_SCANCODE_S) keys = 1;
- else if (code == SDL_SCANCODE_A) keya = 1;
- else if (code == SDL_SCANCODE_D) keyd = 1;
- else if (code == SDL_SCANCODE_UP) arru = 1;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 1;
- else if (code == SDL_SCANCODE_DOWN) arrd = 1;
- else if (code == SDL_SCANCODE_LEFT) arrl = 1;
+ if (code == SDL_SCANCODE_W) keyw = 1;
+ else if (code == SDL_SCANCODE_S)
+ keys = 1;
+ else if (code == SDL_SCANCODE_A)
+ keya = 1;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 1;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 1;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 1;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 1;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 1;
+ else if (code == SDL_SCANCODE_F11) {
+ SDL_SetWindowFullscreen(
+ ttwdw, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
+ fullscreen = !fullscreen;
+ }
} else if (e.type == SDL_KEYUP) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 0;
- else if (code == SDL_SCANCODE_S) keys = 0;
- else if (code == SDL_SCANCODE_A) keya = 0;
- else if (code == SDL_SCANCODE_D) keyd = 0;
- else if (code == SDL_SCANCODE_UP) arru = 0;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 0;
- else if (code == SDL_SCANCODE_DOWN) arrd = 0;
- else if (code == SDL_SCANCODE_LEFT) arrl = 0;
+ if (code == SDL_SCANCODE_W) keyw = 0;
+ else if (code == SDL_SCANCODE_S)
+ keys = 0;
+ else if (code == SDL_SCANCODE_A)
+ keya = 0;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 0;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 0;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 0;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 0;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 0;
}
}
SDL_RenderClear(ttrdr);
SDL_SetRenderDrawColor(ttrdr, 0, 0, 0, min(255, delta * 256 / 600));
tt_player_draw();
- SDL_Rect d = { 14, 14, 32 * 20, 32 * 16 };
+ SDL_Rect d = {14, 14, 32 * 20, 32 * 16};
SDL_RenderFillRect(ttrdr, &d);
{
- SDL_Rect src = { 0, 16 * 6, 16, 16 };
- SDL_Rect dst = { 14 + ttplayer.x - delta +
- rand() % delta,
- 14 + ttplayer.y - delta +
- rand() % delta,
- 32 + delta / 2 + (rand() % delta),
- 32 + delta / 2 + (rand() % delta) };
+ SDL_Rect src = {0, 16 * 6, 16, 16};
+ SDL_Rect dst = {14 + ttplayer.x - delta + rand() % delta,
+ 14 + ttplayer.y - delta + rand() % delta,
+ 32 + delta / 2 + (rand() % delta),
+ 32 + delta / 2 + (rand() % delta)};
SDL_RenderCopy(ttrdr, tttxr, &src, &dst);
}
SDL_RenderPresent(ttrdr);
@@ -534,78 +557,93 @@ static void gotofirstroom()
}
SDL_SetRenderDrawBlendMode(ttrdr, mode);
ttplayer.room = ttmap + '0';
- magic = 0;
- ticks = SDL_GetTicks();
+ magic = 0;
+ ticks = SDL_GetTicks();
}
static void gotogulag()
{
- int roomchanged = 0;
+ int roomchanged = 0;
SDL_BlendMode mode;
SDL_GetRenderDrawBlendMode(ttrdr, &mode);
int newticks = SDL_GetTicks();
SDL_SetRenderDrawBlendMode(ttrdr, SDL_BLENDMODE_BLEND);
while (!q && newticks < ticks + 5000) {
- int delta = newticks - ticks;
+ int delta = newticks - ticks;
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) q = 1;
else if (e.type == SDL_KEYDOWN) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 1;
- else if (code == SDL_SCANCODE_S) keys = 1;
- else if (code == SDL_SCANCODE_A) keya = 1;
- else if (code == SDL_SCANCODE_D) keyd = 1;
- else if (code == SDL_SCANCODE_UP) arru = 1;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 1;
- else if (code == SDL_SCANCODE_DOWN) arrd = 1;
- else if (code == SDL_SCANCODE_LEFT) arrl = 1;
+ if (code == SDL_SCANCODE_W) keyw = 1;
+ else if (code == SDL_SCANCODE_S)
+ keys = 1;
+ else if (code == SDL_SCANCODE_A)
+ keya = 1;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 1;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 1;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 1;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 1;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 1;
+ else if (code == SDL_SCANCODE_F11) {
+ SDL_SetWindowFullscreen(
+ ttwdw, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
+ fullscreen = !fullscreen;
+ }
} else if (e.type == SDL_KEYUP) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 0;
- else if (code == SDL_SCANCODE_S) keys = 0;
- else if (code == SDL_SCANCODE_A) keya = 0;
- else if (code == SDL_SCANCODE_D) keyd = 0;
- else if (code == SDL_SCANCODE_UP) arru = 0;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 0;
- else if (code == SDL_SCANCODE_DOWN) arrd = 0;
- else if (code == SDL_SCANCODE_LEFT) arrl = 0;
+ if (code == SDL_SCANCODE_W) keyw = 0;
+ else if (code == SDL_SCANCODE_S)
+ keys = 0;
+ else if (code == SDL_SCANCODE_A)
+ keya = 0;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 0;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 0;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 0;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 0;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 0;
}
}
SDL_RenderClear(ttrdr);
- if (delta < 4200) SDL_SetRenderDrawColor(ttrdr, 0, 0, 0,
- min(255, delta * 256 / 800));
+ if (delta < 4200)
+ SDL_SetRenderDrawColor(ttrdr, 0, 0, 0, min(255, delta * 256 / 800));
else {
if (!roomchanged) {
- roomchanged = 1;
- ttplayer.room = ttmap + 'G';
+ roomchanged = 1;
+ ttplayer.room = ttmap + 'G';
ttplayer.lenin_zhiv = 0;
- ttplayer.x = 32 * 13;
- ttplayer.y = 32 * 11;
+ ttplayer.x = 32 * 13;
+ ttplayer.y = 32 * 11;
}
SDL_SetRenderDrawColor(ttrdr, 0, 0, 0,
255 - (delta - 4200) * 256 / 800);
}
tt_player_draw();
- SDL_Rect d = { 14, 14, 32 * 20, 32 * 16 };
+ SDL_Rect d = {14, 14, 32 * 20, 32 * 16};
SDL_RenderFillRect(ttrdr, &d);
if (delta < 4200) {
- SDL_Color c = { 128, 20, 20, min(255, delta * 256 / 800) };
- SDL_Surface *surf = TTF_RenderText_Blended(
- ttfont, gulagmsg, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, surf);
- SDL_Rect dst = { 14, 14 + 32 * 7,
- surf->w * 2, surf->h * 2 };
+ SDL_Color c = {128, 20, 20, min(255, delta * 256 / 800)};
+ SDL_Surface *surf = TTF_RenderText_Blended(ttfont, gulagmsg, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, surf);
+ SDL_Rect dst = {14, 14 + 32 * 7, surf->w * 2, surf->h * 2};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(surf);
} else {
- SDL_Color c = { 128, 20, 20, 255 - (delta - 4200) * 256 / 800 };
- SDL_Surface *surf = TTF_RenderText_Blended(
- ttfont, gulagmsg, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, surf);
- SDL_Rect dst = { 14, 14 + 32 * 7,
- surf->w * 2, surf->h * 2 };
+ SDL_Color c = {128, 20, 20, 255 - (delta - 4200) * 256 / 800};
+ SDL_Surface *surf = TTF_RenderText_Blended(ttfont, gulagmsg, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, surf);
+ SDL_Rect dst = {14, 14 + 32 * 7, surf->w * 2, surf->h * 2};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(surf);
@@ -621,318 +659,392 @@ static void gotogulag()
static void mausoleum()
{
- int roomchanged = 0;
+ int roomchanged = 0;
SDL_BlendMode mode;
SDL_GetRenderDrawBlendMode(ttrdr, &mode);
int newticks = SDL_GetTicks();
SDL_SetRenderDrawBlendMode(ttrdr, SDL_BLENDMODE_BLEND);
while (!q && newticks < ticks + 1000) {
- int delta = newticks - ticks;
+ int delta = newticks - ticks;
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) q = 1;
else if (e.type == SDL_KEYDOWN) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 1;
- else if (code == SDL_SCANCODE_S) keys = 1;
- else if (code == SDL_SCANCODE_A) keya = 1;
- else if (code == SDL_SCANCODE_D) keyd = 1;
- else if (code == SDL_SCANCODE_UP) arru = 1;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 1;
- else if (code == SDL_SCANCODE_DOWN) arrd = 1;
- else if (code == SDL_SCANCODE_LEFT) arrl = 1;
+ if (code == SDL_SCANCODE_W) keyw = 1;
+ else if (code == SDL_SCANCODE_S)
+ keys = 1;
+ else if (code == SDL_SCANCODE_A)
+ keya = 1;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 1;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 1;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 1;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 1;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 1;
+ else if (code == SDL_SCANCODE_F11) {
+ SDL_SetWindowFullscreen(
+ ttwdw, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
+ fullscreen = !fullscreen;
+ }
} else if (e.type == SDL_KEYUP) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 0;
- else if (code == SDL_SCANCODE_S) keys = 0;
- else if (code == SDL_SCANCODE_A) keya = 0;
- else if (code == SDL_SCANCODE_D) keyd = 0;
- else if (code == SDL_SCANCODE_UP) arru = 0;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 0;
- else if (code == SDL_SCANCODE_DOWN) arrd = 0;
- else if (code == SDL_SCANCODE_LEFT) arrl = 0;
+ if (code == SDL_SCANCODE_W) keyw = 0;
+ else if (code == SDL_SCANCODE_S)
+ keys = 0;
+ else if (code == SDL_SCANCODE_A)
+ keya = 0;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 0;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 0;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 0;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 0;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 0;
}
}
SDL_RenderClear(ttrdr);
- if (delta < 500) SDL_SetRenderDrawColor(ttrdr, 0, 0, 0,
- min(255, delta * 256 / 500));
+ if (delta < 500)
+ SDL_SetRenderDrawColor(ttrdr, 0, 0, 0, min(255, delta * 256 / 500));
else {
if (!roomchanged) {
- roomchanged = 1;
+ roomchanged = 1;
ttplayer.room = ttmap + 'L';
- ttplayer.y = TT_ROOM_H * 32 - 64;
+ ttplayer.y = TT_ROOM_H * 32 - 64;
}
SDL_SetRenderDrawColor(ttrdr, 0, 0, 0,
255 - (delta - 500) * 256 / 500);
}
tt_player_draw();
if (delta >= 500) {
- SDL_Rect src = { 96, 16 * 12, 64, 48 };
- SDL_Rect dst = { 14 + ttplayer.lenin_pos - 32,
- 110, 128, 96 };
+ SDL_Rect src = {96, 16 * 12, 64, 48};
+ SDL_Rect dst = {14 + ttplayer.lenin_pos - 32, 110, 128, 96};
SDL_RenderCopy(ttrdr, tttxr, &src, &dst);
}
- SDL_Rect d = { 14, 14, 32 * 20, 32 * 16 };
+ SDL_Rect d = {14, 14, 32 * 20, 32 * 16};
SDL_RenderFillRect(ttrdr, &d);
SDL_RenderPresent(ttrdr);
newticks = SDL_GetTicks();
}
- ticks = newticks;
+ ticks = newticks;
newticks = SDL_GetTicks();
Mix_PlayMusic(lenin, -1);
curmus = lenin;
while (!q && newticks < ticks + 14300) {
- int delta = newticks - ticks;
+ int delta = newticks - ticks;
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) q = 1;
else if (e.type == SDL_KEYDOWN) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 1;
- else if (code == SDL_SCANCODE_S) keys = 1;
- else if (code == SDL_SCANCODE_A) keya = 1;
- else if (code == SDL_SCANCODE_D) keyd = 1;
- else if (code == SDL_SCANCODE_UP) arru = 1;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 1;
- else if (code == SDL_SCANCODE_DOWN) arrd = 1;
- else if (code == SDL_SCANCODE_LEFT) arrl = 1;
+ if (code == SDL_SCANCODE_W) keyw = 1;
+ else if (code == SDL_SCANCODE_S)
+ keys = 1;
+ else if (code == SDL_SCANCODE_A)
+ keya = 1;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 1;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 1;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 1;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 1;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 1;
+ else if (code == SDL_SCANCODE_F11) {
+ SDL_SetWindowFullscreen(
+ ttwdw, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
+ fullscreen = !fullscreen;
+ }
} else if (e.type == SDL_KEYUP) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 0;
- else if (code == SDL_SCANCODE_S) keys = 0;
- else if (code == SDL_SCANCODE_A) keya = 0;
- else if (code == SDL_SCANCODE_D) keyd = 0;
- else if (code == SDL_SCANCODE_UP) arru = 0;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 0;
- else if (code == SDL_SCANCODE_DOWN) arrd = 0;
- else if (code == SDL_SCANCODE_LEFT) arrl = 0;
+ if (code == SDL_SCANCODE_W) keyw = 0;
+ else if (code == SDL_SCANCODE_S)
+ keys = 0;
+ else if (code == SDL_SCANCODE_A)
+ keya = 0;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 0;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 0;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 0;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 0;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 0;
}
}
SDL_RenderClear(ttrdr);
tt_player_draw();
{
- int lenin_size = delta * (48 - 4 - 6) / 14300;
- SDL_Rect src = { 32, 16 * 12 + 4, 32, lenin_size };
- SDL_Rect dst = { 14 + ttplayer.lenin_pos,
- 14 + 32 + 96 - 8 - lenin_size * 2,
- 64, lenin_size * 2 };
+ int lenin_size = delta * (48 - 4 - 6) / 14300;
+ SDL_Rect src = {32, 16 * 12 + 4, 32, lenin_size};
+ SDL_Rect dst = {14 + ttplayer.lenin_pos,
+ 14 + 32 + 96 - 8 - lenin_size * 2, 64,
+ lenin_size * 2};
SDL_RenderCopy(ttrdr, tttxr, &src, &dst);
}
{
- SDL_Rect src = { 96, 16 * 12, 64, 48 };
- SDL_Rect dst = { 14 + ttplayer.lenin_pos - 32,
- 110, 128, 96 };
+ SDL_Rect src = {96, 16 * 12, 64, 48};
+ SDL_Rect dst = {14 + ttplayer.lenin_pos - 32, 110, 128, 96};
SDL_RenderCopy(ttrdr, tttxr, &src, &dst);
}
SDL_RenderPresent(ttrdr);
newticks = SDL_GetTicks();
}
ttplayer.lenin_zhiv = 1;
- magic = 0;
- ticks = SDL_GetTicks();
+ magic = 0;
+ ticks = SDL_GetTicks();
}
void changeroom(int out)
{
int newticks = SDL_GetTicks();
while (!q && newticks < ticks + 500) {
- int delta = newticks - ticks;
+ int delta = newticks - ticks;
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) q = 1;
else if (e.type == SDL_KEYDOWN) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 1;
- else if (code == SDL_SCANCODE_S) keys = 1;
- else if (code == SDL_SCANCODE_A) keya = 1;
- else if (code == SDL_SCANCODE_D) keyd = 1;
- else if (code == SDL_SCANCODE_UP) arru = 1;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 1;
- else if (code == SDL_SCANCODE_DOWN) arrd = 1;
- else if (code == SDL_SCANCODE_LEFT) arrl = 1;
+ if (code == SDL_SCANCODE_W) keyw = 1;
+ else if (code == SDL_SCANCODE_S)
+ keys = 1;
+ else if (code == SDL_SCANCODE_A)
+ keya = 1;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 1;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 1;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 1;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 1;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 1;
+ else if (code == SDL_SCANCODE_F11) {
+ SDL_SetWindowFullscreen(
+ ttwdw, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
+ fullscreen = !fullscreen;
+ }
} else if (e.type == SDL_KEYUP) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 0;
- else if (code == SDL_SCANCODE_S) keys = 0;
- else if (code == SDL_SCANCODE_A) keya = 0;
- else if (code == SDL_SCANCODE_D) keyd = 0;
- else if (code == SDL_SCANCODE_UP) arru = 0;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 0;
- else if (code == SDL_SCANCODE_DOWN) arrd = 0;
- else if (code == SDL_SCANCODE_LEFT) arrl = 0;
+ if (code == SDL_SCANCODE_W) keyw = 0;
+ else if (code == SDL_SCANCODE_S)
+ keys = 0;
+ else if (code == SDL_SCANCODE_A)
+ keya = 0;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 0;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 0;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 0;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 0;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 0;
}
}
SDL_RenderClear(ttrdr);
- int tox = (out == 3) - (out == 1);
- int toy = (out == 0) - (out == 2);
+ int tox = (out == 3) - (out == 1);
+ int toy = (out == 0) - (out == 2);
int transx = tox * (delta * TT_ROOM_W * 32 / 500);
int transy = toy * (delta * TT_ROOM_H * 32 / 500);
- int playx = tox * (delta * -32 / 500);
- int playy = toy * (delta * -32 / 500);
- int fullx = tox * TT_ROOM_W * -32;
- int fully = toy * TT_ROOM_H * -32;
+ int playx = tox * (delta * -32 / 500);
+ int playy = toy * (delta * -32 / 500);
+ int fullx = tox * TT_ROOM_W * -32;
+ int fully = toy * TT_ROOM_H * -32;
{
- int i, j;
- tt_room *r = ttplayer.room->neighbours[out];
- for (i = 0; i != TT_ROOM_H; ++i) {
- for (j = 0; j != TT_ROOM_W; ++j) {
- SDL_Rect d = { 14 + j * 32 + fullx + transx,
- 14 + i * 32 + fully + transy,
- 32, 32 };
- SDL_Rect *f = r->floor[i][j];
- tt_body *w = r->walls[i][j];
- if (f) SDL_RenderCopy(ttrdr, tttxr, f, &d);
- if (w) {
+ int i, j;
+ tt_room *r = ttplayer.room->neighbours[out];
+ for (i = 0; i != TT_ROOM_H; ++i) {
+ for (j = 0; j != TT_ROOM_W; ++j) {
+ SDL_Rect d = {14 + j * 32 + fullx + transx,
+ 14 + i * 32 + fully + transy, 32, 32};
+ SDL_Rect *f = r->floor[i][j];
+ tt_body * w = r->walls[i][j];
+ if (f) SDL_RenderCopy(ttrdr, tttxr, f, &d);
+ if (w) {
+ SDL_Rect s = {
+ (w->txrcol * w->anim + w->rem / w->rate % w->anim) *
+ 16,
+ w->txrrow * 16, 16, 16};
+ SDL_RenderCopy(ttrdr, tttxr, &s, &d);
+ }
+ }
+ }
+
+ for (i = 0; i != r->bodies_count; ++i) {
+ tt_body *b = r->bodies + i;
SDL_Rect s = {
- (w->txrcol * w->anim + w->rem / w->rate % w->anim) * 16,
- w->txrrow * 16, 16, 16
- };
+ (b->txrcol * b->anim + b->rem / b->rate % b->anim) * 16,
+ b->txrrow * 16, 16, 16};
+ SDL_Rect d = {14 + b->x + fullx + transx,
+ 14 + b->y + fully + transy, 32, 32};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
+ if (b->msg) {
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, b->msg, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + b->x + fullx + transx,
+ 20 + b->y + fully + transy, s->w, s->h};
+ SDL_RenderCopy(ttrdr, t, 0, &dst);
+ SDL_DestroyTexture(t);
+ SDL_FreeSurface(s);
+ }
}
}
- }
-
- for (i = 0; i != r->bodies_count; ++i) {
- tt_body *b = r->bodies + i;
- SDL_Rect s = {
- (b->txrcol * b->anim + b->rem / b->rate % b->anim) * 16,
- b->txrrow * 16, 16, 16
- };
- SDL_Rect d = { 14 + b->x + fullx + transx,
- 14 + b->y + fully + transy,
- 32, 32 };
- SDL_RenderCopy(ttrdr, tttxr, &s, &d);
- if (b->msg) {
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, b->msg, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + b->x + fullx + transx,
- 20 + b->y + fully + transy,
- s->w, s->h };
- SDL_RenderCopy(ttrdr, t, 0, &dst);
- SDL_DestroyTexture(t);
- SDL_FreeSurface(s);
- }
- }
- }
{
- int i, j;
- tt_room *r = ttplayer.room;
- for (i = 0; i != TT_ROOM_H; ++i) {
- for (j = 0; j != TT_ROOM_W; ++j) {
- SDL_Rect d = { 14 + j * 32 + transx, 14 + i * 32 + transy,
- 32, 32 };
- SDL_Rect *f = r->floor[i][j];
- tt_body *w = r->walls[i][j];
- if (f) SDL_RenderCopy(ttrdr, tttxr, f, &d);
- if (w) {
+ int i, j;
+ tt_room *r = ttplayer.room;
+ for (i = 0; i != TT_ROOM_H; ++i) {
+ for (j = 0; j != TT_ROOM_W; ++j) {
+ SDL_Rect d = {14 + j * 32 + transx, 14 + i * 32 + transy,
+ 32, 32};
+ SDL_Rect *f = r->floor[i][j];
+ tt_body * w = r->walls[i][j];
+ if (f) SDL_RenderCopy(ttrdr, tttxr, f, &d);
+ if (w) {
+ SDL_Rect s = {
+ (w->txrcol * w->anim + w->rem / w->rate % w->anim) *
+ 16,
+ w->txrrow * 16, 16, 16};
+ SDL_RenderCopy(ttrdr, tttxr, &s, &d);
+ }
+ }
+ }
+
+ for (i = 0; i != r->bodies_count; ++i) {
+ tt_body *b = r->bodies + i;
SDL_Rect s = {
- (w->txrcol * w->anim + w->rem / w->rate % w->anim) * 16,
- w->txrrow * 16, 16, 16
- };
+ (b->txrcol * b->anim + b->rem / b->rate % b->anim) * 16,
+ b->txrrow * 16, 16, 16};
+ SDL_Rect d = {14 + b->x + transx, 14 + b->y + transy, 32, 32};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
+ if (b->msg) {
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, b->msg, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + b->x + transx, 20 + b->y + transy,
+ s->w, s->h};
+ SDL_RenderCopy(ttrdr, t, 0, &dst);
+ SDL_DestroyTexture(t);
+ SDL_FreeSurface(s);
+ }
}
- }
- }
-
- for (i = 0; i != r->bodies_count; ++i) {
- tt_body *b = r->bodies + i;
- SDL_Rect s = {
- (b->txrcol * b->anim + b->rem / b->rate % b->anim) * 16,
- b->txrrow * 16, 16, 16
- };
- SDL_Rect d = { 14 + b->x + transx, 14 + b->y + transy, 32, 32 };
- SDL_RenderCopy(ttrdr, tttxr, &s, &d);
- if (b->msg) {
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, b->msg, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + b->x + transx, 20 + b->y + transy,
- s->w, s->h };
- SDL_RenderCopy(ttrdr, t, 0, &dst);
- SDL_DestroyTexture(t);
- SDL_FreeSurface(s);
- }
- }
- SDL_Rect d = { 14 + ttplayer.x + transx + playx,
- 14 + ttplayer.y + transy + playy,
- 32, 32 };
- int dir = 0;
- if (ttplayer.xwalk == 1) dir = 6;
- else if (ttplayer.xwalk == -1) dir = 2;
- else if (ttplayer.ywalk == -1) dir = 4;
- SDL_Rect s = { 16 * (8 * ttplayer.variant +
- dir + (ttplayer.rem / 100 % 2)),
- 16 * 6,
- 16, 16 };
- SDL_RenderCopy(ttrdr, tttxr, &s, &d);
+ SDL_Rect d = {14 + ttplayer.x + transx + playx,
+ 14 + ttplayer.y + transy + playy, 32, 32};
+ int dir = 0;
+ if (ttplayer.xwalk == 1) dir = 6;
+ else if (ttplayer.xwalk == -1)
+ dir = 2;
+ else if (ttplayer.ywalk == -1)
+ dir = 4;
+ SDL_Rect s = {
+ 16 * (8 * ttplayer.variant + dir + (ttplayer.rem / 100 % 2)),
+ 16 * 6, 16, 16};
+ SDL_RenderCopy(ttrdr, tttxr, &s, &d);
}
{
- SDL_Rect d = { 0, 0, 14, 540 };
+ SDL_Rect d = {0, 0, 14, 540};
SDL_RenderFillRect(ttrdr, &d);
}
{
- SDL_Rect d = { 0, 0, 950, 14 };
+ SDL_Rect d = {0, 0, 950, 14};
SDL_RenderFillRect(ttrdr, &d);
}
{
- SDL_Rect d = { 14 + TT_ROOM_W * 32, 0,
- 950 - 14 - TT_ROOM_W * 32, 540 };
+ SDL_Rect d = {14 + TT_ROOM_W * 32, 0, 950 - 14 - TT_ROOM_W * 32,
+ 540};
SDL_RenderFillRect(ttrdr, &d);
}
{
- SDL_Rect d = { 0, 14 + TT_ROOM_H * 32,
- 950, 540 - 14 - TT_ROOM_H * 32 };
+ SDL_Rect d = {0, 14 + TT_ROOM_H * 32, 950,
+ 540 - 14 - TT_ROOM_H * 32};
SDL_RenderFillRect(ttrdr, &d);
}
SDL_RenderPresent(ttrdr);
newticks = SDL_GetTicks();
}
- if (out == 0) ttplayer.y = TT_ROOM_H * 32 - 32;
- else if (out == 1) ttplayer.x = 0;
- else if (out == 2) ttplayer.y = 0;
- else if (out == 3) ttplayer.x = TT_ROOM_W * 32 - 32;
+ if (out == 0) ttplayer.y = TT_ROOM_H * 32 - 32;
+ else if (out == 1)
+ ttplayer.x = 0;
+ else if (out == 2)
+ ttplayer.y = 0;
+ else if (out == 3)
+ ttplayer.x = TT_ROOM_W * 32 - 32;
ttplayer.room = ttplayer.room->neighbours[out];
- ticks = SDL_GetTicks();
- magic = 0;
+ ticks = SDL_GetTicks();
+ magic = 0;
}
void tt_mainloop()
{
keyw = keya = keys = keyd = arru = arrr = arrd = arrl = 0;
- ticks = SDL_GetTicks();
+ ticks = SDL_GetTicks();
while (!q) {
SDL_Event e;
while (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) q = 1;
else if (e.type == SDL_KEYDOWN) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 1;
- else if (code == SDL_SCANCODE_S) keys = 1;
- else if (code == SDL_SCANCODE_A) keya = 1;
- else if (code == SDL_SCANCODE_D) keyd = 1;
- else if (code == SDL_SCANCODE_UP) arru = 1;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 1;
- else if (code == SDL_SCANCODE_DOWN) arrd = 1;
- else if (code == SDL_SCANCODE_LEFT) arrl = 1;
- else if (code == SDL_SCANCODE_F5) save();
- else if (code == SDL_SCANCODE_F6) load();
+ if (code == SDL_SCANCODE_W) keyw = 1;
+ else if (code == SDL_SCANCODE_S)
+ keys = 1;
+ else if (code == SDL_SCANCODE_A)
+ keya = 1;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 1;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 1;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 1;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 1;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 1;
+ else if (code == SDL_SCANCODE_F5)
+ save();
+ else if (code == SDL_SCANCODE_F6)
+ load();
+ else if (code == SDL_SCANCODE_F11) {
+ SDL_SetWindowFullscreen(
+ ttwdw, fullscreen ? 0 : SDL_WINDOW_FULLSCREEN);
+ fullscreen = !fullscreen;
+ }
} else if (e.type == SDL_KEYUP) {
int code = e.key.keysym.scancode;
- if (code == SDL_SCANCODE_W) keyw = 0;
- else if (code == SDL_SCANCODE_S) keys = 0;
- else if (code == SDL_SCANCODE_A) keya = 0;
- else if (code == SDL_SCANCODE_D) keyd = 0;
- else if (code == SDL_SCANCODE_UP) arru = 0;
- else if (code == SDL_SCANCODE_RIGHT) arrr = 0;
- else if (code == SDL_SCANCODE_DOWN) arrd = 0;
- else if (code == SDL_SCANCODE_LEFT) arrl = 0;
+ if (code == SDL_SCANCODE_W) keyw = 0;
+ else if (code == SDL_SCANCODE_S)
+ keys = 0;
+ else if (code == SDL_SCANCODE_A)
+ keya = 0;
+ else if (code == SDL_SCANCODE_D)
+ keyd = 0;
+ else if (code == SDL_SCANCODE_UP)
+ arru = 0;
+ else if (code == SDL_SCANCODE_RIGHT)
+ arrr = 0;
+ else if (code == SDL_SCANCODE_DOWN)
+ arrd = 0;
+ else if (code == SDL_SCANCODE_LEFT)
+ arrl = 0;
}
}
ttplayer.ywalk = (keys | arrd) - (keyw | arru);
ttplayer.xwalk = (keyd | arrr) - (keya | arrl);
- int newticks = SDL_GetTicks();
+ int newticks = SDL_GetTicks();
step(newticks - ticks);
ticks = newticks;
SDL_RenderClear(ttrdr);
diff --git a/src/game.h b/src/game.h
index c660ec9..006c592 100644
--- a/src/game.h
+++ b/src/game.h
@@ -1,12 +1,10 @@
#ifndef TT_INCLUDED_GAME
#define TT_INCLUDED_GAME
-
enum { tt_gotofirstroom = 1, tt_gotogulag, tt_mausoleum, tt_changeroom };
extern int magic;
void tt_mainloop();
-
#endif
diff --git a/src/globals.c b/src/globals.c
index 69dd671..7577c41 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -1,5 +1,6 @@
#include "globals.h"
+SDL_Window *ttwdw;
TTF_Font *ttfont;
diff --git a/src/globals.h b/src/globals.h
index c17732c..bfd6c5e 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -1,13 +1,13 @@
#ifndef TT_INCLUDED_GLOBALS
#define TT_INCLUDED_GLOBALS
-
+#include "player.h"
+#include "room.h"
#include <SDL2/SDL.h>
-#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_mixer.h>
-#include "room.h"
-#include "player.h"
+#include <SDL2/SDL_ttf.h>
+extern SDL_Window *ttwdw;
extern TTF_Font *ttfont;
@@ -25,5 +25,4 @@ extern tt_room ttmap[256];
extern tt_player ttplayer;
-
#endif
diff --git a/src/main.c b/src/main.c
index 60fd479..5fe37fc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,18 +1,17 @@
+#include "game.h"
+#include "globals.h"
+#include "map.h"
+#include "player.h"
#include <SDL2/SDL.h>
-#include <SDL2/SDL_ttf.h>
#include <SDL2/SDL_mixer.h>
+#include <SDL2/SDL_ttf.h>
#include <stdlib.h>
#include <time.h>
-#include "globals.h"
-#include "map.h"
-#include "player.h"
-#include "game.h"
-
static SDL_Texture *loadtxr(const char *path)
{
SDL_Surface *surf = SDL_LoadBMP(path);
- SDL_Texture *res = SDL_CreateTextureFromSurface(ttrdr, surf);
+ SDL_Texture *res = SDL_CreateTextureFromSurface(ttrdr, surf);
SDL_FreeSurface(surf);
return res;
}
@@ -23,17 +22,15 @@ int main(int argc, char **argv)
TTF_Init();
Mix_Init(MIX_INIT_OGG);
Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 4096);
- SDL_Window *wdw = SDL_CreateWindow("T A K E T H I S",
- SDL_WINDOWPOS_UNDEFINED,
- SDL_WINDOWPOS_UNDEFINED,
- 950, 540, 0);
- ttrdr = SDL_CreateRenderer(wdw, -1, SDL_RENDERER_ACCELERATED);
- tttxr = loadtxr("data/txr.bmp");
+ ttwdw = SDL_CreateWindow("T A K E T H I S", SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED, 950, 540, 0);
+ ttrdr = SDL_CreateRenderer(ttwdw, -1, SDL_RENDERER_ACCELERATED);
+ tttxr = loadtxr("data/txr.bmp");
ttfont = TTF_OpenFont("data/font.otf", 24);
- grib = Mix_LoadMUS("data/grib.ogg");
- ussr = Mix_LoadMUS("data/ussr.ogg");
+ grib = Mix_LoadMUS("data/grib.ogg");
+ ussr = Mix_LoadMUS("data/ussr.ogg");
stalin = Mix_LoadMUS("data/stalin.ogg");
- lenin = Mix_LoadMUS("data/lenin.ogg");
+ lenin = Mix_LoadMUS("data/lenin.ogg");
curmus = 0;
tt_map_load();
@@ -46,7 +43,7 @@ int main(int argc, char **argv)
TTF_CloseFont(ttfont);
SDL_DestroyTexture(tttxr);
SDL_DestroyRenderer(ttrdr);
- SDL_DestroyWindow(wdw);
+ SDL_DestroyWindow(ttwdw);
Mix_HaltMusic();
Mix_FreeMusic(lenin);
Mix_FreeMusic(stalin);
diff --git a/src/map.c b/src/map.c
index 5a6f618..557a6f5 100644
--- a/src/map.c
+++ b/src/map.c
@@ -1,12 +1,11 @@
#include "map.h"
+#include "game.h"
+#include "globals.h"
+#include "room.h"
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <stdio.h>
-#include "room.h"
-#include "globals.h"
-#include "game.h"
-
static int readnum(FILE *f)
{
@@ -22,20 +21,19 @@ static int readnum(FILE *f)
static SDL_Rect *newtile(int row, int col)
{
SDL_Rect *r = malloc(sizeof(*r));
- r->x = 16 * col;
- r->y = 16 * row;
+ r->x = 16 * col;
+ r->y = 16 * row;
r->h = r->w = 16;
return r;
}
-
static void loadroom(tt_room *r, FILE *f)
{
int default_floor_id = fgetc(f) - '0';
fgetc(f);
int i, j;
for (i = 0; i != 4; ++i) r->neighbours[i] = ttmap + fgetc(f);
- r->bodies = 0;
+ r->bodies = 0;
r->bodies_count = 0;
fgetc(f);
for (i = 0; i != TT_ROOM_H; ++i) {
@@ -45,265 +43,266 @@ static void loadroom(tt_room *r, FILE *f)
int c = id;
if (id == ' ') id = '0';
if (id < 'a') id -= '0';
- else id = id - 'a' + 10;
+ else
+ id = id - 'a' + 10;
r->floor[i][j] = 0;
r->walls[i][j] = 0;
if (type == '@') {
- ttplayer.room = r;
- ttplayer.x = j * 32;
- ttplayer.y = i * 32;
- ttplayer.xrem = 0;
- ttplayer.yrem = 0;
- ttplayer.xwalk = 0;
- ttplayer.ywalk = 0;
- ttplayer.rem = 0;
- ttplayer.money = 0;
- ttplayer.keys[0] = 0;
- ttplayer.keys[1] = 0;
- ttplayer.lenin_pos = 32 * 9;
+ ttplayer.room = r;
+ ttplayer.x = j * 32;
+ ttplayer.y = i * 32;
+ ttplayer.xrem = 0;
+ ttplayer.yrem = 0;
+ ttplayer.xwalk = 0;
+ ttplayer.ywalk = 0;
+ ttplayer.rem = 0;
+ ttplayer.money = 0;
+ ttplayer.keys[0] = 0;
+ ttplayer.keys[1] = 0;
+ ttplayer.lenin_pos = 32 * 9;
ttplayer.lenin_pos_rem = 0;
- ttplayer.lenin_zhiv = 0;
- ttplayer.lenin_rem = 0;
- ttplayer.lenin_vel = -53;
- ttplayer.variant = 0;
- ttplayer.tobein_gulag = 0;
- ttplayer.until_gulag = 5300;
- r->floor[i][j] = newtile(0, default_floor_id);
+ ttplayer.lenin_zhiv = 0;
+ ttplayer.lenin_rem = 0;
+ ttplayer.lenin_vel = -53;
+ ttplayer.variant = 0;
+ ttplayer.tobein_gulag = 0;
+ ttplayer.until_gulag = 5300;
+ r->floor[i][j] = newtile(0, default_floor_id);
} else if (type == 'y') {
- r->walls[i][j] = malloc(sizeof(tt_body));
- tt_body *b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 2;
- b->txrcol = id;
- b->anim = 1;
- b->rate = 1;
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ tt_body *b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 2;
+ b->txrcol = id;
+ b->anim = 1;
+ b->rate = 1;
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == 'b') {
- r->walls[i][j] = malloc(sizeof(tt_body));
- tt_body *b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 3;
- b->txrcol = id;
- b->anim = 1;
- b->rate = 1;
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ tt_body *b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 3;
+ b->txrcol = id;
+ b->anim = 1;
+ b->rate = 1;
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == 'r') {
- r->walls[i][j] = malloc(sizeof(tt_body));
- tt_body *b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 1;
- b->txrcol = id;
- b->anim = 1;
- b->rate = 1;
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ tt_body *b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 1;
+ b->txrcol = id;
+ b->anim = 1;
+ b->rate = 1;
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == 'g') {
r->floor[i][j] = newtile(0, default_floor_id);
r->bodies_count++;
- r->bodies = realloc(r->bodies,
- sizeof(tt_body) * r->bodies_count);
- tt_body *b = r->bodies + r->bodies_count - 1;
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 8;
- b->txrcol = id;
- b->anim = 4;
- b->rate = 150 + (rand() % 50 - 25);
+ r->bodies =
+ realloc(r->bodies, sizeof(tt_body) * r->bodies_count);
+ tt_body *b = r->bodies + r->bodies_count - 1;
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 8;
+ b->txrcol = id;
+ b->anim = 4;
+ b->rate = 150 + (rand() % 50 - 25);
b->collision_act = colact_grib;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == '^') {
- r->floor[i][j] = newtile(0, default_floor_id);
- r->walls[i][j] = malloc(sizeof(tt_body));
- tt_body *b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 8;
- b->txrcol = id;
- b->anim = 4;
- b->rate = 150 + (rand() % 50 - 25);
+ r->floor[i][j] = newtile(0, default_floor_id);
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ tt_body *b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 8;
+ b->txrcol = id;
+ b->anim = 4;
+ b->rate = 150 + (rand() % 50 - 25);
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == ';') {
- r->floor[i][j] = newtile(0, default_floor_id);
- r->walls[i][j] = malloc(sizeof(tt_body));
- tt_body *b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 10;
- b->txrcol = id;
- b->anim = 1;
- b->rate = 100;
+ r->floor[i][j] = newtile(0, default_floor_id);
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ tt_body *b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 10;
+ b->txrcol = id;
+ b->anim = 1;
+ b->rate = 100;
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == '.') {
r->floor[i][j] = newtile(0, c == ' ' ? default_floor_id : id);
} else if (type == '*') {
- r->walls[i][j] = malloc(sizeof(tt_body));
- tt_body *b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 9;
- b->txrcol = id;
- b->anim = 4;
- b->rate = 150 + (rand() % 50 - 25);
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ tt_body *b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 9;
+ b->txrcol = id;
+ b->anim = 4;
+ b->rate = 150 + (rand() % 50 - 25);
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == '=') {
r->floor[i][j] = newtile(0, default_floor_id);
r->bodies_count++;
- r->bodies = realloc(r->bodies,
- sizeof(tt_body) * r->bodies_count);
- tt_body *b = r->bodies + r->bodies_count - 1;
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->rem = 0;
- b->txrrow = 0;
- b->txrcol = 15;
- b->anim = 1;
- b->rate = 100;
+ r->bodies =
+ realloc(r->bodies, sizeof(tt_body) * r->bodies_count);
+ tt_body *b = r->bodies + r->bodies_count - 1;
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->rem = 0;
+ b->txrrow = 0;
+ b->txrcol = 15;
+ b->anim = 1;
+ b->rate = 100;
b->collision_act = 0;
- b->isdoor = 0;
+ b->isdoor = 0;
} else if (type == 'k') {
r->floor[i][j] = newtile(0, default_floor_id);
r->bodies_count++;
- r->bodies = realloc(r->bodies,
- sizeof(tt_body) * r->bodies_count);
- tt_body *b = r->bodies + r->bodies_count - 1;
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->rem = 0;
- b->txrrow = 11;
- b->txrcol = id;
- b->anim = 1;
- b->rate = 100;
+ r->bodies =
+ realloc(r->bodies, sizeof(tt_body) * r->bodies_count);
+ tt_body *b = r->bodies + r->bodies_count - 1;
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->rem = 0;
+ b->txrrow = 11;
+ b->txrcol = id;
+ b->anim = 1;
+ b->rate = 100;
b->collision_act = colact_key;
- b->isdoor = 0;
+ b->isdoor = 0;
} else if (type == 'd' || type == 'D') {
r->floor[i][j] = newtile(0, default_floor_id);
r->bodies_count++;
- r->bodies = realloc(r->bodies,
- sizeof(tt_body) * r->bodies_count);
- tt_body *b = r->bodies + r->bodies_count - 1;
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->rem = 0;
- b->txrrow = 4 + (type == 'D');
- b->txrcol = id;
- b->anim = 1;
- b->rate = 100;
+ r->bodies =
+ realloc(r->bodies, sizeof(tt_body) * r->bodies_count);
+ tt_body *b = r->bodies + r->bodies_count - 1;
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->rem = 0;
+ b->txrrow = 4 + (type == 'D');
+ b->txrcol = id;
+ b->anim = 1;
+ b->rate = 100;
b->collision_act = colact_door;
- b->isdoor = 1;
- r->walls[i][j] = malloc(sizeof(tt_body));
- b = r->walls[i][j];
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->xvel = 0;
- b->yvel = 0;
- b->rem = 0;
- b->txrrow = 0;
- b->txrcol = 15;
- b->anim = 1;
- b->rate = 100;
+ b->isdoor = 1;
+ r->walls[i][j] = malloc(sizeof(tt_body));
+ b = r->walls[i][j];
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->xvel = 0;
+ b->yvel = 0;
+ b->rem = 0;
+ b->txrrow = 0;
+ b->txrcol = 15;
+ b->anim = 1;
+ b->rate = 100;
b->collision_act = 0;
- b->isdoor = 0;
- b->msg = 0;
- b->msglen = 0;
+ b->isdoor = 0;
+ b->msg = 0;
+ b->msglen = 0;
} else if (type == '$') {
r->floor[i][j] = newtile(0, default_floor_id);
r->bodies_count++;
- r->bodies = realloc(r->bodies,
- sizeof(tt_body) * r->bodies_count);
- tt_body *b = r->bodies + r->bodies_count - 1;
- b->x = j * 32;
- b->y = i * 32;
- b->xrem = 0;
- b->yrem = 0;
- b->rem = 0;
- b->txrrow = 7;
- b->txrcol = id;
- b->anim = 4;
- b->rate = 100 + (rand() % 50 - 25);
+ r->bodies =
+ realloc(r->bodies, sizeof(tt_body) * r->bodies_count);
+ tt_body *b = r->bodies + r->bodies_count - 1;
+ b->x = j * 32;
+ b->y = i * 32;
+ b->xrem = 0;
+ b->yrem = 0;
+ b->rem = 0;
+ b->txrrow = 7;
+ b->txrcol = id;
+ b->anim = 4;
+ b->rate = 100 + (rand() % 50 - 25);
b->collision_act = colact_gulag;
- b->isdoor = 0;
+ b->isdoor = 0;
}
}
fgetc(f);
}
for (i = 0; i != r->bodies_count; ++i) {
- r->bodies[i].yvel = readnum(f);
- r->bodies[i].xvel = readnum(f);
- r->bodies[i].msg = 0;
+ r->bodies[i].yvel = readnum(f);
+ r->bodies[i].xvel = readnum(f);
+ r->bodies[i].msg = 0;
r->bodies[i].msglen = 0;
if (fgetc(f) == '=') {
int c = fgetc(f);
while (c != EOF && c != '\n') {
r->bodies[i].msglen++;
- r->bodies[i].msg = realloc(r->bodies[i].msg,
- r->bodies[i].msglen + 1);
+ r->bodies[i].msg =
+ realloc(r->bodies[i].msg, r->bodies[i].msglen + 1);
r->bodies[i].msg[r->bodies[i].msglen - 1] = c;
- c = fgetc(f);
+ c = fgetc(f);
}
r->bodies[i].msg[r->bodies[i].msglen] = 0;
}
@@ -313,9 +312,9 @@ static void loadroom(tt_room *r, FILE *f)
void tt_map_load()
{
char path[] = "data/map/0";
- char r = '0';
+ char r = '0';
while (r != '~') {
- path[9] = r;
+ path[9] = r;
FILE *roomf = fopen(path, "r");
if (roomf) {
loadroom(ttmap + r, roomf);
@@ -329,8 +328,8 @@ void tt_map_load()
ttmap[m].walls[i][j] = 0;
}
}
- ttmap[m].bodies_count = 0;
- ttmap[m].bodies = 0;
+ ttmap[m].bodies_count = 0;
+ ttmap[m].bodies = 0;
ttmap[m].neighbours[0] = ttmap + '.';
ttmap[m].neighbours[1] = ttmap + '.';
ttmap[m].neighbours[2] = ttmap + '.';
@@ -340,7 +339,6 @@ void tt_map_load()
}
}
-
void tt_map_free()
{
int i;
diff --git a/src/map.h b/src/map.h
index e8da22d..12843ba 100644
--- a/src/map.h
+++ b/src/map.h
@@ -1,7 +1,6 @@
#ifndef TAKETHIS_INCLUDED_MAP
#define TAKETHIS_INCLUDED_MAP
-
/* room is identified by single char
* they are located in data/map/
* roomfile has four neighbors at the first line
@@ -9,10 +8,8 @@
* after them each line is speed of corresponding enemy in percents
* and optionaly after = message of this enemy */
-
void tt_map_load();
void tt_map_free();
-
#endif
diff --git a/src/player.c b/src/player.c
index da5c97e..93c4778 100644
--- a/src/player.c
+++ b/src/player.c
@@ -1,24 +1,22 @@
#include "player.h"
-#include <math.h>
#include "globals.h"
-
+#include <math.h>
void tt_player_draw()
{
- int i, j;
+ int i, j;
tt_room *r = ttplayer.room;
for (i = 0; i != TT_ROOM_H; ++i) {
for (j = 0; j != TT_ROOM_W; ++j) {
- SDL_Rect d = { 14 + j * 32, 14 + i * 32, 32, 32 };
+ SDL_Rect d = {14 + j * 32, 14 + i * 32, 32, 32};
SDL_Rect *f = r->floor[i][j];
- tt_body *w = r->walls[i][j];
+ tt_body * w = r->walls[i][j];
if (f) SDL_RenderCopy(ttrdr, tttxr, f, &d);
if (w) {
SDL_Rect s = {
(w->txrcol * w->anim + w->rem / w->rate % w->anim) * 16,
- w->txrrow * 16, 16, 16
- };
+ w->txrrow * 16, 16, 16};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
}
}
@@ -26,82 +24,76 @@ void tt_player_draw()
if (ttplayer.lenin_zhiv) {
{
- SDL_Rect src = { 32 + 32 * (ttplayer.lenin_rem / 200 % 2),
- 16 * 12 + 4, 32, 38 };
- SDL_Rect dst = { 14 + ttplayer.lenin_pos,
- 14 + 32 + 96 - 8 - 38 * 2, 64, 38 * 2 };
+ SDL_Rect src = {32 + 32 * (ttplayer.lenin_rem / 200 % 2),
+ 16 * 12 + 4, 32, 38};
+ SDL_Rect dst = {14 + ttplayer.lenin_pos, 14 + 32 + 96 - 8 - 38 * 2,
+ 64, 38 * 2};
SDL_RenderCopy(ttrdr, tttxr, &src, &dst);
}
{
- SDL_Rect src = { 96 + 64 * (ttplayer.lenin_rem / 200 % 2),
- 16 * 12, 64, 48 };
- SDL_Rect dst = { 14 + ttplayer.lenin_pos - 32,
- 110, 128, 96 };
+ SDL_Rect src = {96 + 64 * (ttplayer.lenin_rem / 200 % 2), 16 * 12,
+ 64, 48};
+ SDL_Rect dst = {14 + ttplayer.lenin_pos - 32, 110, 128, 96};
SDL_RenderCopy(ttrdr, tttxr, &src, &dst);
}
}
for (i = 0; i != r->bodies_count; ++i) {
tt_body *b = r->bodies + i;
- SDL_Rect s = {
- (b->txrcol * b->anim + b->rem / b->rate % b->anim) * 16,
- b->txrrow * 16, 16, 16
- };
+ SDL_Rect s = {(b->txrcol * b->anim + b->rem / b->rate % b->anim) * 16,
+ b->txrrow * 16, 16, 16};
if (b->isdoor) {
- SDL_Rect d = { 14 + b->x, 14 + b->y, 32, 32 };
+ SDL_Rect d = {14 + b->x, 14 + b->y, 32, 32};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
} else {
- SDL_Rect d = { 14 + b->x, 14 + b->y, 32, 32 };
+ SDL_Rect d = {14 + b->x, 14 + b->y, 32, 32};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
}
if (b->msg) {
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, b->msg, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + b->x, 20 + b->y, s->w, s->h };
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, b->msg, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + b->x, 20 + b->y, s->w, s->h};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(s);
}
}
- SDL_Rect d = { 14 + ttplayer.x, 14 + ttplayer.y, 32, 32 };
- int dir = 0;
+ SDL_Rect d = {14 + ttplayer.x, 14 + ttplayer.y, 32, 32};
+ int dir = 0;
if (ttplayer.xwalk == 1) dir = 6;
- else if (ttplayer.xwalk == -1) dir = 2;
- else if (ttplayer.ywalk == -1) dir = 4;
- SDL_Rect s = { 16 * (8 * ttplayer.variant +
- dir + (ttplayer.rem / 100 % 2)),
- 16 * 6,
- 16, 16 };
+ else if (ttplayer.xwalk == -1)
+ dir = 2;
+ else if (ttplayer.ywalk == -1)
+ dir = 4;
+ SDL_Rect s = {16 * (8 * ttplayer.variant + dir + (ttplayer.rem / 100 % 2)),
+ 16 * 6, 16, 16};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
if (ttplayer.until_gulag > 0) {
double r = ttplayer.until_gulag / 10;
- double f = (double)(ttplayer.until_gulag) / 3000 *
- 2 * 3.14159265358979323846;
- SDL_Rect s = { 0, 16 * 12, 32, 48 };
- SDL_Rect d = { ttplayer.x - 16 + r * cos(f),
- ttplayer.y - 32 + r * sin(f),
- 64, 96 };
+ double f =
+ (double)(ttplayer.until_gulag) / 3000 * 2 * 3.14159265358979323846;
+ SDL_Rect s = {0, 16 * 12, 32, 48};
+ SDL_Rect d = {ttplayer.x - 16 + r * cos(f),
+ ttplayer.y - 32 + r * sin(f), 64, 96};
SDL_RenderCopy(ttrdr, tttxr, &s, &d);
}
{
- SDL_Rect src = { 0, 16 * 11, 16, 16 };
- SDL_Rect d = { 20 + TT_ROOM_W * 32 + 32,
- 12 + 32,
- 64, 64 };
+ SDL_Rect src = {0, 16 * 11, 16, 16};
+ SDL_Rect d = {20 + TT_ROOM_W * 32 + 32, 12 + 32, 64, 64};
SDL_RenderCopy(ttrdr, tttxr, &src, &d);
- int count = ttplayer.keys[0];
+ int count = ttplayer.keys[0];
int digits = 1;
while (count / 10) {
++digits;
count /= 10;
}
char *text = malloc(3 + digits);
- text[0] = 'x';
- text[1] = ' ';
+ text[0] = 'x';
+ text[1] = ' ';
int i;
count = ttplayer.keys[0];
for (i = digits + 1; i != 1; --i) {
@@ -109,30 +101,27 @@ void tt_player_draw()
count /= 10;
}
text[digits + 2] = 0;
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 64, 20 + 32,
- s->w * 2, s->h * 2 };
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + 32 * TT_ROOM_W + 64, 20 + 32, s->w * 2, s->h * 2};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(s);
}
{
- SDL_Rect src = { 16, 16 * 11, 16, 16 };
- SDL_Rect d = { 20 + TT_ROOM_W * 32 + 32,
- 12 + 96,
- 64, 64 };
+ SDL_Rect src = {16, 16 * 11, 16, 16};
+ SDL_Rect d = {20 + TT_ROOM_W * 32 + 32, 12 + 96, 64, 64};
SDL_RenderCopy(ttrdr, tttxr, &src, &d);
- int count = ttplayer.keys[1];
+ int count = ttplayer.keys[1];
int digits = 1;
while (count / 10) {
++digits;
count /= 10;
}
char *text = malloc(3 + digits);
- text[0] = 'x';
- text[1] = ' ';
+ text[0] = 'x';
+ text[1] = ' ';
int i;
count = ttplayer.keys[1];
for (i = digits + 1; i != 1; --i) {
@@ -140,26 +129,25 @@ void tt_player_draw()
count /= 10;
}
text[digits + 2] = 0;
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 64, 20 + 96,
- s->w * 2, s->h * 2 };
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + 32 * TT_ROOM_W + 64, 20 + 96, s->w * 2, s->h * 2};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(s);
}
{
- int count = ttplayer.money;
+ int count = ttplayer.money;
int digits = 1;
while (count / 10) {
++digits;
count /= 10;
}
char *text = malloc(4 + digits);
- text[0] = '$';
- text[1] = ' ';
- text[2] = ttplayer.money < 0 ? '-' : ' ';
+ text[0] = '$';
+ text[1] = ' ';
+ text[2] = ttplayer.money < 0 ? '-' : ' ';
int i;
count = ttplayer.money * (ttplayer.money < 0 ? -1 : 1);
for (i = digits + 2; i != 2; --i) {
@@ -167,29 +155,29 @@ void tt_player_draw()
count /= 10;
}
text[digits + 3] = 0;
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 16, 20 + 96 + 96,
- s->w * 2, s->h * 2 };
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + 32 * TT_ROOM_W + 16, 20 + 96 + 96, s->w * 2,
+ s->h * 2};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(s);
}
if (ttplayer.lenin_rem) {
- int count = ttplayer.lenin_rem / 1000;
+ int count = ttplayer.lenin_rem / 1000;
int digits = 1;
while (count / 10) {
++digits;
count /= 10;
}
char *text = malloc(7 + digits);
- text[0] = 'T';
- text[1] = 'i';
- text[2] = 'm';
- text[3] = 'e';
- text[4] = ':';
- text[5] = ' ';
+ text[0] = 'T';
+ text[1] = 'i';
+ text[2] = 'm';
+ text[3] = 'e';
+ text[4] = ':';
+ text[5] = ' ';
int i;
count = ttplayer.lenin_rem / 1000;
for (i = digits + 5; i != 5; --i) {
@@ -197,11 +185,11 @@ void tt_player_draw()
count /= 10;
}
text[digits + 6] = 0;
- SDL_Color c = { 255, 255, 255, 255 };
- SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
- SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
- SDL_Rect dst = { 50 + 32 * TT_ROOM_W + 16, 20 + 96 + 96 + 96,
- s->w * 2, s->h * 2 };
+ SDL_Color c = {255, 255, 255, 255};
+ SDL_Surface *s = TTF_RenderText_Blended(ttfont, text, c);
+ SDL_Texture *t = SDL_CreateTextureFromSurface(ttrdr, s);
+ SDL_Rect dst = {50 + 32 * TT_ROOM_W + 16, 20 + 96 + 96 + 96, s->w * 2,
+ s->h * 2};
SDL_RenderCopy(ttrdr, t, 0, &dst);
SDL_DestroyTexture(t);
SDL_FreeSurface(s);
diff --git a/src/player.h b/src/player.h
index b6bb697..e531b16 100644
--- a/src/player.h
+++ b/src/player.h
@@ -1,24 +1,22 @@
#ifndef TAKETHIS_INCLUDED_PLAYER
#define TAKETHIS_INCLUDED_PLAYER
-
#include "room.h"
-
typedef struct tt_player {
tt_room *room;
- int xwalk;
- int ywalk;
- int x;
- int y;
- int xrem;
- int yrem;
- int variant;
- int rem;
- int money;
- int keys[2];
- int tobein_gulag;
- int until_gulag;
+ int xwalk;
+ int ywalk;
+ int x;
+ int y;
+ int xrem;
+ int yrem;
+ int variant;
+ int rem;
+ int money;
+ int keys[2];
+ int tobein_gulag;
+ int until_gulag;
int lenin_pos;
int lenin_pos_rem;
@@ -27,10 +25,8 @@ typedef struct tt_player {
int lenin_rem;
} tt_player;
-
void tt_player_walk(int delta);
void tt_player_draw();
-
#endif
diff --git a/src/room.c b/src/room.c
index 66f6a29..90c8430 100644
--- a/src/room.c
+++ b/src/room.c
@@ -1,16 +1,14 @@
#include "room.h"
-
int tt_room_collide(tt_room *room, SDL_Rect *box)
{
- SDL_Rect r = { 0, 0, 32, 16 };
- int i, j;
+ SDL_Rect r = {0, 0, 32, 16};
+ int i, j;
for (i = 0; i != TT_ROOM_H; ++i) {
r.y = 32 * i;
for (j = 0; j != TT_ROOM_W; ++j) {
r.x = 32 * j;
- if (SDL_HasIntersection(box, room->walls[i][j] ? &r : 0))
- return 1;
+ if (SDL_HasIntersection(box, room->walls[i][j] ? &r : 0)) return 1;
}
}
return 0;
diff --git a/src/room.h b/src/room.h
index f1f9ba2..23aca00 100644
--- a/src/room.h
+++ b/src/room.h
@@ -1,23 +1,20 @@
#ifndef TAKETHIS_INCLUDED_ROOM
#define TAKETHIS_INCLUDED_ROOM
-
-#include <SDL2/SDL.h>
#include "body.h"
-
+#include <SDL2/SDL.h>
#define TT_ROOM_W 20
#define TT_ROOM_H 16
typedef struct tt_room {
- SDL_Rect *floor[TT_ROOM_H][TT_ROOM_W];
- tt_body *walls[TT_ROOM_H][TT_ROOM_W];
- tt_body *bodies;
- int bodies_count;
+ SDL_Rect * floor[TT_ROOM_H][TT_ROOM_W];
+ tt_body * walls[TT_ROOM_H][TT_ROOM_W];
+ tt_body * bodies;
+ int bodies_count;
struct tt_room *neighbours[4];
} tt_room;
-
void tt_room_draw_background(tt_room *room);
void tt_room_draw_foreground(tt_room *room);
@@ -25,5 +22,4 @@ int tt_room_collide(tt_room *room, SDL_Rect *box);
int tt_room_out(tt_room *room, SDL_Rect *box);
-
#endif