annotate trix/src/trix.h @ 11:78390e0e674f

remove DPF
author prymula <prymula76@outlook.com>
date Thu, 08 Feb 2024 20:21:56 +0100
parents 2787f5e749ae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
2 * Trix - klikanie po klockach
prymula <prymula76@outlook.com>
parents:
diff changeset
3 * Przemysław R. Pietraszczyk
prymula <prymula76@outlook.com>
parents:
diff changeset
4 *
prymula <prymula76@outlook.com>
parents:
diff changeset
5 * paźdżiernik 2006 r.
prymula <prymula76@outlook.com>
parents:
diff changeset
6 *
prymula <prymula76@outlook.com>
parents:
diff changeset
7 * licencja: Public Domain
prymula <prymula76@outlook.com>
parents:
diff changeset
8 */
prymula <prymula76@outlook.com>
parents:
diff changeset
9
prymula <prymula76@outlook.com>
parents:
diff changeset
10 #ifndef TRIX_H
prymula <prymula76@outlook.com>
parents:
diff changeset
11 #define TRIX_H
prymula <prymula76@outlook.com>
parents:
diff changeset
12
prymula <prymula76@outlook.com>
parents:
diff changeset
13 #include <errno.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
14 #include <fcntl.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
15 #include <dirent.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
16 #include <stdio.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
17 #include <stdlib.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
18 #include <unistd.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
19 #include <limits.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
20 #include <string.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
21 #include <time.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
22 #include <SDL2/SDL.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
23 #include <SDL2/SDL_ttf.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
24 #include <SDL2/SDL_image.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
25
prymula <prymula76@outlook.com>
parents:
diff changeset
26 #if WINDOWS
prymula <prymula76@outlook.com>
parents:
diff changeset
27 #include <windows.h>
prymula <prymula76@outlook.com>
parents:
diff changeset
28 #endif
prymula <prymula76@outlook.com>
parents:
diff changeset
29
prymula <prymula76@outlook.com>
parents:
diff changeset
30
prymula <prymula76@outlook.com>
parents:
diff changeset
31 #if WINDOWS
prymula <prymula76@outlook.com>
parents:
diff changeset
32 //#include "img\\banner.xpm"
prymula <prymula76@outlook.com>
parents:
diff changeset
33 #include "..img/banner.xpm"
prymula <prymula76@outlook.com>
parents:
diff changeset
34 #include "..img/about.xpm"
prymula <prymula76@outlook.com>
parents:
diff changeset
35 #elif LINUX
prymula <prymula76@outlook.com>
parents:
diff changeset
36 #include "../img/banner.xpm"
prymula <prymula76@outlook.com>
parents:
diff changeset
37 #include "../img/about.xpm"
prymula <prymula76@outlook.com>
parents:
diff changeset
38 #endif
prymula <prymula76@outlook.com>
parents:
diff changeset
39
prymula <prymula76@outlook.com>
parents:
diff changeset
40
prymula <prymula76@outlook.com>
parents:
diff changeset
41 #define FONTSIZE 25
prymula <prymula76@outlook.com>
parents:
diff changeset
42
prymula <prymula76@outlook.com>
parents:
diff changeset
43 #define FIELD_SIZE 20
prymula <prymula76@outlook.com>
parents:
diff changeset
44
prymula <prymula76@outlook.com>
parents:
diff changeset
45
prymula <prymula76@outlook.com>
parents:
diff changeset
46
prymula <prymula76@outlook.com>
parents:
diff changeset
47 #if WINDOWS
prymula <prymula76@outlook.com>
parents:
diff changeset
48 #define CATALOGUE "img\\bg\\catalogue.txt"
prymula <prymula76@outlook.com>
parents:
diff changeset
49 #define BG_DIR "img\\bg\\"
prymula <prymula76@outlook.com>
parents:
diff changeset
50 #define ICONS "img\\icons.bmp"
prymula <prymula76@outlook.com>
parents:
diff changeset
51 #define HISCORES_FILE "hiscores"
prymula <prymula76@outlook.com>
parents:
diff changeset
52 #define NAMEFONT "ZapfHumanist.ttf"
prymula <prymula76@outlook.com>
parents:
diff changeset
53 //#define SETTINGS "trix.ini"
prymula <prymula76@outlook.com>
parents:
diff changeset
54 #define SETTINGS "settings"
prymula <prymula76@outlook.com>
parents:
diff changeset
55 #elif LINUX
prymula <prymula76@outlook.com>
parents:
diff changeset
56 #define CATALOGUE "/usr/share/trix/img/bg/catalogue.txt"
prymula <prymula76@outlook.com>
parents:
diff changeset
57 #define BG_DIR "/usr/share/trix/img/bg/"
prymula <prymula76@outlook.com>
parents:
diff changeset
58 #define ICONS "/usr/share/trix/img/icons.bmp"
prymula <prymula76@outlook.com>
parents:
diff changeset
59 #define NAMEFONT "/usr/share/trix/ZapfHumanist.ttf"
prymula <prymula76@outlook.com>
parents:
diff changeset
60 #define SETTINGS "/.trix/trixrc"
prymula <prymula76@outlook.com>
parents:
diff changeset
61
prymula <prymula76@outlook.com>
parents:
diff changeset
62 //#define CATALOGUE "img/bg/catalogue.txt"
prymula <prymula76@outlook.com>
parents:
diff changeset
63 //#define BG_DIR "img/bg/"
prymula <prymula76@outlook.com>
parents:
diff changeset
64 //#define ICONS "img/icons.bmp"
prymula <prymula76@outlook.com>
parents:
diff changeset
65 //#define NAMEFONT "./ZapfHumanist.ttf"
prymula <prymula76@outlook.com>
parents:
diff changeset
66 //#define SETTINGS "/.trix/trixrc"
prymula <prymula76@outlook.com>
parents:
diff changeset
67
prymula <prymula76@outlook.com>
parents:
diff changeset
68 #endif
prymula <prymula76@outlook.com>
parents:
diff changeset
69
prymula <prymula76@outlook.com>
parents:
diff changeset
70 #define N_PIC 6 // ilosc zdjec tla
prymula <prymula76@outlook.com>
parents:
diff changeset
71
prymula <prymula76@outlook.com>
parents:
diff changeset
72 #define START_GAME 1
prymula <prymula76@outlook.com>
parents:
diff changeset
73 #define HISCORES 2
prymula <prymula76@outlook.com>
parents:
diff changeset
74 #define QUIT_GAME 3
prymula <prymula76@outlook.com>
parents:
diff changeset
75 #define ABOUT 4
prymula <prymula76@outlook.com>
parents:
diff changeset
76 #define OPTIONS 5
prymula <prymula76@outlook.com>
parents:
diff changeset
77 // #define GAME_OVER 6
prymula <prymula76@outlook.com>
parents:
diff changeset
78
prymula <prymula76@outlook.com>
parents:
diff changeset
79
prymula <prymula76@outlook.com>
parents:
diff changeset
80 #define Y_START 200 // 100
prymula <prymula76@outlook.com>
parents:
diff changeset
81 #define Y_HISCORES 250 // 150
prymula <prymula76@outlook.com>
parents:
diff changeset
82 #define Y_OPTIONS 300
prymula <prymula76@outlook.com>
parents:
diff changeset
83 #define Y_ABOUT 350
prymula <prymula76@outlook.com>
parents:
diff changeset
84
prymula <prymula76@outlook.com>
parents:
diff changeset
85 #define X_CENTER(w) (230-w/2)
prymula <prymula76@outlook.com>
parents:
diff changeset
86
prymula <prymula76@outlook.com>
parents:
diff changeset
87
prymula <prymula76@outlook.com>
parents:
diff changeset
88
prymula <prymula76@outlook.com>
parents:
diff changeset
89 extern SDL_Surface * block[8];
prymula <prymula76@outlook.com>
parents:
diff changeset
90 extern SDL_Surface * explode;
prymula <prymula76@outlook.com>
parents:
diff changeset
91 extern SDL_Surface * bomb;
prymula <prymula76@outlook.com>
parents:
diff changeset
92 extern SDL_Surface * wall;
prymula <prymula76@outlook.com>
parents:
diff changeset
93 extern SDL_Surface * smoke;
prymula <prymula76@outlook.com>
parents:
diff changeset
94
prymula <prymula76@outlook.com>
parents:
diff changeset
95 extern SDL_Surface * net;
prymula <prymula76@outlook.com>
parents:
diff changeset
96 extern SDL_Surface * banner;
prymula <prymula76@outlook.com>
parents:
diff changeset
97 extern SDL_Surface * bg;
prymula <prymula76@outlook.com>
parents:
diff changeset
98 extern SDL_Surface * screen;
prymula <prymula76@outlook.com>
parents:
diff changeset
99 extern TTF_Font* font;
prymula <prymula76@outlook.com>
parents:
diff changeset
100
prymula <prymula76@outlook.com>
parents:
diff changeset
101 extern SDL_Renderer * renderer;
prymula <prymula76@outlook.com>
parents:
diff changeset
102 extern SDL_Texture * tex_screen;
prymula <prymula76@outlook.com>
parents:
diff changeset
103
prymula <prymula76@outlook.com>
parents:
diff changeset
104 extern SDL_Rect source, dest;
prymula <prymula76@outlook.com>
parents:
diff changeset
105
prymula <prymula76@outlook.com>
parents:
diff changeset
106
prymula <prymula76@outlook.com>
parents:
diff changeset
107 extern int use_net; // zmienna wyswietlania siatki
prymula <prymula76@outlook.com>
parents:
diff changeset
108 extern int start_level; // start gry od poziomu ...
prymula <prymula76@outlook.com>
parents:
diff changeset
109 extern int score;
prymula <prymula76@outlook.com>
parents:
diff changeset
110 extern int bonus; // nalicza premie
prymula <prymula76@outlook.com>
parents:
diff changeset
111
prymula <prymula76@outlook.com>
parents:
diff changeset
112 extern char * hifile; // path do hiscore
prymula <prymula76@outlook.com>
parents:
diff changeset
113
prymula <prymula76@outlook.com>
parents:
diff changeset
114 struct tab {
prymula <prymula76@outlook.com>
parents:
diff changeset
115 char name[20];
prymula <prymula76@outlook.com>
parents:
diff changeset
116 int score;
prymula <prymula76@outlook.com>
parents:
diff changeset
117 };
prymula <prymula76@outlook.com>
parents:
diff changeset
118
prymula <prymula76@outlook.com>
parents:
diff changeset
119 extern struct tab tab_hiscores[5];
prymula <prymula76@outlook.com>
parents:
diff changeset
120 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
121 struct FIELD{
prymula <prymula76@outlook.com>
parents:
diff changeset
122 SDL_Surface * type;
prymula <prymula76@outlook.com>
parents:
diff changeset
123 int status; // 0:brak statusu 2:stoi -1:opada 1:znika lub wybucha
prymula <prymula76@outlook.com>
parents:
diff changeset
124 } field[23][26];
prymula <prymula76@outlook.com>
parents:
diff changeset
125 */
prymula <prymula76@outlook.com>
parents:
diff changeset
126 struct FIELD{
prymula <prymula76@outlook.com>
parents:
diff changeset
127 SDL_Surface * type;
prymula <prymula76@outlook.com>
parents:
diff changeset
128 int status; // 0:brak statusu 2:stoi -1:opada 1:znika lub wybucha
prymula <prymula76@outlook.com>
parents:
diff changeset
129 };
prymula <prymula76@outlook.com>
parents:
diff changeset
130
prymula <prymula76@outlook.com>
parents:
diff changeset
131 extern struct FIELD field[23][26];
prymula <prymula76@outlook.com>
parents:
diff changeset
132
prymula <prymula76@outlook.com>
parents:
diff changeset
133 #define DROP -1 // opada
prymula <prymula76@outlook.com>
parents:
diff changeset
134 #define FADE 1 // element zanika
prymula <prymula76@outlook.com>
parents:
diff changeset
135 #define STAND 2 // stoi
prymula <prymula76@outlook.com>
parents:
diff changeset
136 #define WALL 3 // murek
prymula <prymula76@outlook.com>
parents:
diff changeset
137
prymula <prymula76@outlook.com>
parents:
diff changeset
138
prymula <prymula76@outlook.com>
parents:
diff changeset
139 /* struktura przechowuje pozycje kasowanych elementow */
prymula <prymula76@outlook.com>
parents:
diff changeset
140 struct ghost {
prymula <prymula76@outlook.com>
parents:
diff changeset
141 int x, y;
prymula <prymula76@outlook.com>
parents:
diff changeset
142 };
prymula <prymula76@outlook.com>
parents:
diff changeset
143
prymula <prymula76@outlook.com>
parents:
diff changeset
144 /* struktura przechowujaca dane o danym poziomie */
prymula <prymula76@outlook.com>
parents:
diff changeset
145 struct data_levels {
prymula <prymula76@outlook.com>
parents:
diff changeset
146 int max; // zakres liczb losowych
prymula <prymula76@outlook.com>
parents:
diff changeset
147 int drop; // flaga zrzutu
prymula <prymula76@outlook.com>
parents:
diff changeset
148 int wall; // 1: ustawiony murek na dnie studni 0; brak murka
prymula <prymula76@outlook.com>
parents:
diff changeset
149 };
prymula <prymula76@outlook.com>
parents:
diff changeset
150
prymula <prymula76@outlook.com>
parents:
diff changeset
151 extern char catalogue[N_PIC][40]; // tla
prymula <prymula76@outlook.com>
parents:
diff changeset
152
prymula <prymula76@outlook.com>
parents:
diff changeset
153 SDL_Rect set_rect(int x, int y, int w, int h);
prymula <prymula76@outlook.com>
parents:
diff changeset
154 Uint32 getpixel(SDL_Surface *surface, int x, int y);
prymula <prymula76@outlook.com>
parents:
diff changeset
155
prymula <prymula76@outlook.com>
parents:
diff changeset
156 #endif