-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameobjectbool.cpp.autosave
103 lines (85 loc) · 2.34 KB
/
gameobjectbool.cpp.autosave
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
102
103
#include "gameobjectpool.h"
Gameobjectbool* Gameobjectbool::instance = nullptr;
Gameobjectbool::Gameobjectbool(QObject* parent):QObject (parent)
{
}
void Gameobjectbool::Init()
{
for(int i=0;i<50;i++)
{
player_bullet* p_bullet = new player_bullet(QPixmap(":/img/D:/桌面/插图/我方子弹.png"));
mPlayerBulletList.append(p_bullet);
elitist_bullet* e_bullet = new elitist_bullet(QPixmap(":/img/D:/桌面/插图/敌人子弹1.png"));
mElitistBulletList.append(e_bullet);
enemy* e = new enemy(QPixmap(":/img/D:/桌面/插图/新建文件夹/parrot.png"));
mEnemyList.append(e);
Elitist* el = new Elitist(QPixmap(":/img/D:/桌面/插图/新建文件夹/rabbit.png"));
mElitistList.append(el);
}
}
Gameobject *Gameobjectbool::GetGameobject(int object_type)
{
switch (object_type)
{
case Gameobject::O_p_bullet:
{
player_bullet* bullet = mPlayerBulletList.first();
mPlayerBulletList.pop_front();
return bullet;
}
case Gameobject::O_e_bullet:
{
elitist_bullet* bullet = mElitistBulletList.first();
mElitistBulletList.pop_front();
return bullet;
}
case Gameobject::O_enemy:
{
enemy* e =mEnemyList.first();
mEnemyList.pop_front();
return e;
}
case Gameobject::O_elitist:
{
Elitist* el = mElitistList.first();
mElitistList.pop_front();
return el;
}
}
}
void Gameobjectbool::RecoverGameobject(Gameobject *obj)
{
switch (obj->get_type()) {
case Gameobject::O_p_bullet:
{
mPlayerBulletList.append((player_bullet*)obj);
break;
}
case Gameobject::O_e_bullet:
{
mElitistBulletList.append((elitist_bullet*)obj);
break;
}
case Gameobject::O_enemy:
{
mEnemyList.append((enemy*)obj);
break;
}
case Gameobject::O_elitist:
{
mElitistList.append((Elitist*)obj);
break;
}
}
}
void Gameobjectbool::clear()
{
qDeleteAll(mPlayerBulletList);
qDeleteAll(mElitistBulletList);
qDeleteAll(mEnemyList);
qDeleteAll(mElitistList);
}
Gameobjectbool::~Gameobjectbool()
{
clear();
}