ScummVM API documentation
maski_21.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef QDENGINE_MINIGAMES_MASKI_21_H
23#define QDENGINE_MINIGAMES_MASKI_21_H
24
25#include "common/debug.h"
26
27#include "qdengine/qd_fwd.h"
28#include "qdengine/qdcore/qd_minigame_interface.h"
29
30namespace QDEngine {
31
33public:
34 qdMaski21MiniGame(bool randomDll) { _randomDll = randomDll; }
36
37 bool init(const qdEngineInterface *engine_interface) {
38 debugC(1, kDebugMinigames, "Maski21::init()");
39
40 _engine = engine_interface;
41 _scene = engine_interface->current_scene_interface();
42 if (!_scene)
43 return false;
44
45 _flagObj = _scene->object_interface(_scene->minigame_parameter("command_object"));
46
47 if (!_randomDll)
48 _commandObj = _scene->object_interface(_scene->minigame_parameter("command_object"));
49
50 // srand(time(0))
51
52 _timePassed = -1.0;
53
54 return true;
55 }
56
57 bool quant(float dt) {
58 debugC(3, kDebugMinigames, "Maski21::quant(%f)", dt);
59
60 if (!_randomDll) {
61 mgVect2i pos = _engine->mouse_cursor_position();
62
63 if (pos.x < 25)
64 _commandObj->set_state("\xe2\xeb\xe5\xe2\xee"); // "влево"
65
66 if (pos.x > 775)
67 _commandObj->set_state("\xe2\xef\xf0\xe0\xe2\xee"); // "вправо"
68
69 if (pos.x > 25 && pos.x < 775)
70 _commandObj->set_state("\xed\xe5\xf2"); // "нет"
71 }
72
73 if (_flagObj->is_state_active("\xe7\xe0\xef\xf3\xf1\xea")) { // "запуск"
74 _timePassed = 0.0;
75 _targetTime = qd_rnd(20) + 10;
76
77 _flagObj->set_state("\xe2\xfb\xef\xee\xeb\xed\xe5\xed\xe8\xe5"); // "выполнение"
78 } else if (_flagObj->is_state_active("\xe2\xfb\xef\xee\xeb\xed\xe5\xed\xe8\xe5")) { // "выполнение"
79 _timePassed += dt;
80 }
81
82 if ((float)_targetTime < _timePassed && _timePassed != -1.0 ) {
83 _timePassed = -1.0;
84 _flagObj->set_state("\xea\xee\xed\xe5\xf6"); // "конец"
85 }
86
87 return true;
88 }
89
90 bool finit() {
91 debugC(1, kDebugMinigames, "Maski21::finit()");
92
93 if (_scene) {
94 _engine->release_scene_interface(_scene);
95 _scene = 0;
96 }
97
98 return true;
99 }
100
101 bool new_game(const qdEngineInterface *engine_interface) {
102 return true;
103 }
104
105 int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size) {
106 return 0;
107 }
108
109 int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size) {
110 return 0;
111 }
112
113 enum { INTERFACE_VERSION = 99 };
114 int version() const {
115 return INTERFACE_VERSION;
116 }
117
118private:
119 const qdEngineInterface *_engine = nullptr;
120 qdMinigameSceneInterface *_scene = nullptr;
121
122 qdMinigameObjectInterface *_commandObj = nullptr;
123 qdMinigameObjectInterface *_flagObj = nullptr;
124
125 float _timePassed = -1.0;
126 int _targetTime = 0;
127
128 bool _randomDll = false;
129};
130
131} // namespace QDEngine
132
133#endif // QDENGINE_MINIGAMES_MASKI_21_H
Definition: qd_minigame_interface.h:365
virtual mgVect2i mouse_cursor_position() const =0
Возвращает текущие координаты мышиного курсора.
Definition: maski_21.h:32
int load_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, const char *buffer, int buffer_size)
Загрузка данных, вызывается при загрузке сцены, на которую повешена миниигра.
Definition: maski_21.h:109
int save_game(const qdEngineInterface *engine_interface, const qdMinigameSceneInterface *scene_interface, char *buffer, int buffer_size)
Сохранение данных, вызывается при сохранении сцены, на которую повешена миниигра.
Definition: maski_21.h:105
bool quant(float dt)
Обсчёт логики игры, параметр - время, которое должно пройти в игре (в секундах).
Definition: maski_21.h:57
bool init(const qdEngineInterface *engine_interface)
Инициализация игры.
Definition: maski_21.h:37
bool finit()
Деинициализация игры.
Definition: maski_21.h:90
bool new_game(const qdEngineInterface *engine_interface)
Инициализация миниигры, вызывается при старте и перезапуске игры.
Definition: maski_21.h:101
Definition: qd_minigame_interface.h:78
virtual bool set_state(const char *state_name)=0
Включает состояние с именем state_name.
virtual bool is_state_active(const char *state_name) const =0
Возвращает true, если состояние с именем state_name включено в данный момент.
Интерфейс к сцене.
Definition: qd_minigame_interface.h:315
virtual qdMinigameObjectInterface * object_interface(const char *object_name, bool test=false)=0
Создаёт интерфейс к объекту с именем object_name.
void void void void void debugC(int level, uint32 debugChannel, MSVC_PRINTF const char *s,...) GCC_PRINTF(3
Базовый класс для игровых ресурсов.
Definition: console.h:28
uint32 qd_rnd(uint32 m)
Возвращает случайное значение в интервале [0, m-1].
Definition: qd_rnd.h:30