-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe2.h
101 lines (85 loc) · 1.99 KB
/
frame2.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef FRAME2_H
#define FRAME2_H
#include <stdio.h>
#include <stdlib.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
#include <allegro5/allegro_primitives.h>
#include "./algif5/src/algif.h"
#include <vector>
#include <functional>
#include "levi.h"
#include "frame.h"
enum class ItemType2 {
Tube, Obstacle, Titan
};
struct Item2 {
ALLEGRO_BITMAP* bitmap;
float x;
float y;
ItemType2 type;
float width;
float height;
bool collectible;
bool touched;
};
struct ItemData2 {
const char* filePath;
float x;
float y;
ItemType2 type;
float width;
float height;
bool collectible;
bool touched;
};
class Frame2 {
public:
Frame2();
void Init(Frame& frame);
void Update(Levi& levi);
void Draw();
void Destroy();
void Ding(Levi& levi);
void HandleCollision(Item2& item2, Levi& levi);
void Stop(ALLEGRO_EVENT &event);
void Shift();
bool PreventUp() const;
bool PreventDown() const;
bool failGame() const;
int Tube() const;
private:
bool fail = false;
float x;
float speed;
int life, atk;
int tube;
bool isDying;
float dyingDuration;
float dyingTimeElapsed;
ALLEGRO_TIMER*frame_timer;
ALLEGRO_EVENT_QUEUE *event_queue = NULL;
ALLEGRO_EVENT event;
bool preventUp;
bool preventDown;
std::vector<Item2> items; // Changed from 'obstacles' to 'items'
ALLEGRO_FONT *font = NULL;
ALLEGRO_BITMAP *ding = NULL;
ALLEGRO_BITMAP *key;
ALLEGRO_BITMAP *gain;
ALLEGRO_SAMPLE *sample = NULL;
ALLEGRO_SAMPLE_INSTANCE *dingSound = NULL;
ALLEGRO_SAMPLE_INSTANCE *oi = NULL;
ALLEGRO_SAMPLE_INSTANCE *hit = NULL;
bool showDing = false;
float dingX, dingY;
double dingStartTime;
const double dingDuration = 0.3;
float currentPauseTime;
float pauseDuration;
bool isPaused;
};
#endif // FRAME2_H