-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCenemy.h
More file actions
executable file
·79 lines (65 loc) · 2.78 KB
/
Cenemy.h
File metadata and controls
executable file
·79 lines (65 loc) · 2.78 KB
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
#pragma once
#include <vector>
#include <cmath>
#include <stdio.h>
#include "Copengl.h"
#include "Cbullet.h"
#include "constOpengl.h"
#include "constEnemy.h"
#include "CparticleController.h"
#include "CplayerBullet.h"
#include "Cloader.h"
#include "Cscore.h"
#include "Cbullet.h"
#include "constImages.h"
class Cenemy {
public:
Cenemy(float x, float y, float aimX, float aimY, ENEMY::TYPE type=ENEMY::TYPE::DEFAULT, int hp=1, float speed=ENEMY::DEFAULT_SPEED);
Cenemy(float x, float y, ENEMY::TYPE type=ENEMY::TYPE::DEFAULT, int hp=1, float speed=ENEMY::DEFAULT_SPEED);
ENEMY::STEP step(Cloader &loader, std::vector<CplayerBullet*> &playerBullets, std::vector<Cbullet*> &bullets, CparticleController &particleController, Cscore &score, float playerX, float playerY);
bool die(Cloader &loader, CparticleController &particleController, Cscore &score);
OPENGL::vanillaPoint* draw(Copengl &opengl, OPENGL::vanillaPoint* freeSpace);
void set_aim(float aimX, float aimY, float speed=ENEMY::DEFAULT_SPEED);
void add_action(unsigned int minFrame, ENEMY::EVENT event, float angleOffset=0.0f, float x=0.0f, float y=0.0f, float speed=5.0f);
void move_at_pixels(unsigned int frame, int x, int y, float speed=0.0f);
void shoot_player(unsigned int frame, float angleOffset=0.0f, float speed=0.0f);
void shoot_at(unsigned int frame, int x, int y, float angleOffset=0.0f, float speed=0.0f);
void shoot_angle(unsigned int frame, float angle, float speed=0.0f);
void delete_self(unsigned int frame);
float get_x();
float get_y();
private:
bool do_actions(std::vector<Cbullet*> &bullets, float playerX, float playerY);
float x;
float y;
float previousX;
float previousY;
ENEMY::TYPE type;
int hp;
float speed;
float xSpeed;
float ySpeed;
int framesTillStop;
unsigned int frame;
std::vector<ENEMY::action> actionQueue;
};
inline
void Cenemy::move_at_pixels(unsigned int frame, int x, int y, float speed) {
add_action(frame, ENEMY::MOVE_AT, 0.0f, OPENGL::LEFT_SIDE_X+Copengl::convert_pixel_width(x), OPENGL::TOP_Y-Copengl::convert_pixel_height(y), speed);
}
inline
void Cenemy::shoot_player(unsigned int frame, float angleOffset, float speed) {
add_action(frame, ENEMY::SHOOT_PLAYER, angleOffset, 0.0f, 0.0f, speed);
}
inline
void Cenemy::shoot_at(unsigned int frame, int x, int y, float angleOffset, float speed) {
add_action(frame, ENEMY::SHOOT_AT, angleOffset, OPENGL::LEFT_SIDE_X+Copengl::convert_pixel_width(x), OPENGL::TOP_Y-Copengl::convert_pixel_height(y), speed);
}
inline
void Cenemy::shoot_angle(unsigned int frame, float angle, float speed) {
add_action(frame, ENEMY::SHOOT_ANGLE, angle, 0.0f, 0.0f, speed);
}
inline
void Cenemy::delete_self(unsigned int frame) {
add_action(frame, ENEMY::DELETE_SELF);
}