-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.h
99 lines (82 loc) · 1.96 KB
/
frame.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
#ifndef FRAME_H
#define FRAME_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"
enum class ItemType {
BlackTea, Broom, BrokenGlass, StinkySocks, Obstacle, Character
};
struct Item {
ALLEGRO_BITMAP* bitmap;
float x;
float y;
ItemType type;
float width;
float height;
bool collectible;
bool touched;
};
struct ItemData {
const char* filePath;
float x;
float y;
ItemType type;
float width;
float height;
bool collectible;
bool touched;
};
class Frame {
public:
Frame();
void Init();
void Update(Levi& levi);
void Draw();
void Destroy();
void Ding(Levi& levi);
void HandleCollision(Item& item, Levi& levi);
void Stop(ALLEGRO_EVENT &event);
void Shift();
bool PreventUp() const;
bool PreventDown() const;
int getLife() const;
int getAtk() const;
private:
float x;
float speed;
int life, atk;
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<Item> 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 // FRAME_H