[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/astrododge/src
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2009-07-07 20:28:24
Message-ID: 1246998504.292170.12177.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 992861 by rivol:
Dodges are now limited and need some time to reload. The maximum number of avaliable \
dodges is 3, after using them they will regenerate in some time. Number of currently \
available dodges is also shown in the UI.
- Don't damp the ship's velocity so much, making the game faster.
M +5 -0 gameguiview.cpp
M +17 -2 ship.cpp
M +5 -0 ship.h
--- trunk/playground/games/astrododge/src/gameguiview.cpp #992860:992861
@@ -268,6 +268,11 @@
textRenderer()->draw(timerect, timestring,
Qt::AlignRight | Qt::AlignBottom, timefont);
+ // Dodges available
+ QRect dodgerect = glWidget()->rect().adjusted(10, 10, -10, -50);
+ textRenderer()->draw(dodgerect, QString("Dodges: \
%1").arg(mWorld->ship()->dodgesAvailable, 0, 'f', 1), + \
Qt::AlignRight | Qt::AlignBottom, timefont); +
textRenderer()->end();
}
--- trunk/playground/games/astrododge/src/ship.cpp #992860:992861
@@ -26,6 +26,9 @@
thrust = 1.0f;
rotvelocity = Vector3f(0, 0, 0);
+ dodgesAvailable = 3.0f;
+ timeToDodgeReload = 0.0f;
+
lastshoottime = -1000;
health = 100;
}
@@ -38,6 +41,11 @@
{
GameObject::advance(elapsed);
+ timeToDodgeReload -= elapsed;
+ if (timeToDodgeReload <= 0.0f) {
+ dodgesAvailable = qMin(3.0, dodgesAvailable + elapsed * (0.4 + \
dodgesAvailable * 0.25)); + }
+
addForce(direction() * acceleration * thrust);
const dReal* angvel = dBodyGetAngularVel(body);
@@ -45,7 +53,7 @@
dBodySetAngularVel(body, angvel[0] * damp, angvel[1] * damp, angvel[2] * damp);
const dReal* linvel = dBodyGetLinearVel(body);
- const float linDamp = 0.98f;
+ const float linDamp = 0.99f;
dBodySetLinearVel(body, linvel[0]*linDamp, linvel[1]*linDamp, \
linvel[2]*linDamp); }
@@ -67,7 +75,14 @@
void Ship::dodge(int x, int y)
{
- const int multiplier = 1000000;
+ if (dodgesAvailable < 1.0f) {
+ return;
+ }
+
+ const int multiplier = 800000;
dBodyAddRelForce(body, x*multiplier, y*multiplier, 0);
+
+ timeToDodgeReload = 2.0f;
+ dodgesAvailable -= 1.0f;
}
--- trunk/playground/games/astrododge/src/ship.h #992860:992861
@@ -41,6 +41,11 @@
float thrust;
Vector3f rotvelocity;
+ // How many dodges can the player do
+ float dodgesAvailable;
+ // How long before the dodges will start to reload again
+ float timeToDodgeReload;
+
float lastshoottime;
float health;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic