View.hpp
1
// Copyright 2019 Arthur Sonzogni. All rights reserved.
2
// Use of this source code is governed by the MIT license that can be found in
3
// the LICENSE file.
4
5
#ifndef SMK_VIEW_HPP
6
#define SMK_VIEW_HPP
7
8
#include <glm/glm.hpp>
9
10
namespace
smk {
11
12
/// Represent the area in the game to be drawn on the screen. To preserve the
13
/// screen ratio, the view ratio must be the same.
14
class
View
{
15
public
:
16
void
SetCenter
(
float
x,
float
y);
17
void
SetCenter
(
const
glm::vec2& center);
18
void
SetSize
(
float
width,
float
height);
19
void
SetSize
(
const
glm::vec2& size);
20
21
float
Left()
const
{
return
x_
- width_ / 2; };
/// <
22
float
Right
()
const
{
return
x_
+ width_ / 2; };
/// <
23
float
Top
()
const
{
return
y_ - height_ / 2; };
/// <
24
float
Bottom
()
const
{
return
y_ + height_ / 2; };
/// <
25
26
public
:
27
float
x_
= 0.f;
28
float
y_ = 0.f;
29
float
width_ = 0.f;
30
float
height_ = 0.f;
31
};
32
33
}
// namespace smk
34
35
#endif
/* end of include guard: SMK_VIEW_HPP */
smk::View
Definition:
View.hpp:14
smk::View::Bottom
float Bottom() const
<
Definition:
View.hpp:24
smk::View::Right
float Right() const
<
Definition:
View.hpp:22
smk::View::x_
float x_
<
Definition:
View.hpp:27
smk::View::Top
float Top() const
<
Definition:
View.hpp:23
smk::View::SetCenter
void SetCenter(float x, float y)
Set the center position of the in-game view. param x The center of the view along the horizontal axis...
Definition:
View.cpp:12
smk::View::SetSize
void SetSize(float width, float height)
Set the size of the in-game view. param width The size of the view along the horizontal axis....
Definition:
View.cpp:26