ScummVM API documentation
space_cockpit.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 ULTIMA1_VIEWS_SPACE_COCKPIT_H
23#define ULTIMA1_VIEWS_SPACE_COCKPIT_H
24
25#include "ultima/ultima1/views/map.h"
26#include "ultima/ultima1/data/map.h"
27#include "graphics/views/gfx_surface.h"
28
29namespace Ultima {
30namespace Ultima1 {
31namespace Views {
32
33using namespace Graphics::Views;
34
41class SpaceCockpit : public Map {
42private:
43 enum HyperjumpState {
44 HYPERJUMP_IDLE,
45 HYPERJUMP_ACCELERATE, // Cruising at each speed up to the maximum
46 HYPERJUMP_WARP_IN, // Stars streak outward, leaving their trails behind them
47 HYPERJUMP_WARP_OUT, // The same stars replayed, erasing the trails again
48 HYPERJUMP_DECELERATE // Cruising back down to the original speed
49 };
50
51 HyperjumpState _hyperjumpState = HYPERJUMP_IDLE;
52 int _hyperjumpDX = 0, _hyperjumpDY = 0;
53 int _hyperjumpOrigSpeed = 0;
54 int _hyperjumpLevelFrames = 0; // Frames cruised at each speed
55 int _hyperjumpFrames = 0; // Frames left in the current speed or warp phase
56 int _hyperjumpBudget = 0; // Vertical retraces left to spend on cruise frames
57 uint32 _hyperjumpSeed = 0;
58
59 // The pixels the stars have left behind during the warp
61
62 // Ticks left to keep showing the laser-bolt flash from fireLaser() (0 =
63 // not showing)
64 int _laserFlashTicks = 0;
65
66 // Ticks left to keep showing the incoming shot flash from
67 // alienFireFlash() (0 = not showing), and its endpoints
68 int _alienFlashTicks = 0;
69 int _alienFlashX1 = 0, _alienFlashY1 = 0, _alienFlashX2 = 0, _alienFlashY2 = 0;
70
74 void drawCockpitFrame(Graphics::Views::GfxSurface &s);
75
83 void tickHyperjump();
84
88 void hyperjumpFrame();
89
93 void startWarp();
94
98 void finishHyperjump();
99
103 void plotTrail(int x, int y, int color);
104
109 bool cancelHyperjump();
110
111public:
112 SpaceCockpit() : Map("SpaceCockpit") {}
113 ~SpaceCockpit() override {}
114
115 bool msgFocus(const FocusMessage &msg) override;
116 bool msgUnfocus(const UnfocusMessage &msg) override;
117 void draw() override;
118 bool tick() override;
119
124 bool msgAction(const ActionMessage &msg) override;
125 bool msgKeypress(const KeypressMessage &msg) override;
126
133 bool msgMouseMove(const MouseMoveMessage &msg) override;
134 bool msgMouseDown(const MouseDownMessage &msg) override;
135
141 void startHyperjump(int dx, int dy);
142
148 void fireLaser();
149
155 void alienFireFlash(int x1, int y1, int x2, int y2);
156};
157
158} // namespace Views
159} // namespace Ultima1
160} // namespace Ultima
161
162#endif
Definition: managed_surface.h:51
Definition: gfx_surface.h:34
Definition: map.h:37
Definition: space_cockpit.h:41
bool msgMouseMove(const MouseMoveMessage &msg) override
bool msgAction(const ActionMessage &msg) override
void startHyperjump(int dx, int dy)
void alienFireFlash(int x1, int y1, int x2, int y2)
Definition: messages.h:118
Definition: messages.h:42
Definition: messages.h:54
Definition: messages.h:76
Definition: messages.h:61
Definition: messages.h:50