RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
ccustomscene.cpp
Go to the documentation of this file.
1 //--------------------------------------------------------------- @License begins
2 // RioEngine: The late night Coke -without whores- debugging sessions
3 // 2012-2015 Leopoldo Lomas Flores. Torreon, Coahuila. MEXICO
4 // leopoldolomas [at] gmail
5 // www.rioengine.com
6 // www.leopoldolomas.info
7 // "You have a problem, you face it like a man."
8 //
9 // This is free and unencumbered software released into the public domain.
10 //
11 // Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
12 // software, either in source code form or as a compiled binary, for any purpose,
13 // commercial or non-commercial, and by any means.
14 //
15 // In jurisdictions that recognize copyright laws, the author or authors of this
16 // software dedicate any and all copyright interest in the software to the public
17 // domain. We make this dedication for the benefit of the public at large and to
18 // the detriment of our heirs and successors. We intend this dedication to be
19 // an overt act of relinquishment in perpetuity of all present and future
20 // rights to this software under copyright law.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS
24 // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 //--------------------------------------------------------------- @License ends
29 
30 #include "cengine/cdirector.h"
32 #include "shootingrange/cplayer.h"
34 
35 //-----------------------------------------------------------------------------
36 
38  m_player = NULL;
39 }
40 
41 //-----------------------------------------------------------------------------
42 
43 void CCustomScene::deployPlayer() {
44  m_player = static_cast<CPlayer*>(createGameObjectWithNode("Cube", true, "CPlayer"));
45  m_player->setVisible(false);
46  m_player->setName("__player");
47  m_player->setPosition(btVector3(0, 0.2f, 0));
48  m_player->setbMass(1.0f);
49  m_player->calcSize();
50  m_player->deployIntoDynamicsWorld();
51 }
52 
53 //-----------------------------------------------------------------------------
54 
57 
58  // Enemy Launcher 1
59  CEnemyLauncher* enemy = qobject_cast<CEnemyLauncher*>(getGameObjectHavingTag(1));
60  if(enemy != NULL) {
61  enemy->launchEnemy(1.0f, 1.5f, false);
62  }
63 
64  // Enemy Launcher 2
65  enemy = qobject_cast<CEnemyLauncher*>(getGameObjectHavingTag(2));
66  if(enemy != NULL) {
67  enemy->launchEnemy(2.5f, 1.75f, true);
68  enemy->launchEnemy(3.7f, 1.75f, true);
69  enemy->launchEnemy(4.9f, 1.75f, true);
70  }
71 
72  // Enemy Launcher 3
73  enemy = qobject_cast<CEnemyLauncher*>(getGameObjectHavingTag(3));
74  if(enemy != NULL) {
75  enemy->launchEnemy(5.3f, 1.25f, true);
76  enemy->launchEnemy(6.1f, 1.5f, false);
77  }
78 
79  // Enemy Launcher 4
80  enemy = qobject_cast<CEnemyLauncher*>(getGameObjectHavingTag(4));
81  if(enemy != NULL) {
82  enemy->launchEnemy(7.5f, 1.0f, true);
83  enemy->launchEnemy(9.5f, 1.0f, true);
84  }
85 
86  // Enemy Launcher 5
87  enemy = qobject_cast<CEnemyLauncher*>(getGameObjectHavingTag(5));
88  if(enemy != NULL) {
89  enemy->launchEnemy(9.7f, 1.5f, false);
90  enemy->launchEnemy(11.2f, 0.85f, true);
91  enemy->launchEnemy(11.7f, 0.85f, true);
92  }
93 }
94 
95 //-----------------------------------------------------------------------------
96 
98  if (!m_player) {
99  deployPlayer();
100  }
101 
102  CDIRECTOR->setActiveCameraHavingId(m_player->getCameraId());
103 
105 }
106 
107 //-----------------------------------------------------------------------------
108 
111  m_player = NULL;
112 }
virtual void clear()
Definition: cgamescene.cpp:384
virtual void start()
Definition: cgamescene.cpp:148
std::string getCameraId() const
Definition: cplayer.cpp:141
CGameObject * getGameObjectHavingTag(int tag) const
Definition: cgamescene.cpp:558
virtual void start()
CGameObject * createGameObjectWithNode(const std::string &node_id, bool add_to_scene=true, const char *object_type=NULL)
Creates a GameObject based upon the specified Node id.
Definition: cgamescene.cpp:214
void setVisible(bool visible)
Definition: clnode.cpp:93
virtual void preUpdate()
virtual void clear()
virtual void preUpdate()
Definition: cgamescene.cpp:159
#define CDIRECTOR
Definition: cdirector.h:37
virtual void launchEnemy(float delay_time, float exposure_time, bool slide)