summaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c912
1 files changed, 512 insertions, 400 deletions
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);