Arkanoid Remake  1.0
BoxObj.h
Go to the documentation of this file.
1 /*
2 ArkanoidRemakeSDL
3 a sample of object-oriented game programming with C++.
4 version 1.0, May 2016
5 
6 Copyright (c) 2016 Giovanni Paolo Vigano'
7 
8 The source code of the SDL library used by ArkanoidRemakeSDL can be found here:
9 https://www.libsdl.org/
10 ---
11 ArkanoidRemakeSDL source code is licensed with the same zlib license:
12 (http://www.gzip.org/zlib/zlib_license.html)
13 
14 This software is provided 'as-is', without any express or implied warranty. In
15 no event will the authors be held liable for any damages arising from the use of
16 this software.
17 
18 Permission is granted to anyone to use this software for any purpose, including
19 commercial applications, and to alter it and redistribute it freely, subject to
20 the following restrictions:
21 
22  1. The origin of this software must not be misrepresented; you must not
23  claim that you wrote the original software. If you use this software in a
24  product, an acknowledgment in the product documentation would be appreciated
25  but is not required.
26 
27  2. Altered source versions must be plainly marked as such, and must not be
28  misrepresented as being the original software.
29 
30  3. This notice may not be removed or altered from any source distribution.
31 */
32 
33 
37 
38 #pragma once
39 
40 #ifndef BOXOBJ_H
41 #define BOXOBJ_H
42 
43 #include <VecXy.h>
44 
47 
51 class BoxObj
52 {
53 public:
55  BoxObj(double x=0.0, double y=0.0)
56  : mPos(x,y)
57  {
58  }
59 
60  // Copy constructor
61  BoxObj(const BoxObj& obj)
62  : mPos(obj.Pos()), mSize(obj.Size()), mOrigin(obj.Origin())
63  {
64  }
65 
67  VecXy& Pos() { return mPos; }
68 
70  const VecXy& Pos() const { return mPos; }
71 
73  VecXy& Origin() { return mOrigin; }
74 
76  const VecXy& Origin() const { return mOrigin; }
77 
79  VecXy& Size() { return mSize; }
80 
82  const VecXy& Size() const { return mSize; }
83 
84 
85  //VecXy Centre() const { return mPos+mOrigin+mSize/2.0; }
86 
88  const double MinX() const { return mPos.X+mOrigin.X; }
89 
91  const double MinY() const { return mPos.Y+mOrigin.Y; }
92 
94  const double MaxX() const { return MinX()+mSize.X; }
95 
97  const double MaxY() const { return MinY()+mSize.Y; }
98 
100  const VecXy HSize() const { return mSize/2.0; }
101 
103  const double HSizeX() const { return mSize.X/2.0; }
104 
106  const double HSizeY() const { return mSize.Y/2.0; }
107 
108 
109 protected:
110 
111  VecXy mPos;
112  VecXy mSize;
113  VecXy mOrigin;
114 };
115 
117 
118 #endif//BOXOBJ_H
119 
const VecXy HSize() const
Half size.
Definition: BoxObj.h:100
BoxObj(double x=0.0, double y=0.0)
Default constructor with optional intialization list.
Definition: BoxObj.h:55
Vector with two (double precision) coordinate values.
Definition: VecXy.h:59
const VecXy & Origin() const
Origin (min x,y corner, read-only)
Definition: BoxObj.h:76
const double HSizeX() const
Half size along X axis.
Definition: BoxObj.h:103
const double MaxY() const
Upper X value.
Definition: BoxObj.h:97
A box-shaped object.
Definition: BoxObj.h:51
const VecXy & Pos() const
Position (read only)
Definition: BoxObj.h:70
const double MaxX() const
Upper X value.
Definition: BoxObj.h:94
double Y
Vertical coordinate.
Definition: VecXy.h:62
double X
Horizontal coordinate.
Definition: VecXy.h:61
const VecXy & Size() const
Size (read only)
Definition: BoxObj.h:82
VecXy & Size()
Size.
Definition: BoxObj.h:79
const double MinX() const
Lower X value.
Definition: BoxObj.h:88
VecXy & Origin()
Origin (min x,y corner)
Definition: BoxObj.h:73
VecXy & Pos()
Position.
Definition: BoxObj.h:67
2-dimensional vector
const double MinY() const
Lower Y value.
Definition: BoxObj.h:91
const double HSizeY() const
Half size along Y axis.
Definition: BoxObj.h:106