-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathingame.cpp
More file actions
97 lines (66 loc) · 2.42 KB
/
Copy pathingame.cpp
File metadata and controls
97 lines (66 loc) · 2.42 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "ingame.h"
InGame::InGame()
{
}
InGame::InGame(int width, int height)
{
MainFrame = new QFrame();
MainFrame->resize(width, height);
env = new Environment();
SFMLView = new QSFcanvas(QPoint(0,0),QSize(width,height),MainFrame);
// gui = new InGameUI(QPoint(0,height-50),QSize(width,50));
env->setHitbox("graphics/hitmap1.png");
Width = width;
Height = height;
setMinimumSize(width,height);
Pause = new QMessageBox(this);
endLevel = new QMessageBox();
// SM = new SoundManager("Fly_menu.mp3",12800);
container = new QVBoxLayout(this);
container->addWidget(MainFrame);
// container->addWidget(gui);
container->setMargin(0);
endLevel->setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
Pause->setText("Pause");
// Préparation du timer
timer.setInterval(TIMER);
}
void InGame::init(){
MainFrame->show();
SFMLView->show();
env->init();
SFMLView->initView(env->getHero()->get_x(),env->getHero()->get_y(),Width,Height);
connect(env,SIGNAL(sendHeroPos(int,int)),SFMLView,SLOT(updateView(int,int)));
connect(env,SIGNAL(sendEM(QMap<int,Entite*>&)),SFMLView,SLOT(receiveEM(QMap<int,Entite*>&)));
connect(env,SIGNAL(moveSecondPlan(QPair<double,double>)),&(SFMLView->getDM()),SLOT(moveSecondPlan(QPair<double,double>)));
connect(env,SIGNAL(initSecondPlan()),&(SFMLView->getDM()),SLOT(initSecondPlan()));
connect(SFMLView,SIGNAL(switchTrigger()),env,SLOT(switchTriggers()));
// On paramètre le timer de sorte qu'il génère un rafraîchissement à la fréquence souhaitée
connect(&timer, SIGNAL(timeout()), SFMLView, SLOT(repaint()));
connect(&timer,SIGNAL(timeout()),env,SLOT(run()));
connect(SFMLView, SIGNAL(turnLeft(bool)), env, SLOT(turnLeft(bool)));
connect(SFMLView, SIGNAL(turnRight(bool)), env, SLOT(turnRight(bool)));
connect(SFMLView, SIGNAL(jump()), env, SLOT(jump()));
connect(SFMLView, SIGNAL(dash(bool)), env, SLOT(dash(bool)));
timer.start();
// SM->playPause();
}
void InGame::changeMusic(QString str){
SM->playPause();
SM = new SoundManager(str,12800);
SM->playPause();
}
void InGame::pausePopUp(){
if(Pause->isEnabled())
Pause->close();
else Pause->exec();
}
void InGame::endLvlPopUp(QString str){
endLevel->setText(str);
endLevel->exec();
}
void InGame::pause(){
if(timer.isActive())
timer.stop();
else timer.start();
}