ScummVM API documentation
Shape.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/*
23 * This code is based on the CRAB engine
24 *
25 * Copyright (c) Arvind Raja Yadav
26 *
27 * Licensed under MIT
28 *
29 */
30
31#ifndef CRAB_SHAPE_H
32#define CRAB_SHAPE_H
33
34#include "crab/Polygon.h"
35#include "crab/vectors.h"
36
37namespace Crab {
38
39// The kind of shape
40enum ShapeType {
41 SHAPE_RECT,
42 SHAPE_POLYGON,
43 SHAPE_ELLIPSE
44};
45
47 // Store the type of shape
48 ShapeType _type;
49
50 // Do the two shapes intersect?
51 bool _intersect;
52
53 // If Shape is Polygon, the .x and .y of this rectangle contain the minimum translation vector
54 // If Shape is Rectangle, this contains the colliding rectangle
55 Rect _data;
56
58 _type = SHAPE_RECT;
59 _intersect = false;
60 }
61};
62
63class Shape {
64public:
65 // The type of shape
66 ShapeType _type;
67
68 // This stores both the ellipse and rectangle data
69 Rect _rect;
70
71 // This stores the polygon data
72 Polygon2D _poly;
73
74 Shape() {
75 _type = SHAPE_RECT;
76 }
77
78 ~Shape() {}
79
80 void load(rapidxml::xml_node<char> *node, const bool &echo = true);
81 CollisionData collide(Rect box) const;
82
83 bool contains(const Vector2i &pos);
84
85 void draw(const int &xOffset = 0, const int &yOffset = 0,
86 const uint8 &r = 0, const uint8 &g = 0, const uint8 &b = 0, const uint8 &a = 255);
87};
88
89} // End of namespace Crab
90
91#endif // CRAB_SHAPE_H
Definition: Polygon.h:58
Definition: Shape.h:63
Definition: Shape.h:46
Definition: Rectangle.h:42