-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEngine_Input.cpp
151 lines (133 loc) · 3.53 KB
/
Engine_Input.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include "stdafx.h"
#include "Engine.h"
#include "Player.h"
#include "GeneralFunctions.h"
#include <cmath>
#include <iostream>
void Engine::Input()
{
sf::Event event;
while (m_Window.pollEvent(event))
{
// Updates Cursor Position and Angle
vec_CursorPosition.x = sf::Mouse::getPosition(m_Window).x - (Resolution.x / 2);
vec_CursorPosition.y = sf::Mouse::getPosition(m_Window).y - (Resolution.y / 2);
flo_AngleCursor = (atan2(vec_CursorPosition.x, vec_CursorPosition.y) * 180 / PI) + 180;
// Handle the player quitting
if (Keyboard::isKeyPressed(Keyboard::Escape))
{
m_Window.close();
}
//-------------HUD INPUT-------------------
// Resets Position/Velocity Data
if (Keyboard::isKeyPressed(Keyboard::H))
{
hud.ResetMinMax(player.vec_Position, player.vec_Velocity);
}
if (Keyboard::isKeyPressed(Keyboard::Num0))
{
hud.ht_CurrentMode = RELEASE;
}
if (Keyboard::isKeyPressed(Keyboard::Num1))
{
hud.ht_CurrentMode = MOVEMENT;
}
if (Keyboard::isKeyPressed(Keyboard::Num2))
{
hud.ht_CurrentMode = COMBAT;
}
if (!player.GetState().CurrentState == CS_DEAD)
{
//-----------PLAYER INPUT-----------------
// Handle the player moving Left/Right
if (Keyboard::isKeyPressed(Keyboard::A))
{
player.MoveLeft();
player.recieveDamage(1);
}
else
{
player.StopLeft();
}
if (Keyboard::isKeyPressed(Keyboard::D))
{
player.MoveRight();
}
else
{
player.StopRight();
}
// Handle Player Duck and Roll
if (Keyboard::isKeyPressed(Keyboard::S) && player.GetState().Jumping == false)
{
player.EngageDuck();
}
else
{
player.DisengageDuck();
}
if (Keyboard::isKeyPressed(Keyboard::Left) && (player.GetState().Ducking == true && player.GetState().Rolling == false))
{
player.EngageLeftRoll();
}
else if (Keyboard::isKeyPressed(Keyboard::Right) && (player.GetState().Ducking == true && player.GetState().Rolling == false))
{
player.EngageRightRoll();
}
// Handle Player Jumping
if (Keyboard::isKeyPressed(Keyboard::W) && player.GetState().CanJump == true)
{
player.EngageJump();
}
// Player Shooting
if (sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)
&& (player.sta_Current.Shooting == false && player.sta_Current.Meleeing == false))
{
int num = 0;
for (int count = 0; count < map_Selected.int_MaxEnemyIndex; count++)
{
if (ene_Spawned[map_Selected.int_LoadedEnemies[count]].flo_FinalDuration > 0)
{
num++;
player.EngageRange(flo_AngleCursor, ene_Spawned[map_Selected.int_LoadedEnemies[count]]);
hud.UpdateReports(OUTPUT, player.GetDamageReport(OUTPUT));
}
}
if (num == 0)
{
EnemyObject blank;
player.EngageRange(flo_AngleCursor, blank);
}
}
// Player Blocking
if (Mouse::isButtonPressed(Mouse::Right))
{
player.EngageBlock();
}
else
{
player.DisengageBlock();
}
// Player Meleeing
if (Keyboard::isKeyPressed(Keyboard::F)
&& (player.sta_Current.Shooting == false && player.sta_Current.Meleeing == false))
{
int num = 0;
for (int count = 0; count < map_Selected.int_MaxEnemyIndex; count++)
{
if (ene_Spawned[map_Selected.int_LoadedEnemies[count]].flo_FinalDuration > 0)
{
num++;
player.EngageMelee(flo_AngleCursor, ene_Spawned[map_Selected.int_LoadedEnemies[count]]);
hud.UpdateReports(OUTPUT, player.GetDamageReport(OUTPUT));
}
}
if (num == 0)
{
EnemyObject blank;
player.EngageMelee(flo_AngleCursor, blank);
}
}
}
}
}