-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.h
79 lines (50 loc) · 1.38 KB
/
Character.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
#pragma once
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <string>
#include <vector>
#include "TextureAPI.h"
#include "GlobalResource.h"
#include "Bullet.h"
#include "EnemyBullet.h"
using namespace std;
class Character {
public:
static const int CHARACTER_WIDTH = 44;
static const int CHARACTER_HEIGHT = 56;
static const int MIN_CHARACTER_VEL = 50;
static const int MAX_CHARACTER_VEL = 300;
Character();
void loadFromFile(SDL_Renderer *renderer, string path);
//Takes key presses and adjusts the dot's velocity
void handleEvent(SDL_Event& e);
//Moves the dot
void move(double timeStep);
//Shows the dot on the screen
void render(SDL_Renderer *renderer);
void free();
void shoot();
void createBullet(EnemyBullet &bullet, double angle = 90);
void moveBullets(double timeStep);
vector<Bullet> getBullets();
double getX();
double getY();
int getHp();
void setHp(int hp);
void setDefaultPlace();
private:
TextureAPI characterTexture;
TextureAPI bulletTexture;
const string CHARACTER_PATH = "Resource/Image/planeWithHitBox.png";
const string BULLET_PATH = "Resource/Image/bullet.png";
SDL_Rect currentClip = { 0,0,44,56 };
//The X and Y offsets of the dot
double mPosX, mPosY;
//Center of the hitbox
const int HITBOX_RADIUS = 3;
double mVelX, mVelY;
int hp;
vector <Bullet> bullets;
};