-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBall.h
48 lines (41 loc) · 1.02 KB
/
Ball.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
#pragma once
#include "surface.h"
#include "template.h"
#include "Ground.h"
#include "VerticalGround.h"
#include "Terrain.h"
class Ball
{
public:
Ball() : ballSprite(new Tmpl8::Surface("assets/golfball.png"), 1) {};
void HandleInput(Tmpl8::Surface* screen);
void Update(float deltaTime);
void ScreenCollisions();
void GroundCollisions(Ground g);
void VerticalCollisions(VerticalGround v);
void Reset();
void Draw(Tmpl8::Surface* screen);
int strokes = 0;
int totalStrokes = 0;
int activeGroundId = 0;
float startX = -13;
Tmpl8::vec2 pos = Tmpl8::vec2(ScreenWidth / 8, 0);
Tmpl8::vec2 v;
bool ballMoving = true;
bool startedAiming = false;
float frictionFactor = 1;
float bounceFactor = 1;
private:
float gravity = 0.0035f;
float friction = 0.001f;
float bounciness = 0.65f;
float radius = 13;
Tmpl8::vec2 a = Tmpl8::vec2(0, gravity);
Tmpl8::Sprite ballSprite;
Tmpl8::vec2 mousePosition;
Tmpl8::vec2 mouseStart;
Tmpl8::vec2 mouseEnd;
Tmpl8::vec2 direction;
int bounceCollisionCount = 0;
int activeSegment = 0;
};