89c5ee5f70143ee420c65c44e509aa73bb53be89
[supertux.git] / src / math / aatriangle.hpp
1 //  $Id$
2 //
3 //  SuperTux
4 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 //
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19
20 #ifndef __AATRIANGLE_H__
21 #define __AATRIANGLE_H__
22
23 #include "rect.hpp"
24
25 /**
26  * An axis-aligned triangle (ie. a triangle where 2 sides are parallel to the x-
27  * and y-axis.
28  */
29 class AATriangle : public Rect
30 {
31 public:
32   /** Directions:
33    *
34    *    SOUTHEWEST    NORTHEAST   SOUTHEAST    NORTHWEST
35    *    *      or      *---*   or      *    or *---*
36    *    | \             \  |         / |       |  /
37    *    |  \             \ |        /  |       | /
38    *    *---*              *       *---*       *
39    *
40    * Deform flags: (see docs/aatriangletypes.png for details)
41    */
42   enum Direction {
43     SOUTHWEST = 0,
44     NORTHEAST,
45     SOUTHEAST,
46     NORTHWEST,
47     DIRECTION_MASK = 0x0003,
48     DEFORM1 = 0x0010,
49     DEFORM2 = 0x0020,
50     DEFORM3 = 0x0030,
51     DEFORM4 = 0x0040,
52     DEFORM_MASK = 0x0070
53   };
54
55   AATriangle()
56     : dir(SOUTHWEST)
57   {
58   }
59   AATriangle(const Vector& v1, const Vector& v2, int newdir)
60     : Rect(v1, v2), dir(newdir)
61   {
62   }
63
64   int dir;
65 };
66
67 #endif