File: player.h

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (88 lines) | stat: -rw-r--r-- 2,728 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef DARKSEED_PLAYER_H
#define DARKSEED_PLAYER_H

#include "common/rect.h"
#include "common/path.h"
#include "darkseed/nsp.h"

namespace Darkseed {

class Player {
	Nsp _cPlayerSprites;
	Nsp _gPlayerSprites;

public:
	Nsp _animations;
	int _frameIdx = 0;
	int _direction = 0;
	Common::Point _position;
	Common::Point _positionLong; // the original sometimes seems to use a long (4 byte) version of the location
	Common::Point _walkTarget;
	Common::Point _finalTarget;

	int16 _playerSpriteWalkIndex_maybe = 0;
	int16 _playerWalkFrameDeltaOffset = 0;
	int16 _playerNewFacingDirection_maybe = 0;
	uint16 _playerWalkFrameIdx = 0;
	bool _actionToPerform = false; // player is pathfinding to some destination?
	bool _playerIsChangingDirection = false; // AKA _Rotating
	bool _isAutoWalkingToBed = false;
	bool _heroMoving = false; // maybe set to true while player is walking around the room.
	bool _heroWaiting = false;
	int _walkPathIndex = -1;
	uint16 _numConnectorsInWalkPath = 0;
	Common::Array<Common::Point> _connectorList;
	int16 _sequenceRotation = -1;
	bool _walkToSequence = false;
	Common::Point _walkToSequencePoint;
	bool _flipSprite = false;

	Player();
	bool loadAnimations(const Common::Path &filename);
	const Sprite &getSprite(int frameNo) const;
	void updateSprite();
	void draw();

	bool isAtPosition(int x, int y) const;
	bool isAtWalkTarget() const;
	void calculateWalkTarget();

	void changeDirection(int16 oldDir, int16 newDir);
	void playerFaceWalkTarget();
	int getWidth();
	int getHeight();
	void updatePlayerPositionAfterRoomChange();
	void setPlayerTowardsBedroom();
	void walkToNextConnector();

private:
	void createConnectorPathToDest();
	Common::Point getClosestUnusedConnector(int16 x, int16 y, bool mustHaveCleanLine = false);
	void reverseConnectorList();
	void optimisePath();
};

} // namespace Darkseed

#endif // DARKSEED_PLAYER_H