-
Notifications
You must be signed in to change notification settings - Fork 0
/
Paddle.cpp
69 lines (60 loc) · 1.96 KB
/
Paddle.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
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
#include "Paddle.h"
#include <iostream>
//---------------------------------------------------------------------------
Paddle::Paddle(Ogre::String nym, Ogre::SceneManager* mgr, Simulator* sim, Ogre::SceneNode* shipNode, int &sc, SoundPlayer* sPlayer) : GameObject(nym, mgr, sim), score(sc)
{
name = nym;
Ogre::Vector3 shipPos = shipNode -> getPosition();
rootNode->setPosition(Ogre::Vector3(shipPos.x - 8.25f, shipPos.y + 0.0f, shipPos.z + 10.0f));
soundPlayer = sPlayer;
}
//---------------------------------------------------------------------------
Paddle::~Paddle(void)
{
}
//---------------------------------------------------------------------------
void Paddle::addToScene(void)
{
geom = sceneMgr->createEntity(name + "Ent", "paddle.mesh");
geom->setCastShadows(true);
rootNode->attachObject(geom);
mass = 1.0f;
shape = new btBoxShape(btVector3(5,4,1));
}
//---------------------------------------------------------------------------
void Paddle::addToSimulator(void)
{
GameObject::addToSimulator();
body->forceActivationState(DISABLE_DEACTIVATION);
body->setLinearFactor(btVector3(1,0,1));
}
//---------------------------------------------------------------------------
void Paddle::update(void)
{
if(!context->hit) {
hasIncr = false;
}
if (!hasIncr && context->hit){
soundPlayer->playScore();
hasIncr = true;
}
}
//---------------------------------------------------------------------------
void Paddle::injectKeyDown(const OIS::KeyEvent &arg)
{
}
//---------------------------------------------------------------------------
void Paddle::injectKeyUp(const OIS::KeyEvent &arg)
{
}
//---------------------------------------------------------------------------
void Paddle::setPaddleHinge(btHingeConstraint* paddleHinge)
{
hinge = paddleHinge;
}
//---------------------------------------------------------------------------
btHingeConstraint* Paddle::getPaddleHinge()
{
return hinge;
}
//---------------------------------------------------------------------------