ScummVM API documentation
raycastpuzzle.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 NANCY_ACTION_RAYCASTPUZZLE_H
23 #define NANCY_ACTION_RAYCASTPUZZLE_H
24 
25 #include "engines/nancy/action/actionrecord.h"
26 
27 namespace Nancy {
28 
29 struct RCPR;
30 
31 namespace Action {
32 
33 class RaycastDeferredLoader;
34 class RaycastLevelBuilder;
35 
36 // Action record implementing nancy3's maze minigame
38  friend class RaycastDeferredLoader;
39  friend class RaycastLevelBuilder;
40 public:
41  RaycastPuzzle() : RenderActionRecord(7), _map(7) {}
42  ~RaycastPuzzle() override;
43 
44  void init() override;
45  void registerGraphics() override;
46 
47  void readData(Common::SeekableReadStream &stream) override;
48  void execute() override;
49  void onPause(bool pause) override;
50  void handleInput(NancyInput &input) override;
51  void updateGraphics() override;
52 
53 protected:
54  Common::String getRecordTypeName() const override { return "RaycastPuzzle"; }
55  bool isViewportRelative() const override { return true; }
56 
57  void validateMap();
58 
59  void createTextureLightSourcing(Common::Array<Graphics::ManagedSurface> *array, const Common::Path &textureName);
60 
61  void drawMap();
62  void updateMap();
63  void drawMaze();
64  void clearZBuffer();
65 
66  void checkSwitch();
67  void checkExit();
68 
69  uint16 _mapWidth = 0;
70  uint16 _mapHeight = 0;
71  byte _wallHeight = 0;
72 
73  Common::String _switchSoundName;
74  uint16 _switchSoundChannelID = 0;
75  Common::String _unknownSoundName;
76  uint16 _unknownSoundChannelID = 0;
77  SoundDescription _dummySound;
78 
79  SceneChangeWithFlag _solveScene;
80  SoundDescription _solveSound;
81 
82  Common::Array<uint32> _wallMap, _infoMap;
83  Common::Array<int16> _floorMap, _ceilingMap;
84  Common::Array<uint16> _wallLightMap, _floorCeilingLightMap, _heightMap;
85  Common::Array<uint16> _wallLightMapBackup, _floorCeilingLightMapBackup;
86 
87  uint16 _mapFullWidth = 0;
88  uint16 _mapFullHeight = 0;
89 
90  RenderObject _map;
91  Graphics::ManagedSurface _mapBaseSurface;
92 
93  double _pi = 3.141592653589793;
94  uint _fov = 192;
95  Common::Array<float> _sinTable, _cosTable;
96 
102 
103  Common::Array<int32> _wallCastColumnAngles;
104  Common::Array<byte> _zBuffer;
105  byte _lastZDepth = 0;
106  Common::Array<float> _depthBuffer;
107  int32 _leftmostAngle = -1;
108  int32 _rightmostAngle = -1;
109 
110  // Improvement: we store position as float for smoother movement
111  float _playerX = -1; // Player position with precision 1/128th of cell width/height
112  float _playerY = -1;
113  int32 _playerRotation = 0; // Rotation of player (0 - 4096)
114  uint32 _playerAltitude = 88; // Z position of "camera"; only modified in god mode
115 
116  float _rotationSingleStep = 4096.0 / (_pi * 2);
117  float _maxWorldDistance = 0.0;
118 
119  uint32 _lastMovementTime = 0;
120  int _lastMouseX = -1;
121 
122  uint32 _nextSlowdownMovementTime = 0;
123  byte _slowdownFramesLeft = 0;
124  int32 _slowdownDeltaX = -1;
125  int32 _slowdownDeltaY = -1;
126 
127  Common::Array<byte> _lightSwitchIDs;
128  Common::Array<Common::Point> _lightSwitchPositions;
129  Common::Array<bool> _lightSwitchStates;
130  int _lightSwitchPlayerIsOn = -1;
131 
132  const RCPR *_puzzleData = nullptr;
134 };
135 
136 } // End of namespace Action
137 } // End of namespace Nancy
138 
139 #endif // NANCY_ACTION_RAYCASTPUZZLE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: raycastpuzzle.h:37
Definition: path.h:52
Definition: stream.h:745
Definition: input.h:41
Definition: commontypes.h:171
Definition: actionrecord.h:149
Definition: renderobject.h:36
Definition: enginedata.h:427
Definition: hashmap.h:85
Definition: commontypes.h:254
Definition: actionmanager.h:32