|
1 /* |
|
2 Copyright (c) 2023 MCL Software |
|
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), |
|
4 to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, |
|
5 and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
|
6 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
|
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
8 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
9 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
10 */ |
|
11 #ifndef COMMON |
|
12 #define COMMON |
|
13 |
|
14 #define TILEMAP_DIMS 16 |
|
15 |
|
16 #include <SDL2/SDL.h> |
|
17 #include <SDL2/SDL_mixer.h> |
|
18 #include "fontcche.h" |
|
19 #include <SDL2/SDL_image.h> |
|
20 #include <stdbool.h> |
|
21 |
|
22 #define SCREEN_WIDTH 1280 |
|
23 #define SCREEN_HEIGHT 960 |
|
24 |
|
25 // Level width and height in tiles |
|
26 #define LEVEL_WIDTH 256 // X |
|
27 #define LEVEL_HEIGHT 5 // Y |
|
28 #define LEVEL_DEPTH 256 // Z |
|
29 |
|
30 // Tile width and height in pixels |
|
31 #define TILE_WIDTH 89 |
|
32 #define TILE_HEIGHT 90 |
|
33 |
|
34 extern SDL_Texture* logo; |
|
35 extern bool gameRunning; |
|
36 extern int zoomFactor; |
|
37 extern int orientation; |
|
38 extern int stealProgress; |
|
39 extern bool fireAlarmSystemActivated; |
|
40 extern SDL_TimerID fireAlarmTimer; |
|
41 extern Mix_Chunk* alarmSound; |
|
42 extern Mix_Music* themeSong; |
|
43 extern Mix_Music* bgm1; |
|
44 extern Mix_Music* bgm2; |
|
45 extern Mix_Music* bgm3; |
|
46 extern Mix_Music* bgm4; |
|
47 extern Mix_Music* bgm5; |
|
48 extern Mix_Music* bgm6; |
|
49 extern Mix_Music* bgm7; |
|
50 extern Mix_Music* bgm8; |
|
51 extern Mix_Music* bgm9; |
|
52 extern Mix_Music* bgm10; |
|
53 extern Mix_Music* bgm11; |
|
54 extern Mix_Music* bgm12; |
|
55 extern Mix_Music* bgm13; |
|
56 extern Mix_Music* bgm14; |
|
57 extern int selectedMenuItem; |
|
58 |
|
59 extern FC_Font* font; |
|
60 |
|
61 typedef struct |
|
62 { |
|
63 int x, y; |
|
64 char objectsStolen[8]; |
|
65 bool canMove; |
|
66 bool canLeaveCampus; |
|
67 bool leftCampus; |
|
68 } |
|
69 Player; |
|
70 |
|
71 typedef struct |
|
72 { |
|
73 int ident; |
|
74 } |
|
75 Interactions; |
|
76 |
|
77 typedef struct |
|
78 { |
|
79 int textureIndex; |
|
80 bool passable; |
|
81 int stealable; |
|
82 int stealTime; |
|
83 int interactable; // Different numbers mean different actions (e.g. 0 = sit in chair, 1 = activate fire alarm sys, 2 = flush toilet, etc.) |
|
84 int placementHeight; |
|
85 int height; |
|
86 int textureHeight; |
|
87 bool renderUnder; |
|
88 bool renderAbove; |
|
89 bool flipTexture; |
|
90 } |
|
91 Object; |
|
92 |
|
93 typedef struct |
|
94 { |
|
95 Object level[LEVEL_WIDTH * LEVEL_HEIGHT * LEVEL_DEPTH]; |
|
96 } |
|
97 Level; |
|
98 |
|
99 Object getObjectFromIdent(char ident); |
|
100 |
|
101 SDL_Point getTransformation(int x, int y); |
|
102 |
|
103 SDL_Point getLevelTransformation(int i, int j); |
|
104 |
|
105 SDL_Point pixelToTileCoordinates(int x, int y); |
|
106 |
|
107 SDL_Point tileToPixelCoordinates(int x, int y); |
|
108 |
|
109 extern char levelTiles[LEVEL_WIDTH * LEVEL_DEPTH]; |
|
110 |
|
111 extern Player player; |
|
112 extern SDL_Point offset; |
|
113 extern SDL_Rect clip; |
|
114 extern SDL_Rect destRect; |
|
115 extern SDL_Renderer* renderer; |
|
116 extern SDL_Texture* tilemap; |
|
117 extern SDL_Surface* tilemapSurface; |
|
118 extern double frameDelta; |
|
119 |
|
120 #endif |