projects
/
libbear.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6247102
)
entityCreator setup to use bear::Queue
author
Patrik Gornicz
<Gornicz.P@gmail.com>
Tue, 4 Aug 2009 04:09:13 +0000
(
00:09
-0400)
committer
Patrik Gornicz
<Gornicz.P@gmail.com>
Tue, 4 Aug 2009 04:09:13 +0000
(
00:09
-0400)
src/entityCreator.cpp
patch
|
blob
|
blame
|
history
diff --git
a/src/entityCreator.cpp
b/src/entityCreator.cpp
index
5e0edaa
..
34b9a56
100644
(file)
--- a/
src/entityCreator.cpp
+++ b/
src/entityCreator.cpp
@@
-17,7
+17,7
@@
#include "entityCreator.h"
#include "entityCreator.h"
-#include <
queue
>
+#include <
bear/Queue.h
>
#include "entityManager.h"
#include "input/inputManager.h"
#include "entityManager.h"
#include "input/inputManager.h"
@@
-29,8
+29,10
@@
/// ***** Private Variables *****
/// ***** Private Variables *****
-typedef std::queue<Ball*> queBall;
-typedef std::queue<Polygon*> quePoly;
+//static bear::Queue<int> s_test;
+
+typedef bear::Queue<Ball*> queBall;
+typedef bear::Queue<Polygon*> quePoly;
static queBall s_startBalls;
static queBall s_mouseBalls;
static queBall s_startBalls;
static queBall s_mouseBalls;
@@
-61,6
+63,11
@@
void creator::init()
Ball* pBall;
float fStartMass = 5;
Ball* pBall;
float fStartMass = 5;
+ s_startBalls.init();
+ s_mouseBalls.init();
+
+ s_startPolys.init();
+
pBall = addBall(Vector2(50, 50), 20, cWhite, s_startBalls);
pBall->mass = fStartMass;
pBall = addBall(Vector2(50, 50), 20, cWhite, s_startBalls);
pBall->mass = fStartMass;
@@
-101,10
+108,14
@@
void creator::init()
}
void creator::clean()
{
}
void creator::clean()
{
- removeAllBalls(s_startBalls);
+ removeAllPolys(s_startPolys);
+ s_startPolys.fini();
+
removeAllBalls(s_mouseBalls);
removeAllBalls(s_mouseBalls);
+ s_mouseBalls.fini();
- removeAllPolys(s_startPolys);
+ removeAllBalls(s_startBalls);
+ s_startBalls.fini();
}
/// ***** Public Methods *****
}
/// ***** Public Methods *****
@@
-127,7
+138,7
@@
void creator::handleInput()
if(input::mouseLeft())
addBall(input::mousePosition(), 10, cCyan);
if(input::mouseLeft())
addBall(input::mousePosition(), 10, cCyan);
- if(input::mouseRight() && ! s_mouseBalls.
e
mpty())
+ if(input::mouseRight() && ! s_mouseBalls.
isE
mpty())
removeBall();
}
removeBall();
}
@@
-140,7
+151,7
@@
Ball* addBall(const Vector2& vecPos,
{
Ball* pBall = new Ball(vecPos, fRadius, color);
{
Ball* pBall = new Ball(vecPos, fRadius, color);
- que.push(pBall);
+ que.push
Back
(pBall);
manager::add(pBall);
return pBall;
manager::add(pBall);
return pBall;
@@
-151,7
+162,7
@@
Polygon* addPoly(const vector<Vector2>& vecPoints,
{
Polygon* pPoly = new Polygon(vecPoints, color);
{
Polygon* pPoly = new Polygon(vecPoints, color);
- que.push(pPoly);
+ que.push
Back
(pPoly);
manager::add(pPoly);
return pPoly;
manager::add(pPoly);
return pPoly;
@@
-159,16
+170,16
@@
Polygon* addPoly(const vector<Vector2>& vecPoints,
void removeBall(queBall& que)
{
void removeBall(queBall& que)
{
- Ball* pBall = que.
f
ront();
+ Ball* pBall = que.
getF
ront();
manager::remove(pBall);
manager::remove(pBall);
- que.pop();
+ que.pop
Front
();
delete pBall;
}
void removeAllBalls(queBall& que)
{
delete pBall;
}
void removeAllBalls(queBall& que)
{
- while(! que.
e
mpty() )
+ while(! que.
isE
mpty() )
{
removeBall(que);
}
{
removeBall(que);
}
@@
-176,16
+187,16
@@
void removeAllBalls(queBall& que)
static void removePoly(quePoly& que)
{
static void removePoly(quePoly& que)
{
- Polygon* pPoly = que.
f
ront();
+ Polygon* pPoly = que.
getF
ront();
manager::remove(pPoly);
manager::remove(pPoly);
- que.pop();
+ que.pop
Front
();
delete pPoly;
}
static void removeAllPolys(quePoly& que)
{
delete pPoly;
}
static void removeAllPolys(quePoly& que)
{
- while(! que.
e
mpty() )
+ while(! que.
isE
mpty() )
{
removePoly(que);
}
{
removePoly(que);
}