-
Notifications
You must be signed in to change notification settings - Fork 0
/
key.cpp
30 lines (26 loc) · 1.02 KB
/
key.cpp
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
#include "key.h"
#include "player.h"
#include <iostream>
#include <QtMultimedia/QMediaPlayer>
Key::Key(Player* p,QVector2D pos,QVector2D text):Interactable2D (pos,text,0),picked(false),player(p),altText(2,1){
splayer = new QMediaPlayer;
splayer->setMedia(QUrl::fromLocalFile("key.wav"));
splayer->setVolume(50);
}
Key::Key(Player* p,QVector2D pos,QVector2D text, bool state, QVector2D d): Interactable2D (pos,text,0),picked(state),altText(d),player(p){
splayer = new QMediaPlayer;
splayer->setMedia(QUrl::fromLocalFile("key.wav"));
splayer->setVolume(50);
}
//on pickup par le joueur, jouer son, changer de sprite et donner la clé au joueur
int Key::OnTriggerEnter(Interactable2D* other){
if (!picked){
if(dynamic_cast<Player*> (other)!=NULL){
picked = true;//empeche de collide plusieurs fois
splayer->play();//son
this->renderer.spriteCoords = altText;
this->renderer.CreateGeometry();
player->PickKey();//file la clé
}
}
}