-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHook.h
87 lines (70 loc) · 2.13 KB
/
Hook.h
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
#ifndef __Block_Frog__Hook__
#define __Block_Frog__Hook__
#include <iostream>
#include <Box2D/Box2D.h>
#include <SFML/Graphics.hpp>
class Circle;
class Rectangle;
class Game;
class Utility;
class ContactListener;
class Player;
class Hook
{
public:
Hook(Game* game_, Player* player_);
~Hook();
enum Action
{
SHOOTING,
PASSIVE
};
void draw();
void update();
void shoot(sf::Vector2i mousePixelPos);
void aim(sf::Vector2i mousePixelPos);
void release();
b2RevoluteJoint* grab(b2Body* box);
float getLength();
void changeLength(float delta);
//network
Circle* getHookTip(){ return hookTip; };
Rectangle* getHookBase() { return hookBase; };
float getPassiveLength() { return passiveLength; }
b2Body* getGrabbedBox() { return grabbedBox; }
int getAction() {return ACTION;};
private:
Game* game;
Circle* hookTip;
Rectangle* hookBase;
Utility* utility;
ContactListener* contactListener;
Player* player;
int localID;
Action ACTION;
// This is set in grab and used by makeStatic to release hook if grabbed box
// just got static. We cannot hook static shapes and therefore this should happen
b2Body* grabbedBox;
b2PrismaticJoint* prismaticJoint;
b2RevoluteJoint* revoluteJoint;
b2RevoluteJoint* grabJoint;
// The most recent box we have hit with hook
b2Body* recentBoxContact;
b2Vec2 playerMeterPos;
float newMouseAngle;
float oldMouseAngle;
// This is the length the hook is striving towards having
float passiveLength;
// This is the length the hook should have when holding a box
float grabLength;
// This is the length we want to strive towards when using hook
float reachLength;
// This is needed so as to not, for example, go into the if case
// of hook length > x several times because it has yet to adjust
float currentLength;
float minLength;
// This is only needed for comparison in calculating what degree
// set the revolute joint at. See Utility::mouseAngle
float hookDegrees;
};
#endif /* defined(__Block_Frog__Hook__) */