2e795eba5a8930e4493e52c89573aac2ecd3315e
[rocksndiamonds.git] / src / game_bd / bd_gameplay.h
1 /*
2  * Copyright (c) 2007, 2008, 2009, Czirkos Zoltan <cirix@fw.hu>
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16
17 #ifndef BD_GAMEPLAY_H
18 #define BD_GAMEPLAY_H
19
20 #include "bd_cave.h"
21
22
23 #define GAME_INT_INVALID                -100
24
25 /* prepare cave, gfx buffer */
26 #define GAME_INT_LOAD_CAVE              -73
27
28 /* show description/note of cave. */
29 #define GAME_INT_SHOW_STORY             -72
30
31 /* waiting fire button after showing the story. */
32 #define GAME_INT_SHOW_STORY_WAIT        -71
33
34 /* start uncovering */
35 #define GAME_INT_START_UNCOVER          -70
36
37 /* ...70 frames until full uncover... */
38 #define GAME_INT_UNCOVER_ALL            -1
39
40 /* normal running state. */
41 #define GAME_INT_CAVE_RUNNING           0
42
43 /* add points for remaining time */
44 #define GAME_INT_CHECK_BONUS_TIME       1
45
46 /* ...2..99 = wait and do nothing, after adding time */
47 #define GAME_INT_WAIT_BEFORE_COVER      2
48
49 /* start covering */
50 #define GAME_INT_COVER_START            100
51
52 /* ... 8 frames of cover animation */
53 #define GAME_INT_COVER_ALL              108
54
55
56 typedef struct _gd_game
57 {
58   GdString player_name;     /* Name of player */
59   int player_score;         /* Score of player */
60   int player_lives;         /* Remaining lives of player */
61
62   GdDirection player_move;
63   boolean player_move_stick;
64   boolean player_fire;
65
66   GdCave *cave;             /* Copy of the cave. This is the iterated, changed (ruined...) one */
67   GdCave *original_cave;    /* original cave from caveset. used to record highscore */
68
69   boolean out_of_window;   /* will be set to true, if player is not visible in the window, and we have to wait for scrolling */
70
71   int cave_num;             /* actual playing cave number */
72   int cave_score;           /* score collected in this cave */
73   int level_num;            /* actual playing level */
74   int bonus_life_flash;     /* different kind of flashing, for bonus life */
75
76   int state_counter;        /* counter used to control the game flow, rendering of caves */
77   int **element_buffer;
78   int **last_element_buffer;
79   int **dir_buffer;
80   int **gfx_buffer;         /* contains the indexes to the cells; created by *start_level, deleted by *stop_game */
81   int itercycle;
82   int itermax;
83   int itermax_last;
84   int animcycle;
85   int milliseconds_game;
86   int milliseconds_anim;
87
88   int replay_no_more_movements;
89   boolean show_story;      /* variable to remember that the story for a particular cave was already shown. */
90 } GdGame;
91
92 typedef enum _gd_game_state
93 {
94   GD_GAME_INVALID_STATE,
95   GD_GAME_SHOW_STORY,
96   GD_GAME_SHOW_STORY_WAIT,
97   GD_GAME_CAVE_LOADED,
98   GD_GAME_NOTHING,
99   GD_GAME_LABELS_CHANGED,
100   GD_GAME_TIMEOUT_NOW,      /* this signals the moment of time out */
101   GD_GAME_NO_MORE_LIVES,
102   GD_GAME_STOP,
103   GD_GAME_GAME_OVER,
104 } GdGameState;
105
106 GdCave *gd_create_snapshot(GdGame *gameplay);
107
108 void gd_game_free(GdGame *gameplay);
109 GdGame *gd_game_new(const int cave, const int level);
110 GdGame *gd_game_new_snapshot(GdCave *snapshot);
111 GdGame *gd_game_new_test(GdCave *cave, int level);
112
113 void play_game_func(GdGame *game, int action);
114
115 #endif  // BD_GAMEPLAY_H