-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cpp
87 lines (77 loc) · 1.89 KB
/
Player.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Almost Legal Speed - platform running game
// Copyright (C) 2018 Alexander Kraus <nr4@z10.info>
// Daniel Hauck <mail@dhauck.eu>
// Jonas Blahut <darkphoenix@jbtec.eu>
//
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Player.h>
#include <SFML/System/Time.hpp>
#include <cmath>
Player::Player()
{
reset();
}
void Player::reset()
{
pos.x = -10;
pos.y = -10;
initialized = false;
v.x = 0;
v.y = 0;
a = NONE;
face = LEFT;
forwardPower = 0.0;
upwardPower = 0.0;
speedPower = 0.0;
money = 0.0;
brainfreeze = 0.0;
pizza = false;
schnitzel = false;
inair = true;
jumping = false;
jump_count = 0;
drunken = 0;
pizza_start = sf::Time::Zero;
schnitzel_start = sf::Time::Zero;
game_start = sf::Time::Zero;
time_penalty = 0;
}
vec2 vec2::operator+(vec2 const& rhs) {
vec2 res;
res.x = x + rhs.x;
res.y = y + rhs.y;
return res;
}
void vec2::operator+=(vec2 const& rhs) {
x += rhs.x;
y += rhs.y;
}
vec2 vec2::operator*(double f) {
vec2 res;
res.x = x * f;
res.y = y * f;
return res;
}
void vec2::operator*=(double f) {
x *= f;
y *= f;
}
void vec2::operator/=(double f) {
x /= f;
y /= f;
}
double vec2::abs() {
return sqrt(x*x + y*y);
}