Arkanoid Remake  1.0
VecXy.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 VECXY_H
41 #define VECXY_H
42 
45 
59 struct VecXy
60 {
61  double X;
62  double Y;
63 
65  VecXy(double vx=0.0, double vy=0.0)
66  : X(vx), Y(vy)
67  {
68  }
69 };
70 
74 inline VecXy& operator +=(VecXy& v1,const VecXy& v2)
75 {
76  v1.X += v2.X;
77  v1.Y += v2.Y;
78  return v1;
79 }
80 
81 inline VecXy& operator -=(VecXy& v1,const VecXy& v2)
82 {
83  v1.X += v2.X;
84  v1.Y += v2.Y;
85  return v1;
86 }
87 
88 inline VecXy operator +(const VecXy& v1,const VecXy& v2)
89 {
90  return VecXy(v1.X + v2.X, v1.Y + v2.Y);
91 }
92 
93 inline VecXy operator -(const VecXy& v1,const VecXy& v2)
94 {
95  return VecXy(v1.X - v2.X, v1.Y - v2.Y);
96 }
97 
98 inline VecXy operator *(const VecXy& v1,const VecXy& v2)
99 {
100  return VecXy(v1.X * v2.X, v1.Y * v2.Y);
101 }
102 
103 inline VecXy operator /(const VecXy& v1,const VecXy& v2)
104 {
105  return VecXy(v1.X / v2.X, v1.Y / v2.Y);
106 }
107 
108 inline VecXy operator *(const VecXy& v1,const double& v2)
109 {
110  return VecXy(v1.X * v2, v1.Y * v2);
111 }
112 
113 inline VecXy operator /(const VecXy& v1,const double& v2)
114 {
115  return VecXy(v1.X / v2, v1.Y / v2);
116 }
117 
118 inline VecXy operator *(const double& v2,const VecXy& v1)
119 {
120  return VecXy(v1.X * v2, v1.Y * v2);
121 }
122 
123 inline VecXy operator /(const double& v2,const VecXy& v1)
124 {
125  return VecXy(v1.X / v2, v1.Y / v2);
126 }
127 
128 inline VecXy operator -(const VecXy& v1)
129 {
130  return VecXy(-v1.X, -v1.Y);
131 }
132 
134 
136 
137 
138 #endif//VECXY_H
VecXy(double vx=0.0, double vy=0.0)
Constructor.
Definition: VecXy.h:65
Vector with two (double precision) coordinate values.
Definition: VecXy.h:59
double Y
Vertical coordinate.
Definition: VecXy.h:62
double X
Horizontal coordinate.
Definition: VecXy.h:61