opentnl-cvs Mailing List for Torque Network Library (Page 23)
Brought to you by:
mark_frohnmayer,
s_alanet
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(141) |
May
(232) |
Jun
(103) |
Jul
(36) |
Aug
(35) |
Sep
(19) |
Oct
(20) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(26) |
Mar
(2) |
Apr
(84) |
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Mark F. <mar...@us...> - 2004-05-03 22:55:59
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26044/exe Modified Files: README.txt Log Message: Added newlines to end of files Updated README Index: README.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/README.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README.txt 30 Apr 2004 20:27:40 -0000 1.1 --- README.txt 3 May 2004 22:55:50 -0000 1.2 *************** *** 1,6 **** ! ZAP 1.1.2 Welcome to ZAP, the retro multiplayer team action game! Controls: --- 1,13 ---- ! ZAP 1.2 Welcome to ZAP, the retro multiplayer team action game! + Changes since the last version: + - Added shields, boost and ship energy + - Added Soccer game type + - Added level cycling and victory conditions + - Removed player particle trails and added motion trails + - Added README + Controls: *************** *** 12,17 **** --- 19,27 ---- T - chat to team G - chat global + V - open quick chat menu C - toggle commander map + F - toggle shields + SPACE - boost TAB - show scores *************** *** 21,25 **** Aim and fire with mouse button 1 ! In the game you can press ESC to go to the game options screen. From there you can access the main options which include setting full screen mode, enabling relative controls and on the Windows platform enabling dual analog controller support. Command Line Options: --- 31,48 ---- Aim and fire with mouse button 1 ! Dual-Analog Controller: ! ! Left stick - move ! Right stick - aim and fire ! ! left trigger - shield ! right trigger - boost ! button 3 - toggle commander map ! button 4 - show scores ! ! In the game you can press ESC to go to the game options screen. ! From there you can access the main options which include setting ! full screen mode, enabling relative controls and on the Windows ! platform enabling dual analog controller support. Command Line Options: *************** *** 30,44 **** or IP:www.foobar.com:24601 ! -server [bindAddress] hosts a game server/client on the specified bind address. ! -connect [connectAddress] starts as a game client and attempts to connect to the server at the specified address. ! -master [masterAddress] specfies the address of the master server to connect to. -dedicated [bindAddress] starts Zap as a dedicated server ! -name [playerName] sets the client's name to the specified name and skips the name entry screen. -level [levelName] sets the specified level to load when hosting ! -hostname [hostname] sets the name that will appear in the server browser when searching for servers. ! -maxplayers [number] sets the maximum number of players allowed on the server Credits: ZAP is free software provided by GarageGames.com, Inc. ! Team members are: Mark Frohnmayer, Ben Garney, John Quigley \ No newline at end of file --- 53,78 ---- or IP:www.foobar.com:24601 ! -server [bindAddress] hosts a game server/client on the specified ! bind address. ! -connect [connectAddress] starts as a game client and attempts ! to connect to the server at the specified address. ! -master [masterAddress] specfies the address of the master server ! to connect to. -dedicated [bindAddress] starts Zap as a dedicated server ! -name [playerName] sets the client's name to the specified name ! and skips the name entry screen. -level [levelName] sets the specified level to load when hosting ! -hostname [hostname] sets the name that will appear in the server ! browser when searching for servers. ! -maxplayers [number] sets the maximum number of players allowed ! on the server Credits: ZAP is free software provided by GarageGames.com, Inc. ! Team members are: ! ! Mark Frohnmayer ! Ben Garney ! John Quigley ! Robert Blanchett \ No newline at end of file |
From: Mark F. <mar...@us...> - 2004-05-03 22:06:25
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14626/zap Modified Files: CTFGame.cpp game.cpp game.h gameConnection.cpp gameConnection.h gameObject.h gameType.cpp gameType.h main.cpp ship.cpp ship.h soccerGame.cpp soccerGame.h Log Message: Added sorting to Vector template class Updated Zap level2 to include a 30 second time limit Updated GameType base class to perform as a simple deathmatch game type Added correct player counts to server in server browser Fixed commander map scoping to scope fewer objects seen by remote players Soccer ball now slows down when it reaches the goal Scoping now handled in the game type instead of Ship Teams are randomized after each map Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** main.cpp 3 May 2004 02:41:01 -0000 1.15 --- main.cpp 3 May 2004 22:06:16 -0000 1.16 *************** *** 51,54 **** --- 51,55 ---- const char *gWindowTitle = "ZAP II - The Return"; U32 gMaxPlayers = 128; + const char *gMasterAddressString = "IP:master.opentnl.org:29005"; Address gMasterAddress; Index: gameType.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** gameType.cpp 2 May 2004 06:27:41 -0000 1.16 --- gameType.cpp 3 May 2004 22:06:16 -0000 1.17 *************** *** 29,32 **** --- 29,33 ---- #include "UIGame.h" #include "gameNetInterface.h" + #include "glutInclude.h" namespace Zap *************** *** 90,93 **** --- 91,179 ---- } + void GameType::renderInterfaceOverlay(bool scoreboardVisible) + { + if((mGameOver || scoreboardVisible) && mTeams.size() > 0) + { + U32 totalWidth = 780; + U32 teamWidth = totalWidth / mTeams.size(); + U32 maxTeamPlayers = 0; + countTeamPlayers(); + + for(S32 i = 0; i < mTeams.size(); i++) + if(mTeams[i].numPlayers > maxTeamPlayers) + maxTeamPlayers = mTeams[i].numPlayers; + + U32 teamAreaHeight = 40; + if(mTeams.size() < 2) + teamAreaHeight = 0; + + U32 totalHeight = 580; + U32 maxHeight = (totalHeight - teamAreaHeight) / maxTeamPlayers; + if(maxHeight > 30) + maxHeight = 30; + + totalHeight = teamAreaHeight + maxHeight * maxTeamPlayers; + U32 yt = (600 - totalHeight) / 2; + U32 yb = yt + totalHeight; + + for(S32 i = 0; i < mTeams.size(); i++) + { + U32 xl = 10 + i * teamWidth; + U32 xr = xl + teamWidth - 2; + + Color c = mTeams[i].color; + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glColor4f(c.r, c.g, c.b, 0.6); + glBegin(GL_POLYGON); + glVertex2f(xl, yt); + glVertex2f(xr, yt); + glVertex2f(xr, yb); + glVertex2f(xl, yb); + glEnd(); + + glDisable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ZERO); + + glColor3f(1,1,1); + if(teamAreaHeight) + { + glBegin(GL_LINES); + glVertex2f(xl, yt + teamAreaHeight); + glVertex2f(xr, yt + teamAreaHeight); + glEnd(); + + UserInterface::drawString(xl + 40, yt + 2, 30, mTeams[i].name.getString()); + + UserInterface::drawStringf(xr - 140, yt + 2, 30, "%d", mTeams[i].score); + } + + U32 curRowY = yt + teamAreaHeight + 1; + U32 fontSize = maxHeight * 0.8f; + for(S32 j = 0; j < mClientList.size(); j++) + { + if(mClientList[j].teamId == i) + { + UserInterface::drawString(xl + 40, curRowY, fontSize, mClientList[j].name.getString()); + + static char buff[255] = ""; + dSprintf(buff, sizeof(buff), "%d", mClientList[j].score); + + UserInterface::drawString(xr - (120 + UserInterface::getStringWidth(fontSize, buff)), curRowY, fontSize, buff); + UserInterface::drawStringf(xr - 70, curRowY, fontSize, "%d", mClientList[j].ping); + curRowY += maxHeight; + } + } + } + } + glColor3f(1,1,1); + U32 timeLeft = mGameTimer.getCurrent(); + + U32 minsRemaining = timeLeft / (60000); + U32 secsRemaining = (timeLeft - (minsRemaining * 60000)) / 1000; + UserInterface::drawStringf(720, 577, 20, "%02d:%02d", minsRemaining, secsRemaining); + } + void GameType::gameOverManGameOver() { *************** *** 171,174 **** --- 257,298 ---- } + void GameType::performProxyScopeQuery(GameObject *scopeObject, GameConnection *connection) + { + static Vector<GameObject *> fillVector; + fillVector.clear(); + + if(connection->mInCommanderMap && mTeams.size() > 1) + { + S32 teamId = mClientList[findClientIndexByConnection(connection)].teamId; + + for(S32 i = 0; i < mClientList.size(); i++) + { + if(mClientList[i].teamId == teamId) + { + GameObject *co = mClientList[i].clientConnection->getControlObject(); + if(!co) + continue; + + Point pos = co->getActualPos(); + + Rect queryRect(pos, pos); + queryRect.expand(Point(Game::PlayerHorizScopeDistance, Game::PlayerVertScopeDistance)); + findObjects(scopeObject == co ? AllObjectTypes : CommandMapVisType, fillVector, queryRect); + } + } + } + else + { + Point pos = scopeObject->getActualPos(); + + Rect queryRect(pos, pos); + queryRect.expand(Point(Game::PlayerHorizScopeDistance, Game::PlayerVertScopeDistance)); + findObjects(AllObjectTypes, fillVector, queryRect); + } + + for(S32 i = 0; i < fillVector.size(); i++) + connection->objectInScope(fillVector[i]); + } + void GameType::countTeamPlayers() { *************** *** 211,217 **** void GameType::controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject) { S32 clientIndex = findClientIndexByConnection(theClient); ! if(clientIndex != -1) ! mClientList[clientIndex].respawnTimer.reset(RespawnDelay); } --- 335,353 ---- void GameType::controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject) { + GameConnection *killer = killerObject ? killerObject->getControllingClient() : NULL; + S32 killerIndex = findClientIndexByConnection(killer); S32 clientIndex = findClientIndexByConnection(theClient); ! ! if(killerIndex != -1) ! { ! // Punish team killers slightly ! if(mTeams.size() > 1 && mClientList[killerIndex].teamId == mClientList[clientIndex].teamId) ! mClientList[killerIndex].score -= 1; ! else ! mClientList[killerIndex].score += 1; ! ! s2cKillMessage(mClientList[clientIndex].name, mClientList[killerIndex].name); ! } ! mClientList[clientIndex].respawnTimer.reset(RespawnDelay); } Index: soccerGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/soccerGame.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** soccerGame.cpp 2 May 2004 06:27:41 -0000 1.2 --- soccerGame.cpp 3 May 2004 22:06:16 -0000 1.3 *************** *** 125,128 **** --- 125,129 ---- } } + glColor3f(1,1,1); U32 timeLeft = mGameTimer.getCurrent(); *************** *** 283,289 **** void SoccerBallItem::processServer(U32 deltaT) { - Parent::processServer(deltaT); if(sendHomeTime) { if(sendHomeTime > deltaT) sendHomeTime -= deltaT; --- 284,294 ---- void SoccerBallItem::processServer(U32 deltaT) { if(sendHomeTime) { + F32 accelFraction = 1 - (0.98 * deltaT / 1000.0f); + + mMoveState[ActualState].vel *= accelFraction; + mMoveState[RenderState].vel *= accelFraction; + if(sendHomeTime > deltaT) sendHomeTime -= deltaT; *************** *** 294,297 **** --- 299,303 ---- } } + Parent::processServer(deltaT); } Index: gameConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** gameConnection.cpp 26 Apr 2004 23:35:00 -0000 1.9 --- gameConnection.cpp 3 May 2004 22:06:16 -0000 1.10 *************** *** 207,210 **** --- 207,217 ---- if(!Parent::readConnectRequest(stream, errorString)) return false; + + if(gServerGame->isFull()) + { + *errorString = "Server Full."; + return false; + } + char buf[256]; *************** *** 266,269 **** --- 273,281 ---- } + void GameConnection::onConnectionRejected(const char *reason) + { + gMainMenuUserInterface.activate(); + } + void GameConnection::onDisconnect(const char *reason) { Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** game.h 2 May 2004 06:27:41 -0000 1.11 --- game.h 3 May 2004 22:06:16 -0000 1.12 *************** *** 159,162 **** --- 159,163 ---- U32 getMaxPlayers() { return mMaxPlayers; } const char *getHostName() { return mHostName; } + bool isFull() { return mPlayerCount == mMaxPlayers; } void addClient(GameConnection *theConnection); Index: gameConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gameConnection.h 30 Apr 2004 20:27:41 -0000 1.6 --- gameConnection.h 3 May 2004 22:06:16 -0000 1.7 *************** *** 217,220 **** --- 217,221 ---- void onConnectionEstablished(bool isInitiator); + void onConnectionRejected(const char *reason); void onDisconnect(const char *reason); void onTimedOut(); Index: gameObject.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameObject.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gameObject.h 30 Apr 2004 20:27:41 -0000 1.4 --- gameObject.h 3 May 2004 22:06:16 -0000 1.5 *************** *** 98,101 **** --- 98,102 ---- F32 getUpdatePriority(NetObject *scopeObject, U32 updateMask, S32 updateSkips); + virtual S32 getRenderSortValue() { return 0; } virtual void render(); Index: ship.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ship.h 30 Apr 2004 21:58:10 -0000 1.12 --- ship.h 3 May 2004 22:06:16 -0000 1.13 *************** *** 38,45 **** class Ship : public MoveObject { - private: - // This is called when we're doing team queries... - void performInnerScopeQuery(GhostConnection *connection); - public: enum { --- 38,41 ---- Index: CTFGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** CTFGame.cpp 2 May 2004 06:27:41 -0000 1.19 --- CTFGame.cpp 3 May 2004 22:06:16 -0000 1.20 *************** *** 128,132 **** static char buff[255] = ""; ! sprintf(buff, "%d", mClientList[j].score); UserInterface::drawString(xr - (120 + UserInterface::getStringWidth(fontSize, buff)), curRowY, fontSize, buff); --- 128,132 ---- static char buff[255] = ""; ! dSprintf(buff, sizeof(buff), "%d", mClientList[j].score); UserInterface::drawString(xr - (120 + UserInterface::getStringWidth(fontSize, buff)), curRowY, fontSize, buff); *************** *** 147,150 **** --- 147,151 ---- } } + glColor3f(1,1,1); U32 timeLeft = mGameTimer.getCurrent(); Index: gameType.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** gameType.h 2 May 2004 06:27:41 -0000 1.7 --- gameType.h 3 May 2004 22:06:16 -0000 1.8 *************** *** 46,50 **** StringTableEntry name; /// Name of client - guaranteed to be unique of current clients S32 teamId; ! U32 score; Timer respawnTimer; --- 46,50 ---- StringTableEntry name; /// Name of client - guaranteed to be unique of current clients S32 teamId; ! S32 score; Timer respawnTimer; *************** *** 119,125 **** virtual void processClientGameMenuOption(U32 index); ! virtual void renderInterfaceOverlay(bool scoreboardVisible) {}; virtual void updateClientScoreboard(S32 clientIndex); TNL_DECLARE_RPC(s2cAddTeam, (StringTableEntry teamName, F32 r, F32 g, F32 b)); TNL_DECLARE_RPC(s2cSetTeamScore, (U32 teamIndex, U32 score)); --- 119,127 ---- virtual void processClientGameMenuOption(U32 index); ! virtual void renderInterfaceOverlay(bool scoreboardVisible); virtual void updateClientScoreboard(S32 clientIndex); + virtual void performProxyScopeQuery(GameObject *scopeObject, GameConnection *connection); + TNL_DECLARE_RPC(s2cAddTeam, (StringTableEntry teamName, F32 r, F32 g, F32 b)); TNL_DECLARE_RPC(s2cSetTeamScore, (U32 teamIndex, U32 score)); Index: game.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** game.cpp 2 May 2004 06:27:41 -0000 1.16 --- game.cpp 3 May 2004 22:06:16 -0000 1.17 *************** *** 197,200 **** --- 197,203 ---- void ServerGame::cycleLevel() { + // delete any objects on the delete list: + processDeleteList(0xFFFFFFFF); + // delete any objects that may exist while(mGameObjects.size()) *************** *** 213,220 **** g->addToGame(this); } for(GameConnection *walk = GameConnection::gClientList.mNext; walk != &GameConnection::gClientList; walk = walk->mNext) { ! addClient(walk); ! walk->activateGhosting(); } } --- 216,234 ---- g->addToGame(this); } + Vector<GameConnection *> connectionList; + for(GameConnection *walk = GameConnection::gClientList.mNext; walk != &GameConnection::gClientList; walk = walk->mNext) + connectionList.push_back(walk); + + // now add the connections to the game type, in a random order + while(connectionList.size()) { ! U32 index = Random::readI() % connectionList.size(); ! GameConnection *gc = connectionList[index]; ! connectionList.erase(index); ! ! if(mGameType.isValid()) ! mGameType->serverAddClient(gc); ! gc->activateGhosting(); } } *************** *** 255,258 **** --- 269,273 ---- if(mGameType.isValid()) mGameType->serverAddClient(theConnection); + mPlayerCount++; } *************** *** 261,264 **** --- 276,280 ---- if(mGameType.isValid()) mGameType->serverRemoveClient(theConnection); + mPlayerCount--; } *************** *** 431,435 **** } ! void ClientGame::renderCommander() --- 447,454 ---- } ! S32 QSORT_CALLBACK renderSortCompare(GameObject **a, GameObject **b) ! { ! return (*a)->getRenderSortValue() - (*b)->getRenderSortValue(); ! } void ClientGame::renderCommander() *************** *** 515,524 **** } for(S32 i = 0; i < renderObjects.size(); i++) - { renderObjects[i]->render(); - } - - //SparkManager::render(); glPopMatrix(); --- 534,541 ---- } + renderObjects.sort(renderSortCompare); + for(S32 i = 0; i < renderObjects.size(); i++) renderObjects[i]->render(); glPopMatrix(); *************** *** 546,549 **** --- 563,568 ---- mDatabase.findObjects(AllObjectTypes, renderObjects, extentRect); + renderObjects.sort(renderSortCompare); + for(S32 i = 0; i < renderObjects.size(); i++) renderObjects[i]->render(); Index: soccerGame.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/soccerGame.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** soccerGame.h 2 May 2004 06:27:41 -0000 1.2 --- soccerGame.h 3 May 2004 22:06:16 -0000 1.3 *************** *** 95,98 **** --- 95,99 ---- U32 getTeamIndex() { return teamIndex; } void render(); + S32 getRenderSortValue() { return -1; } void processArguments(S32 argc, const char **argv); void onAddedToGame(Game *theGame); Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ship.cpp 3 May 2004 02:41:01 -0000 1.22 --- ship.cpp 3 May 2004 22:06:16 -0000 1.23 *************** *** 526,568 **** static Vector<GameObject *> fillVector; - void Ship::performInnerScopeQuery(GhostConnection *connection) - { - Rect queryRect(mMoveState[ActualState].pos, mMoveState[ActualState].pos); - queryRect.expand(Point(Game::PlayerHorizScopeDistance, Game::PlayerVertScopeDistance)); - - - fillVector.clear(); - findObjects(AllObjectTypes, fillVector, queryRect); - - for(S32 i = 0; i < fillVector.size(); i++) - connection->objectInScope(fillVector[i]); - } - void Ship::performScopeQuery(GhostConnection *connection) { ! GameConnection *g = dynamic_cast<GameConnection*>(connection); ! ! if(g && g->mInCommanderMap) ! { ! GameType *gt = gServerGame->getGameType(); ! ! S32 teamId = gt->mClientList[gt->findClientIndexByConnection(g)].teamId; ! ! // Scope for all ships on our team. ! for(S32 i=0; i<gt->mClientList.size(); i++) ! { ! if(gt->mClientList[i].teamId == teamId) ! { ! Ship *co = dynamic_cast<Ship*>(gt->mClientList[i].clientConnection->getControlObject()); ! if(co) ! co->performInnerScopeQuery(connection); ! } ! } ! } ! else ! { ! // Just scope for the current ship... ! performInnerScopeQuery(connection); ! } } --- 526,533 ---- static Vector<GameObject *> fillVector; void Ship::performScopeQuery(GhostConnection *connection) { ! GameType *gt = gServerGame->getGameType(); ! gt->performProxyScopeQuery(this, (GameConnection *) connection); } |
From: Mark F. <mar...@us...> - 2004-05-03 22:06:25
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14626/tnl Modified Files: tnlVector.h Log Message: Added sorting to Vector template class Updated Zap level2 to include a 30 second time limit Updated GameType base class to perform as a simple deathmatch game type Added correct player counts to server in server browser Fixed commander map scoping to scope fewer objects seen by remote players Soccer ball now slows down when it reaches the goal Scoping now handled in the game type instead of Ship Teams are randomized after each map Index: tnlVector.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlVector.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tnlVector.h 20 Apr 2004 04:27:19 -0000 1.1 --- tnlVector.h 3 May 2004 22:06:16 -0000 1.2 *************** *** 122,125 **** --- 122,127 ---- typedef U32 size_type; + typedef difference_type (QSORT_CALLBACK *compare_func)(T *a, T *b); + Vector<T>& operator=(const Vector<T>& p); *************** *** 175,178 **** --- 177,181 ---- void compact(); + void sort(compare_func f); T& first(); T& last(); *************** *** 566,569 **** --- 569,579 ---- } + typedef int (QSORT_CALLBACK *qsort_compare_func)(const void *, const void *); + + template<class T> inline void Vector<T>::sort(compare_func f) + { + qsort(address(), size(), sizeof(T), (qsort_compare_func) f); + } + }; |
From: Mark F. <mar...@us...> - 2004-05-03 22:06:24
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14626/exe Modified Files: level2.txt Log Message: Added sorting to Vector template class Updated Zap level2 to include a 30 second time limit Updated GameType base class to perform as a simple deathmatch game type Added correct player counts to server in server browser Fixed commander map scoping to scope fewer objects seen by remote players Soccer ball now slows down when it reaches the goal Scoping now handled in the game type instead of Ship Teams are randomized after each map Index: level2.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level2.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** level2.txt 20 Apr 2004 04:27:12 -0000 1.1 --- level2.txt 3 May 2004 22:06:15 -0000 1.2 *************** *** 3,7 **** GridSize 128 ! GameType 8 2 8 14 Team Blue 0 0 1 --- 3,7 ---- GridSize 128 ! GameType 0.5 Team Blue 0 0 1 |
From: Mark F. <mar...@us...> - 2004-05-03 02:41:09
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3512/zap Modified Files: UIGame.cpp main.cpp ship.cpp winJoystick.cpp Log Message: Shield is now a circle Added better mouse support on Win32 Changed team colors to Red and Blue in soccer Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** main.cpp 2 May 2004 06:27:41 -0000 1.14 --- main.cpp 3 May 2004 02:41:01 -0000 1.15 *************** *** 49,52 **** --- 49,53 ---- bool gIsServer = false; const char *gHostName = "ZAP Game"; + const char *gWindowTitle = "ZAP II - The Return"; U32 gMaxPlayers = 128; const char *gMasterAddressString = "IP:master.opentnl.org:29005"; *************** *** 353,357 **** glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); ! glutCreateWindow("ZAP II - The Return"); glutDisplayFunc(display); glutReshapeFunc(reshape); --- 354,358 ---- glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB); ! glutCreateWindow(gWindowTitle); glutDisplayFunc(display); glutReshapeFunc(reshape); Index: UIGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIGame.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** UIGame.cpp 2 May 2004 06:27:41 -0000 1.14 --- UIGame.cpp 3 May 2004 02:41:01 -0000 1.15 *************** *** 99,102 **** --- 99,106 ---- } + #ifdef TNL_OS_WIN32 + extern void checkMousePos(S32 maxdx, S32 maxdy); + #endif + void GameUserInterface::render() { *************** *** 125,132 **** if(!OptionsMenuUserInterface::joystickEnabled) { glPushMatrix(); glTranslatef(400, 300, 0); ! glTranslatef(mMousePoint.x, mMousePoint.y, 0); static U32 cursorSpin = 90; --- 129,148 ---- if(!OptionsMenuUserInterface::joystickEnabled) { + Point realMousePoint = mMousePoint; + + #ifdef TNL_OS_WIN32 + + F32 len = mMousePoint.len(); + checkMousePos(windowWidth * 100 / canvasWidth, + windowHeight * 100 / canvasHeight); + + if(len > 100) + realMousePoint *= 100 / len; + #endif + glPushMatrix(); glTranslatef(400, 300, 0); ! glTranslatef(realMousePoint.x, realMousePoint.y, 0); static U32 cursorSpin = 90; *************** *** 234,237 **** --- 250,259 ---- void GameUserInterface::onMouseMoved(S32 x, S32 y) { + S32 xp = x - windowWidth / 2; + S32 yp = y - windowHeight / 2; + S32 horzMax = 100 * windowWidth / canvasWidth; + S32 vertMax = 100 * windowHeight / canvasHeight; + + mMousePoint = Point(x - windowWidth / 2, y - windowHeight / 2); mMousePoint.x *= canvasWidth / windowWidth; Index: winJoystick.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/winJoystick.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** winJoystick.cpp 27 Apr 2004 22:36:48 -0000 1.5 --- winJoystick.cpp 3 May 2004 02:41:01 -0000 1.6 *************** *** 37,40 **** --- 37,76 ---- { + extern const char *gWindowTitle; + + void checkMousePos(S32 maxdx, S32 maxdy) + { + char windowName[256]; + + HWND theWindow = GetForegroundWindow(); + GetWindowText(theWindow, windowName, sizeof(windowName)); + + if(strcmp(windowName, gWindowTitle)) + return; + + RECT r; + + GetWindowRect(theWindow, &r); + POINT cp; + GetCursorPos(&cp); + + S32 centerX = (r.right + r.left) >> 1; + S32 centerY = (r.bottom + r.top) >> 1; + + cp.x -= centerX; + cp.y -= centerY; + + if(cp.x > maxdx) + cp.x = maxdx; + if(cp.y > maxdy) + cp.y = maxdy; + if(cp.x < -maxdx) + cp.x = -maxdx; + if(cp.y < -maxdy) + cp.y = -maxdy; + + SetCursorPos(int(centerX + cp.x), int(centerY + cp.y)); + } + BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, VOID* pContext ); Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ship.cpp 1 May 2004 19:47:26 -0000 1.21 --- ship.cpp 3 May 2004 02:41:01 -0000 1.22 *************** *** 942,950 **** if(mShield) { glColor4f(1,1,0, alpha); glBegin(GL_LINE_LOOP); ! glVertex2f(-23, -18); ! glVertex2f(0, 27); ! glVertex2f(23, -18); glEnd(); } --- 942,952 ---- if(mShield) { + F32 shieldRadius = mRadius + 3; + glColor4f(1,1,0, alpha); glBegin(GL_LINE_LOOP); ! for(F32 theta = 0; theta <= 2 * 3.1415; theta += 0.3) ! glVertex2f(cos(theta) * shieldRadius, sin(theta) * shieldRadius); ! glEnd(); } |
From: Mark F. <mar...@us...> - 2004-05-03 02:41:09
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3512/exe Modified Files: level3.txt Log Message: Shield is now a circle Added better mouse support on Win32 Changed team colors to Red and Blue in soccer Index: level3.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level3.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** level3.txt 2 May 2004 21:05:14 -0000 1.4 --- level3.txt 3 May 2004 02:41:00 -0000 1.5 *************** *** 3,8 **** GridSize 280 ! Team Yellow 1 1 0 ! Team Green 0 1 0 BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 --- 3,8 ---- GridSize 280 ! Team Blue 0 0 1 ! Team Red 1 0 0 BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 |
From: Mark F. <mar...@us...> - 2004-05-02 21:05:23
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8946/exe Modified Files: level3.txt Log Message: Finished the first soccer level Index: level3.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level3.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** level3.txt 2 May 2004 06:27:40 -0000 1.3 --- level3.txt 2 May 2004 21:05:14 -0000 1.4 *************** *** 1,4 **** --- 1,5 ---- SoccerGameType 20 8 + GridSize 280 Team Yellow 1 1 0 *************** *** 6,17 **** BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 BarrierMaker 6 6 7 7 5 7 6 6 ! BarrierMaker 6 10 7 9 5 9 6 10 BarrierMaker 5 3 5 3.5 4 3.5 5 3 ! BarrierMaker 5 4 5 5 5.5 5 ! BarrierMaker 7 3 7 5 ! Spawn 0 0.5 1.5 ! Spawn 1 7.5 7.5 SoccerBallItem 6 8 --- 7,62 ---- BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 + BarrierMaker 6 6 7 7 5 7 6 6 ! BarrierMaker 5 3 5 3.5 4 3.5 5 3 ! BarrierMaker 4 4 5 4 5 5 5.5 5 ! BarrierMaker 8 3 7 3 7 5 ! BarrierMaker 4 3.5 5 3.5 5 3 4 3.5 ! BarrierMaker 4 2.5 4.5 2.5 4.5 2 5 2 ! BarrierMaker 6 5 5.5 3 6.5 3 6 5 ! BarrierMaker 3.5 4.5 3.5 6 4 6 ! BarrierMaker 4.5 6 4.5 4.5 4 4.5 ! BarrierMaker 3.5 2 4 2 ! BarrierMaker 1.5 2 3 2 3 3.5 1.5 2 ! BarrierMaker 1 2 2.5 4 1 3 1 2 ! BarrierMaker 7 2 7.5 2 7 2.5 7 2 ! BarrierMaker 7.5 4 8 4 8 5 7.5 5 7.5 4 ! BarrierMaker 8 6 11 4 11 2 8 6 ! BarrierMaker 8 2.5 9 2.5 9 3 8.5 3.5 ! BarrierMaker 6 10 7 9 5 9 6 10 ! ! BarrierMaker 5 13 5 12.5 4 12.5 5 13 ! BarrierMaker 4 12 5 12 5 11 5.5 11 ! BarrierMaker 8 13 7 13 7 11 ! BarrierMaker 4 12.5 5 12.5 5 13 4 12.5 ! BarrierMaker 4 13.5 4.5 13.5 4.5 14 5 14 ! BarrierMaker 6 11 5.5 13 6.5 13 6 11 ! BarrierMaker 3.5 11.5 3.5 10 4 10 ! BarrierMaker 4.5 10 4.5 11.5 4 11.5 ! BarrierMaker 3.5 14 4 14 ! BarrierMaker 1.5 14 3 14 3 12.5 1.5 14 ! BarrierMaker 1 14 2.5 12 1 13 1 14 ! BarrierMaker 7 14 7.5 14 7 13.5 7 14 ! BarrierMaker 7.5 12 8 12 8 11 7.5 11 7.5 12 ! BarrierMaker 8 10 11 12 11 14 8 10 ! BarrierMaker 8 13.5 9 13.5 9 13 8.5 12.5 ! ! Spawn 0 4 9 ! Spawn 0 4 8.5 ! Spawn 0 5 8.5 ! Spawn 0 6 8.5 ! Spawn 0 7 8.5 ! Spawn 0 8 8.5 ! Spawn 0 8 9 ! ! Spawn 1 4 7 ! Spawn 1 4 7.5 ! Spawn 1 5 7.5 ! Spawn 1 6 7.5 ! Spawn 1 7 7.5 ! Spawn 1 8 7.5 ! Spawn 1 8 7 SoccerBallItem 6 8 |
From: Mark F. <mar...@us...> - 2004-05-02 06:27:52
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27167/zap Modified Files: CTFGame.cpp CTFGame.h UIGame.cpp ZAP.vcproj game.cpp game.h gameType.cpp gameType.h main.cpp soccerGame.cpp soccerGame.h Added Files: timer.h Log Message: Fixed ghosting bug Made games cycle after time or score limit are reached --- NEW FILE: timer.h --- //----------------------------------------------------------------------------------- // // Torque Network Library - ZAP example multiplayer vector graphics space game // Copyright (C) 2004 GarageGames.com, Inc. // For more information see http://www.opentnl.org // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // For use in products that are not compatible with the terms of the GNU // General Public License, alternative licensing options are available // from GarageGames.com. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //------------------------------------------------------------------------------------ #ifndef _TIMER_H_ #define _TIMER_H_ namespace Zap { class Timer { U32 mPeriod; U32 mCurrentCounter; public: Timer(U32 period = 0) { mCurrentCounter = mPeriod = period; } bool update(U32 timeDelta) { if(!mCurrentCounter) return false; if(timeDelta >= mCurrentCounter) { mCurrentCounter = 0; return true; } mCurrentCounter -= timeDelta; return false; } U32 getCurrent() { return mCurrentCounter; } void reset() { mCurrentCounter = mPeriod; } void reset(U32 newPeriod) { mCurrentCounter = mPeriod = newPeriod; } }; }; #endif Index: gameType.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** gameType.cpp 30 Apr 2004 20:27:41 -0000 1.15 --- gameType.cpp 2 May 2004 06:27:41 -0000 1.16 *************** *** 36,53 **** GameType::GameType() { mNetFlags.set(Ghostable); ! mTimeUntilScoreboardUpdate = 0; } void GameType::processArguments(S32 argc, const char **argv) { } void GameType::processServer(U32 deltaT) { ! if(deltaT > mTimeUntilScoreboardUpdate) { for(S32 i = 0; i < mClientList.size(); i++) if(mClientList[i].clientConnection) --- 36,66 ---- GameType::GameType() + : mScoreboardUpdateTimer(1000) + , mGameTimer(DefaultGameTime) + , mGameTimeUpdateTimer(30000) { mNetFlags.set(Ghostable); ! mGameOver = false; ! mTeamScoreLimit = DefaultTeamScoreLimit; } void GameType::processArguments(S32 argc, const char **argv) { + if(argc > 0) + mGameTimer.reset(U32(atof(argv[0]) * 60 * 1000)); + if(argc > 1) + mTeamScoreLimit = atoi(argv[1]); + } + void GameType::processClient(U32 deltaT) + { + mGameTimer.update(deltaT); } void GameType::processServer(U32 deltaT) { ! if(mScoreboardUpdateTimer.update(deltaT)) { + mScoreboardUpdateTimer.reset(); for(S32 i = 0; i < mClientList.size(); i++) if(mClientList[i].clientConnection) *************** *** 55,78 **** for(S32 i = 0; i < mClientList.size(); i++) ! if(mClientList[i].wantsScoreboardUpdates) updateClientScoreboard(i); ! mTimeUntilScoreboardUpdate = 1000; } - else - mTimeUntilScoreboardUpdate -= deltaT; for(S32 i = 0; i < mClientList.size(); i++) { ! if(mClientList[i].respawnDelay) ! { ! if(mClientList[i].respawnDelay <= deltaT) ! spawnShip(mClientList[i].clientConnection); ! else ! mClientList[i].respawnDelay -= deltaT; ! } } } void GameType::onAddedToGame(Game *theGame) { --- 68,107 ---- for(S32 i = 0; i < mClientList.size(); i++) ! if(mGameOver || mClientList[i].wantsScoreboardUpdates) updateClientScoreboard(i); + } ! if(mGameTimeUpdateTimer.update(deltaT)) ! { ! mGameTimeUpdateTimer.reset(); ! s2cSetTimeRemaining(mGameTimer.getCurrent()); } for(S32 i = 0; i < mClientList.size(); i++) { ! if(mClientList[i].respawnTimer.update(deltaT)) ! spawnShip(mClientList[i].clientConnection); ! } ! ! if(mGameTimer.update(deltaT)) ! { ! gameOverManGameOver(); } } + void GameType::gameOverManGameOver() + { + // 17 days??? We won't last 17 hours! + mGameOver = true; + s2cSetGameOver(true); + gServerGame->gameEnded(); + } + + TNL_IMPLEMENT_NETOBJECT_RPC(GameType, s2cSetGameOver, (bool gameOver), + NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) + { + mGameOver = gameOver; + } + void GameType::onAddedToGame(Game *theGame) { *************** *** 133,137 **** S32 teamIndex = mClientList[clientIndex].teamId; - mClientList[clientIndex].respawnDelay = 0; Point spawnPoint; S32 spawnIndex = Random::readI() % mTeams[teamIndex].spawnPoints.size(); --- 162,165 ---- *************** *** 185,189 **** S32 clientIndex = findClientIndexByConnection(theClient); if(clientIndex != -1) ! mClientList[clientIndex].respawnDelay = RespawnDelay; } --- 213,217 ---- S32 clientIndex = findClientIndexByConnection(theClient); if(clientIndex != -1) ! mClientList[clientIndex].respawnTimer.reset(RespawnDelay); } *************** *** 205,208 **** --- 233,250 ---- } + void GameType::setTeamScore(S32 teamIndex, S32 newScore) + { + mTeams[teamIndex].score = newScore; + s2cSetTeamScore(teamIndex, newScore); + if(newScore >= mTeamScoreLimit) + gameOverManGameOver(); + } + + TNL_IMPLEMENT_NETOBJECT_RPC(GameType, s2cSetTimeRemaining, (U32 timeLeft), + NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) + { + mGameTimer.reset(timeLeft); + } + TNL_IMPLEMENT_NETOBJECT_RPC(GameType, c2sChangeTeams, (), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhostParent, 0) *************** *** 303,306 **** --- 345,350 ---- s2cClientJoinedTeam(mClientList[i].name, mClientList[i].teamId); } + s2cSetTimeRemaining(mGameTimer.getCurrent()); + s2cSetGameOver(mGameOver); NetObject::setRPCDestConnection(NULL); } Index: soccerGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/soccerGame.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** soccerGame.cpp 30 Apr 2004 20:27:42 -0000 1.1 --- soccerGame.cpp 2 May 2004 06:27:41 -0000 1.2 *************** *** 44,48 **** void SoccerGameType::renderInterfaceOverlay(bool scoreboardVisible) { ! if(scoreboardVisible) { U32 totalWidth = 780; --- 44,48 ---- void SoccerGameType::renderInterfaceOverlay(bool scoreboardVisible) { ! if(scoreboardVisible || mGameOver ) { U32 totalWidth = 780; *************** *** 119,123 **** for(S32 i = 0; i < mTeams.size(); i++) { ! Point pos(750, 550 - i * 38); renderFlag(pos + Point(-20, 18), mTeams[i].color); glColor3f(1,1,1); --- 119,123 ---- for(S32 i = 0; i < mTeams.size(); i++) { ! Point pos(750, 535 - i * 38); renderFlag(pos + Point(-20, 18), mTeams[i].color); glColor3f(1,1,1); *************** *** 125,128 **** --- 125,133 ---- } } + U32 timeLeft = mGameTimer.getCurrent(); + + U32 minsRemaining = timeLeft / (60000); + U32 secsRemaining = (timeLeft - (minsRemaining * 60000)) / 1000; + UserInterface::drawStringf(720, 577, 20, "%02d:%02d", minsRemaining, secsRemaining); } *************** *** 143,147 **** s2cKillMessage(mClientList[clientIndex].name, mClientList[killerIndex].name); } ! mClientList[clientIndex].respawnDelay = RespawnDelay; } --- 148,152 ---- s2cKillMessage(mClientList[clientIndex].name, mClientList[killerIndex].name); } ! mClientList[clientIndex].respawnTimer.reset(RespawnDelay); } *************** *** 158,174 **** } ! TNL_IMPLEMENT_NETOBJECT_RPC(SoccerGameType, s2cSoccerScoreMessage, (StringTableEntry clientName, U32 teamIndex), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) { ! gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), ! "%s scored a goal for team %s!", ! clientName.getString(), ! mTeams[teamIndex].name.getString()); ! SFXObject::play(SFXFlagCapture); } void SoccerGameType::scoreGoal(StringTableEntry playerName, U32 goalTeamIndex) { ! s2cSoccerScoreMessage(playerName, goalTeamIndex); } --- 163,251 ---- } ! TNL_IMPLEMENT_NETOBJECT_RPC(SoccerGameType, s2cSoccerScoreMessage, (U32 msgIndex, StringTableEntry clientName, U32 teamIndex), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) { ! if(msgIndex == SoccerMsgScoreGoal) ! { ! SFXObject::play(SFXFlagCapture); ! gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), ! "%s scored a goal on team %s!", ! clientName.getString(), ! mTeams[teamIndex].name.getString()); ! } ! else if(msgIndex == SoccerMsgScoreOwnGoal) ! { ! SFXObject::play(SFXFlagCapture); ! if(clientName.isNull()) ! gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), ! "A goal was scored on team %s!", ! mTeams[teamIndex].name.getString()); ! else ! gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), ! "%s scored a goal for the other team%s!", ! clientName.getString(), ! mTeams.size() > 2 ? "s" : ""); ! } ! else if(msgIndex == SoccerMsgGameOverTeamWin) ! { ! gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), ! "Team %s wins the game!", ! mTeams[teamIndex].name.getString()); ! SFXObject::play(SFXFlagCapture); ! } ! else if(msgIndex == SoccerMsgGameOverTie) ! { ! gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), ! "The game ended in a tie."); ! SFXObject::play(SFXFlagDrop); ! } } void SoccerGameType::scoreGoal(StringTableEntry playerName, U32 goalTeamIndex) { ! S32 index = findClientIndexByName(playerName); ! S32 scoringTeam = -1; ! if(index != -1) ! scoringTeam = mClientList[index].teamId; ! ! if(scoringTeam == -1 || scoringTeam == goalTeamIndex) ! { ! // give all the other teams a point. ! for(S32 i = 0; i < mTeams.size(); i++) ! { ! if(i != goalTeamIndex) ! setTeamScore(i, mTeams[i].score + 1); ! } ! s2cSoccerScoreMessage(SoccerMsgScoreOwnGoal, playerName, goalTeamIndex); ! } ! else ! { ! mClientList[index].score += GoalScore; ! setTeamScore(scoringTeam, mTeams[scoringTeam].score + 1); ! s2cSoccerScoreMessage(SoccerMsgScoreGoal, playerName, goalTeamIndex); ! } ! } ! ! void SoccerGameType::gameOverManGameOver() ! { ! Parent::gameOverManGameOver(); ! bool tied = false; ! S32 teamWinner = 0; ! U32 winningScore = mTeams[0].score; ! for(S32 i = 1; i < mTeams.size(); i++) ! { ! if(mTeams[i].score == winningScore) ! tied = true; ! else if(mTeams[i].score > winningScore) ! { ! teamWinner = i; ! winningScore = mTeams[i].score; ! tied = false; ! } ! } ! if(tied) ! s2cSoccerScoreMessage(SoccerMsgGameOverTie, StringTableEntry(), 0); ! else ! s2cSoccerScoreMessage(SoccerMsgGameOverTeamWin, StringTableEntry(), teamWinner); } Index: ZAP.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ZAP.vcproj,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ZAP.vcproj 30 Apr 2004 20:27:41 -0000 1.10 --- ZAP.vcproj 2 May 2004 06:27:41 -0000 1.11 *************** *** 262,265 **** --- 262,268 ---- </File> <File + RelativePath=".\timer.h"> + </File> + <File RelativePath=".\UI.cpp"> </File> Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** game.h 30 Apr 2004 20:27:41 -0000 1.10 --- game.h 2 May 2004 06:27:41 -0000 1.11 *************** *** 32,35 **** --- 32,36 ---- #include "../tnl/tnlNetObject.h" #include "gridDB.h" + #include "timer.h" /// *************** *** 144,150 **** --- 145,158 ---- class ServerGame : public Game { + enum { + LevelSwitchTime = 5000, + }; + U32 mPlayerCount; U32 mMaxPlayers; const char *mHostName; + Vector<StringTableEntry> mLevelList; + U32 mCurrentLevelIndex; + Timer mLevelSwitchTimer; public: U32 getPlayerCount() { return mPlayerCount; } *************** *** 156,163 **** --- 164,175 ---- ServerGame(const Address &theBindAddress, U32 maxPlayers, const char *hostName); + void setLevelList(const char *levelList); void loadLevel(const char *fileName); + void cycleLevel(); + void processLevelLoadLine(int argc, const char **argv); bool isServer() { return true; } void idle(U32 timeDelta); + void gameEnded(); }; Index: UIGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIGame.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** UIGame.cpp 30 Apr 2004 21:58:10 -0000 1.13 --- UIGame.cpp 2 May 2004 06:27:41 -0000 1.14 *************** *** 119,124 **** } - glTranslatef(400, 300, 0); - if(gClientGame) gClientGame->render(); --- 119,122 ---- *************** *** 128,131 **** --- 126,130 ---- { glPushMatrix(); + glTranslatef(400, 300, 0); glTranslatef(mMousePoint.x, mMousePoint.y, 0); Index: CTFGame.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** CTFGame.h 30 Apr 2004 20:27:41 -0000 1.6 --- CTFGame.h 2 May 2004 06:27:41 -0000 1.7 *************** *** 39,42 **** --- 39,43 ---- class CTFGameType : public GameType { + typedef GameType Parent; enum Scores { *************** *** 55,58 **** --- 56,60 ---- U32 checkFlagDrop(GameObject *theObject); + void gameOverManGameOver(); enum { *************** *** 61,64 **** --- 63,68 ---- CTFMsgTakeFlag, CTFMsgDropFlag, + CTFMsgGameOverTeamWin, + CTFMsgGameOverTie, }; Index: main.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/main.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** main.cpp 27 Apr 2004 21:43:04 -0000 1.13 --- main.cpp 2 May 2004 06:27:41 -0000 1.14 *************** *** 52,56 **** const char *gMasterAddressString = "IP:master.opentnl.org:29005"; Address gMasterAddress; ! const char *gLoadLevel = "level1.txt"; void reshape(int nw, int nh) --- 52,56 ---- const char *gMasterAddressString = "IP:master.opentnl.org:29005"; Address gMasterAddress; ! const char *gLevelList = "level1.txt level3.txt"; void reshape(int nw, int nh) *************** *** 206,210 **** { gServerGame = new ServerGame(bindAddress, gMaxPlayers, gHostName); ! gServerGame->loadLevel(gLoadLevel); if(!dedicated) --- 206,210 ---- { gServerGame = new ServerGame(bindAddress, gMaxPlayers, gHostName); ! gServerGame->setLevelList(gLevelList); if(!dedicated) *************** *** 314,321 **** } } ! else if(!stricmp(argv[i], "-level")) { if(hasAdditionalArg) ! gLoadLevel = argv[i+1]; } else if(!stricmp(argv[i], "-hostname")) --- 314,321 ---- } } ! else if(!stricmp(argv[i], "-levels")) { if(hasAdditionalArg) ! gLevelList = argv[i+1]; } else if(!stricmp(argv[i], "-hostname")) Index: CTFGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** CTFGame.cpp 30 Apr 2004 21:58:10 -0000 1.18 --- CTFGame.cpp 2 May 2004 06:27:41 -0000 1.19 *************** *** 66,70 **** void CTFGameType::renderInterfaceOverlay(bool scoreboardVisible) { ! if(scoreboardVisible && mTeams.size() > 0) { U32 totalWidth = 780; --- 66,70 ---- void CTFGameType::renderInterfaceOverlay(bool scoreboardVisible) { ! if((mGameOver || scoreboardVisible) && mTeams.size() > 0) { U32 totalWidth = 780; *************** *** 141,196 **** for(S32 i = 0; i < mTeams.size(); i++) { ! Point pos(750, 550 - i * 38); renderFlag(pos + Point(-20, 18), mTeams[i].color); glColor3f(1,1,1); UserInterface::drawStringf(pos.x, pos.y, 32, "%d", mTeams[i].score); } - - // Render current ship's energy, too. - if(gClientGame && gClientGame->getConnectionToServer()) - { - Ship *s = dynamic_cast<Ship*>(gClientGame->getConnectionToServer()->getControlObject()); - if(s) - { - static F32 curEnergy = 0.f; - - curEnergy = (curEnergy + s->mEnergy) * 0.5f; - - const F32 offset = 50; - - glColor3f(0.0, 0.0, 1); - glBegin(GL_POLYGON); - glVertex2f(15, 515 + offset); - glVertex2f(15 + curEnergy, 515 + offset); - glVertex2f(15 + curEnergy, 535 + offset); - glVertex2f(15, 535 + offset); - glEnd(); - - // Show danger line. - glColor3f(1, 0, 0); - glBegin(GL_LINES); - glVertex2f(15 + 5, 512 + offset); - glVertex2f(15 + 5, 539 + offset); - glEnd(); - - // Show safety line. - glColor3f(1, 1, 0); - glBegin(GL_LINES); - glVertex2f(15 + 15, 512 + offset); - glVertex2f(15 + 15, 539 + offset); - glEnd(); - - // Show full marker - glColor3f(0, 1, 0); - glBegin(GL_LINE_STRIP); - glVertex2f(15 + 90, 512 + offset); - glVertex2f(15 + 101, 512 + offset); - glVertex2f(15 + 101, 539 + offset); - glVertex2f(15 + 90, 539 + offset); - glEnd(); - - } - } } } --- 141,155 ---- for(S32 i = 0; i < mTeams.size(); i++) { ! Point pos(750, 535 - i * 38); renderFlag(pos + Point(-20, 18), mTeams[i].color); glColor3f(1,1,1); UserInterface::drawStringf(pos.x, pos.y, 32, "%d", mTeams[i].score); } } + U32 timeLeft = mGameTimer.getCurrent(); + + U32 minsRemaining = timeLeft / (60000); + U32 secsRemaining = (timeLeft - (minsRemaining * 60000)) / 1000; + UserInterface::drawStringf(720, 577, 20, "%02d:%02d", minsRemaining, secsRemaining); } *************** *** 222,227 **** if(mountedFlag) { ! mTeams[cl.teamId].score++; ! s2cSetTeamScore(cl.teamId, mTeams[cl.teamId].score); s2cCTFMessage(CTFMsgCaptureFlag, cl.name, mountedFlag->getTeamIndex()); --- 181,185 ---- if(mountedFlag) { ! setTeamScore(cl.teamId, mTeams[cl.teamId].score + 1); s2cCTFMessage(CTFMsgCaptureFlag, cl.name, mountedFlag->getTeamIndex()); *************** *** 306,310 **** } checkFlagDrop(clientObject); ! mClientList[clientIndex].respawnDelay = RespawnDelay; } --- 264,268 ---- } checkFlagDrop(clientObject); ! mClientList[clientIndex].respawnTimer.reset(RespawnDelay); } *************** *** 314,317 **** --- 272,298 ---- } + void CTFGameType::gameOverManGameOver() + { + Parent::gameOverManGameOver(); + bool tied = false; + S32 teamWinner = 0; + U32 winningScore = mTeams[0].score; + for(S32 i = 1; i < mTeams.size(); i++) + { + if(mTeams[i].score == winningScore) + tied = true; + else if(mTeams[i].score > winningScore) + { + teamWinner = i; + winningScore = mTeams[i].score; + tied = false; + } + } + if(tied) + s2cCTFMessage(CTFMsgGameOverTie, StringTableEntry(), 0); + else + s2cCTFMessage(CTFMsgGameOverTeamWin, StringTableEntry(), teamWinner); + } + TNL_IMPLEMENT_NETOBJECT_RPC(CTFGameType, s2cCTFMessage, (U32 messageIndex, StringTableEntry clientName, U32 teamIndex), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) *************** *** 323,326 **** --- 304,309 ---- "%s took the %s flag!", "%s dropped the %s flag!", + "%sTeam %s wins the game!", + "The game ended in a tie.", }; *************** *** 331,334 **** --- 314,319 ---- SFXFlagSnatch, SFXFlagDrop, + SFXFlagCapture, + SFXFlagDrop, }; Index: gameType.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** gameType.h 30 Apr 2004 20:27:41 -0000 1.6 --- gameType.h 2 May 2004 06:27:41 -0000 1.7 *************** *** 29,32 **** --- 29,33 ---- #include "gameObject.h" + #include "timer.h" namespace Zap *************** *** 46,55 **** S32 teamId; U32 score; ! U32 respawnDelay; bool wantsScoreboardUpdates; SafePtr<GameConnection> clientConnection; U32 ping; ! ClientRef() { ping = 0; score = 0; respawnDelay = 0; } }; --- 47,56 ---- S32 teamId; U32 score; ! Timer respawnTimer; bool wantsScoreboardUpdates; SafePtr<GameConnection> clientConnection; U32 ping; ! ClientRef() { ping = 0; score = 0; } }; *************** *** 67,74 **** Vector<Team> mTeams; U32 mThisClientName; ///< Set to the client name of this client (only on the ghost of the GameType) ! U32 mTimeUntilScoreboardUpdate; enum { MaxPing = 999, }; --- 68,81 ---- Vector<Team> mTeams; U32 mThisClientName; ///< Set to the client name of this client (only on the ghost of the GameType) ! Timer mScoreboardUpdateTimer; ! Timer mGameTimer; ! Timer mGameTimeUpdateTimer; ! U32 mTeamScoreLimit; ! bool mGameOver; // set to true when an end condition is met enum { MaxPing = 999, + DefaultGameTime = 20 * 60 * 1000, + DefaultTeamScoreLimit = 8, }; *************** *** 94,99 **** --- 101,110 ---- void onAddedToGame(Game *theGame); void onGhostAvailable(GhostConnection *theConnection); + void processClient(U32 deltaT); void processServer(U32 deltaT); + void setTeamScore(S32 teamIndex, S32 newScore); + virtual void gameOverManGameOver(); + virtual void serverAddClient(GameConnection *theClient); virtual void serverRemoveClient(GameConnection *theClient); *************** *** 125,128 **** --- 136,141 ---- TNL_DECLARE_RPC(s2cScoreboardUpdate, (const Vector<RangedU32<0, MaxPing> > &pingTimes, const Vector<Int<24> > &scores)); + TNL_DECLARE_RPC(s2cSetGameOver, (bool gameOver)); + TNL_DECLARE_RPC(s2cSetTimeRemaining, (U32 timeLeft)); TNL_DECLARE_RPC(c2sRequestScoreboardUpdates, (bool updates)); Index: game.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** game.cpp 30 Apr 2004 21:58:10 -0000 1.15 --- game.cpp 2 May 2004 06:27:41 -0000 1.16 *************** *** 174,177 **** --- 174,223 ---- } + void ServerGame::setLevelList(const char *levelList) + { + for(;;) + { + const char *firstSpace = strchr(levelList, ' '); + StringTableEntry st; + if(firstSpace) + st.setn(levelList, firstSpace - levelList); + else + st.set(levelList); + + if(st.getString()[0]) + mLevelList.push_back(st); + if(!firstSpace) + break; + levelList = firstSpace + 1; + } + mCurrentLevelIndex = mLevelList.size() - 1; + cycleLevel(); + } + + void ServerGame::cycleLevel() + { + // delete any objects that may exist + while(mGameObjects.size()) + delete mGameObjects[0]; + + for(GameConnection *walk = GameConnection::gClientList.mNext; walk != &GameConnection::gClientList; walk = walk->mNext) + walk->resetGhosting(); + + mCurrentLevelIndex++; + if(mCurrentLevelIndex >= mLevelList.size()) + mCurrentLevelIndex = 0; + loadLevel(mLevelList[mCurrentLevelIndex].getString()); + if(!getGameType()) + { + GameType *g = new GameType; + g->addToGame(this); + } + for(GameConnection *walk = GameConnection::gClientList.mNext; walk != &GameConnection::gClientList; walk = walk->mNext) + { + addClient(walk); + walk->activateGhosting(); + } + } + void ServerGame::loadLevel(const char *fileName) { *************** *** 227,230 **** --- 273,284 ---- processDeleteList(timeDelta); mNetInterface->processConnections(); + + if(mLevelSwitchTimer.update(timeDelta)) + cycleLevel(); + } + + void ServerGame::gameEnded() + { + mLevelSwitchTimer.reset(LevelSwitchTime); } *************** *** 406,409 **** --- 460,465 ---- glPushMatrix(); + glTranslatef(400, 300, 0); + glScalef(visScale.x, visScale.y, 1); glTranslatef(-offset.x, -offset.y, 0); *************** *** 475,478 **** --- 531,536 ---- glPushMatrix(); + glTranslatef(400, 300, 0); + glScalef(400 / F32(PlayerHorizVisDistance), 300 / F32(PlayerVertVisDistance), 1); *************** *** 495,498 **** --- 553,602 ---- glPopMatrix(); + + // Render current ship's energy, too. + if(mConnectionToServer.isValid()) + { + Ship *s = dynamic_cast<Ship*>(mConnectionToServer->getControlObject()); + if(s) + { + static F32 curEnergy = 0.f; + + curEnergy = (curEnergy + s->mEnergy) * 0.5f; + + const F32 offset = 50; + + glColor3f(0.0, 0.0, 1); + glBegin(GL_POLYGON); + glVertex2f(15, 515 + offset); + glVertex2f(15 + curEnergy, 515 + offset); + glVertex2f(15 + curEnergy, 535 + offset); + glVertex2f(15, 535 + offset); + glEnd(); + + // Show danger line. + glColor3f(1, 0, 0); + glBegin(GL_LINES); + glVertex2f(15 + 5, 512 + offset); + glVertex2f(15 + 5, 539 + offset); + glEnd(); + + // Show safety line. + glColor3f(1, 1, 0); + glBegin(GL_LINES); + glVertex2f(15 + 15, 512 + offset); + glVertex2f(15 + 15, 539 + offset); + glEnd(); + + // Show full marker + glColor3f(0, 1, 0); + glBegin(GL_LINE_STRIP); + glVertex2f(15 + 90, 512 + offset); + glVertex2f(15 + 101, 512 + offset); + glVertex2f(15 + 101, 539 + offset); + glVertex2f(15 + 90, 539 + offset); + glEnd(); + + } + } } Index: soccerGame.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/soccerGame.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** soccerGame.h 30 Apr 2004 20:27:42 -0000 1.1 --- soccerGame.h 2 May 2004 06:27:41 -0000 1.2 *************** *** 39,42 **** --- 39,43 ---- class SoccerGameType : public GameType { + typedef GameType Parent; enum Scores { *************** *** 49,58 **** bool objectCanDamageObject(GameObject *damager, GameObject *victim); void scoreGoal(StringTableEntry playerName, U32 goalTeamIndex); enum { SoccerMsgScoreGoal, }; ! TNL_DECLARE_RPC(s2cSoccerScoreMessage, (StringTableEntry clientName, U32 teamIndex)); TNL_DECLARE_CLASS(SoccerGameType); }; --- 50,63 ---- bool objectCanDamageObject(GameObject *damager, GameObject *victim); void scoreGoal(StringTableEntry playerName, U32 goalTeamIndex); + void gameOverManGameOver(); enum { SoccerMsgScoreGoal, + SoccerMsgScoreOwnGoal, + SoccerMsgGameOverTeamWin, + SoccerMsgGameOverTie, }; ! TNL_DECLARE_RPC(s2cSoccerScoreMessage, (U32 msgIndex, StringTableEntry clientName, U32 teamIndex)); TNL_DECLARE_CLASS(SoccerGameType); }; |
From: Mark F. <mar...@us...> - 2004-05-02 06:27:49
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27167/tnl Modified Files: ghostConnection.cpp Log Message: Fixed ghosting bug Made games cycle after time or score limit are reached Index: ghostConnection.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/ghostConnection.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ghostConnection.cpp 27 Apr 2004 23:26:14 -0000 1.2 --- ghostConnection.cpp 2 May 2004 06:27:40 -0000 1.3 *************** *** 895,898 **** --- 895,899 ---- { detachObject(&mGhostRefs[i]); + mGhostRefs[i].lastUpdateChain = NULL; freeGhostInfo(&mGhostRefs[i]); } |
From: Mark F. <mar...@us...> - 2004-05-02 06:27:49
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27167/exe Modified Files: level1.txt level3.txt Log Message: Fixed ghosting bug Made games cycle after time or score limit are reached Index: level3.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level3.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** level3.txt 30 Apr 2004 20:27:27 -0000 1.2 --- level3.txt 2 May 2004 06:27:40 -0000 1.3 *************** *** 1,3 **** ! SoccerGameType Team Yellow 1 1 0 --- 1,4 ---- ! SoccerGameType 20 8 ! Team Yellow 1 1 0 *************** *** 5,14 **** BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 Spawn 0 0.5 1.5 Spawn 1 7.5 7.5 ! SoccerBallItem 4 4 SoccerGoalObject 1 5.2 1 5.6 0.2 6.4 0.2 6.8 1 ! SoccerGoalObject 0 5 15 7 15 6.5 16 5.5 16 --- 6,20 ---- BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 + BarrierMaker 6 6 7 7 5 7 6 6 + BarrierMaker 6 10 7 9 5 9 6 10 + BarrierMaker 5 3 5 3.5 4 3.5 5 3 + BarrierMaker 5 4 5 5 5.5 5 + BarrierMaker 7 3 7 5 Spawn 0 0.5 1.5 Spawn 1 7.5 7.5 ! SoccerBallItem 6 8 SoccerGoalObject 1 5.2 1 5.6 0.2 6.4 0.2 6.8 1 ! SoccerGoalObject 0 5.2 15 6.8 15 6.4 15.8 5.6 15.8 Index: level1.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level1.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** level1.txt 1 May 2004 19:47:26 -0000 1.4 --- level1.txt 2 May 2004 06:27:40 -0000 1.5 *************** *** 3,7 **** GridSize 300 ! CTFGameType Team Blue 0 0 1 --- 3,7 ---- GridSize 300 ! CTFGameType 20 8 Team Blue 0 0 1 |
From: Robert B. Jr. <rbl...@us...> - 2004-05-01 19:47:35
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15509/zap Modified Files: ship.cpp Log Message: Crash fix in ship rendering. Also changed processArguments to be consistent with the way all other objects are loaded from the game level, ie: multiplying the position by the grid size. Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ship.cpp 30 Apr 2004 21:58:10 -0000 1.20 --- ship.cpp 1 May 2004 19:47:26 -0000 1.21 *************** *** 81,89 **** return; ! mMoveState[0].pos.read(argv); ! ! for(U32 i = 1; i < MoveStateCount; i++) { ! mMoveState[i].pos = mMoveState[0].pos; mMoveState[i].angle = 0; } --- 81,90 ---- return; ! Point pos; ! pos.read(argv); ! pos *= getGame()->getGridSize(); ! for(U32 i = 0; i < MoveStateCount; i++) { ! mMoveState[i].pos = pos; mMoveState[i].angle = 0; } *************** *** 752,756 **** // Render name... ! if(gClientGame->getConnectionToServer()->getControlObject() != this) { static char buff[255]; --- 753,758 ---- // Render name... ! GameConnection *conn = gClientGame->getConnectionToServer(); ! if(conn && conn->getControlObject() != this) { static char buff[255]; |
From: Robert B. Jr. <rbl...@us...> - 2004-05-01 19:47:34
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15509/exe Modified Files: level1.txt Log Message: Crash fix in ship rendering. Also changed processArguments to be consistent with the way all other objects are loaded from the game level, ie: multiplying the position by the grid size. Index: level1.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level1.txt,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** level1.txt 27 Apr 2004 20:41:53 -0000 1.3 --- level1.txt 1 May 2004 19:47:26 -0000 1.4 *************** *** 75,79 **** #BarrierMaker 0 0 1 0 2 1 ! Ship 50 300 0 1 0 ! Ship 450 100 0 1 1 ! Ship 150 300 1 1 0 \ No newline at end of file --- 75,79 ---- #BarrierMaker 0 0 1 0 2 1 ! Ship 0.5 1 0 1 0 ! Ship 1.5 0.5 0 1 1 ! Ship 1 1 1 1 0 |
From: Ben G. <s_a...@us...> - 2004-04-30 21:58:19
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16758/zap Modified Files: CTFGame.cpp UIGame.cpp game.cpp ship.cpp ship.h sparkManager.cpp sparkManager.h Log Message: Implemented energy on ships. Added boost (hold space) and shields (toggle w/ F). Rebound joystick buttons - shoulder buttons do boost/shield and buttons 3/4 do commander map/scoreboard. Motion trails change color during boost. Render energy bar as part of gametype GUI, with markers showing 100%, 15%, and 5%. Refactored motion trail rendering to be done globally. This reduces state changes and prevents ugly popping issues. Index: ship.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ship.h 30 Apr 2004 20:27:42 -0000 1.11 --- ship.h 30 Apr 2004 21:58:10 -0000 1.12 *************** *** 48,51 **** --- 48,53 ---- MaxVelocity = 450, // points per second Acceleration = 2500, // points per second per second + TurboMaxVelocity = 700, // points per second + TurboAcceleration = 5000, // points per second per second InterpMaxVelocity = 900, // velocity to use to interpolate to proper position InterpAcceleration = 1800, *************** *** 58,61 **** --- 60,64 ---- MaxControlObjectInterpDistance = 200, TrailCount = 2, + RechargeRate = 3, // How many percent/second }; *************** *** 67,70 **** --- 70,74 ---- ExplosionMask = BIT(4), HealthMask = BIT(5), + PowersMask = BIT(6), }; *************** *** 73,79 **** F32 mHealth; F32 mEnergy; - bool mShieldActive; - StringTableEntry mPlayerName; S32 mLastTrailPoint[TrailCount]; --- 77,82 ---- F32 mHealth; F32 mEnergy; StringTableEntry mPlayerName; + bool mShield, mTurbo, mCooldown; S32 mLastTrailPoint[TrailCount]; *************** *** 95,98 **** --- 98,102 ---- F32 getHealth() { return mHealth; } + void burnEnergy(U32 dT); void emitMovementSparks(); void emitShipExplosion(Point pos); Index: CTFGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** CTFGame.cpp 30 Apr 2004 20:27:41 -0000 1.17 --- CTFGame.cpp 30 Apr 2004 21:58:10 -0000 1.18 *************** *** 146,149 **** --- 146,195 ---- UserInterface::drawStringf(pos.x, pos.y, 32, "%d", mTeams[i].score); } + + // Render current ship's energy, too. + if(gClientGame && gClientGame->getConnectionToServer()) + { + Ship *s = dynamic_cast<Ship*>(gClientGame->getConnectionToServer()->getControlObject()); + if(s) + { + static F32 curEnergy = 0.f; + + curEnergy = (curEnergy + s->mEnergy) * 0.5f; + + const F32 offset = 50; + + glColor3f(0.0, 0.0, 1); + glBegin(GL_POLYGON); + glVertex2f(15, 515 + offset); + glVertex2f(15 + curEnergy, 515 + offset); + glVertex2f(15 + curEnergy, 535 + offset); + glVertex2f(15, 535 + offset); + glEnd(); + + // Show danger line. + glColor3f(1, 0, 0); + glBegin(GL_LINES); + glVertex2f(15 + 5, 512 + offset); + glVertex2f(15 + 5, 539 + offset); + glEnd(); + + // Show safety line. + glColor3f(1, 1, 0); + glBegin(GL_LINES); + glVertex2f(15 + 15, 512 + offset); + glVertex2f(15 + 15, 539 + offset); + glEnd(); + + // Show full marker + glColor3f(0, 1, 0); + glBegin(GL_LINE_STRIP); + glVertex2f(15 + 90, 512 + offset); + glVertex2f(15 + 101, 512 + offset); + glVertex2f(15 + 101, 539 + offset); + glVertex2f(15 + 90, 539 + offset); + glEnd(); + + } + } } } Index: sparkManager.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/sparkManager.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** sparkManager.cpp 30 Apr 2004 08:33:20 -0000 1.4 --- sparkManager.cpp 30 Apr 2004 21:58:10 -0000 1.5 *************** *** 166,176 **** }; fxTrail::fxTrail(U32 dropFrequency, U32 len) { mDropFreq = dropFrequency; mLength = len; } ! void fxTrail::update(Point pos) { if(mNodes.size() < mLength) --- 166,184 ---- }; + //----------------------------------------------------------------------------- + fxTrail::fxTrail(U32 dropFrequency, U32 len) { mDropFreq = dropFrequency; mLength = len; + registerTrail(); } ! fxTrail::~fxTrail() ! { ! unregisterTrail(); ! } ! ! void fxTrail::update(Point pos, bool boosted) { if(mNodes.size() < mLength) *************** *** 179,187 **** --- 187,200 ---- t.pos = pos; t.ttl = mDropFreq; + t.boosted = boosted; mNodes.push_front(t); } else + { mNodes[0].pos = pos; + if(boosted) + mNodes[0].boosted = true; + } } *************** *** 198,204 **** void fxTrail::render() { - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glBegin(GL_LINE_STRIP); --- 211,214 ---- *************** *** 206,217 **** { F32 t = ((F32)i/(F32)mNodes.size()); ! glColor4f(1.f - 2*t, 1.f - 2*t, 1.f, 1.f-t); glVertex2f(mNodes[i].pos.x, mNodes[i].pos.y); } glEnd(); - - glDisable(GL_BLEND); - glBlendFunc(GL_ONE, GL_ZERO); } --- 216,229 ---- { F32 t = ((F32)i/(F32)mNodes.size()); ! ! if(mNodes[i].boosted) ! glColor4f(1.f - t, 1.f - t, 0.f, 1.f-t); ! else ! glColor4f(1.f - 2*t, 1.f - 2*t, 1.f, 0.7f-0.7*t); ! glVertex2f(mNodes[i].pos.x, mNodes[i].pos.y); } glEnd(); } *************** *** 231,233 **** --- 243,292 ---- } + fxTrail * fxTrail::mHead = NULL; + + void fxTrail::registerTrail() + { + fxTrail *n = mHead; + mHead = this; + mNext = n; + } + + void fxTrail::unregisterTrail() + { + // Find ourselves in the list (lame O(n) solution) + fxTrail *w = mHead, *p = NULL; + while(w) + { + if(w == this) + { + if(p) + { + p->mNext = w->mNext; + } + else + { + mHead = w->mNext; + } + } + p = w; + w = w->mNext; + } + } + + void fxTrail::renderTrails() + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + fxTrail *w = mHead; + while(w) + { + w->render(); + w = w->mNext; + } + + glDisable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ZERO); + } + }; \ No newline at end of file Index: game.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** game.cpp 30 Apr 2004 20:27:41 -0000 1.14 --- game.cpp 30 Apr 2004 21:58:10 -0000 1.15 *************** *** 492,495 **** --- 492,496 ---- SparkManager::render(); + fxTrail::renderTrails(); glPopMatrix(); Index: sparkManager.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/sparkManager.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sparkManager.h 30 Apr 2004 08:33:20 -0000 1.3 --- sparkManager.h 30 Apr 2004 21:58:10 -0000 1.4 *************** *** 51,54 **** --- 51,55 ---- Point pos; S32 ttl; + bool boosted; }; *************** *** 56,66 **** U32 mDropFreq; ! U32 mLength; public: fxTrail(U32 dropFrequency = 32, U32 len = 15); /// Update the point this trail is attached to. ! void update(Point pos); void tick(U32 dT); --- 57,76 ---- U32 mDropFreq; ! S32 mLength; ! ! fxTrail *mNext; ! ! ! static fxTrail *mHead; ! void registerTrail(); ! void unregisterTrail(); ! public: fxTrail(U32 dropFrequency = 32, U32 len = 15); + ~fxTrail(); /// Update the point this trail is attached to. ! void update(Point pos, bool boosted = false); void tick(U32 dT); *************** *** 71,74 **** --- 81,86 ---- Point getLastPos(); + + static void renderTrails(); }; Index: UIGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIGame.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** UIGame.cpp 28 Apr 2004 01:34:57 -0000 1.12 --- UIGame.cpp 30 Apr 2004 21:58:10 -0000 1.13 *************** *** 255,259 **** switch(buttonIndex) { ! case 6: { mInScoreboardMode = true; --- 255,259 ---- switch(buttonIndex) { ! case 3: { mInScoreboardMode = true; *************** *** 263,269 **** break; } ! case 7: gClientGame->zoomCommanderMap(); break; } } --- 263,277 ---- break; } ! case 2: gClientGame->zoomCommanderMap(); break; + + case 7: + mCurrentMove.boost = true; + break; + + case 6: + mCurrentMove.shield = true; + break; } } *************** *** 273,277 **** switch(buttonIndex) { ! case 6: { mInScoreboardMode = false; --- 281,285 ---- switch(buttonIndex) { ! case 3: { mInScoreboardMode = false; *************** *** 281,284 **** --- 289,300 ---- break; } + + case 7: + mCurrentMove.boost = false; + break; + + case 6: + mCurrentMove.shield = false; + break; } } *************** *** 312,315 **** --- 328,335 ---- mCurrentMove.right = 1.0; break; + case ' ': + mCurrentMove.boost = true; + break; + case 27: if(!gClientGame->isConnectedToServer()) *************** *** 407,410 **** --- 427,437 ---- mCurrentMove.right = 0; break; + + case ' ': + mCurrentMove.boost = false; + break; + case 'F': + mCurrentMove.shield = !mCurrentMove.shield; + break; } } Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ship.cpp 30 Apr 2004 20:27:41 -0000 1.19 --- ship.cpp 30 Apr 2004 21:58:10 -0000 1.20 *************** *** 69,72 **** --- 69,77 ---- for(S32 i=0; i<TrailCount; i++) mTrail[i].reset(); + + mEnergy = 100.f; + mShield = false; + mTurbo = false; + mCooldown = false; } *************** *** 102,117 **** mMoveState[LastProcessState] = mMoveState[stateIndex]; ! float time = theMove->time * 0.001; Point requestVel(theMove->right - theMove->left, theMove->down - theMove->up); ! requestVel *= MaxVelocity; F32 len = requestVel.len(); ! if(len > MaxVelocity) ! requestVel *= MaxVelocity / len; Point velDelta = requestVel - mMoveState[stateIndex].vel; ! float accRequested = velDelta.len(); ! float maxAccel = Acceleration * time; if(accRequested > maxAccel) { --- 107,122 ---- mMoveState[LastProcessState] = mMoveState[stateIndex]; ! F32 time = theMove->time * 0.001; Point requestVel(theMove->right - theMove->left, theMove->down - theMove->up); ! requestVel *= (mTurbo ? TurboMaxVelocity : MaxVelocity); F32 len = requestVel.len(); ! if(len > (mTurbo ? TurboMaxVelocity : MaxVelocity)) ! requestVel *= (mTurbo ? TurboMaxVelocity : MaxVelocity) / len; Point velDelta = requestVel - mMoveState[stateIndex].vel; ! F32 accRequested = velDelta.len(); ! F32 maxAccel = (mTurbo ? TurboAcceleration : Acceleration) * time; if(accRequested > maxAccel) { *************** *** 135,138 **** --- 140,144 ---- mMoveState[RenderState] = mMoveState[ActualState]; setMaskBits(PositionMask); + if(!theMove->isEqualMove(&lastMove)) { *************** *** 140,143 **** --- 146,150 ---- setMaskBits(MoveMask); } + if(theMove->fire) { *************** *** 145,158 **** if(currentTime - lastFireTime > FireDelay) { lastFireTime = currentTime; Point dir(sin(mMoveState[ActualState].angle), cos(mMoveState[ActualState].angle) ); ! Point projVel = dir * 600 + dir * mMoveState[ActualState].vel.dot(dir); //mMoveState[ActualState].vel + dir * 500; Projectile *proj = new Projectile(mMoveState[ActualState].pos + dir * (CollisionRadius-1), projVel, 500, this); proj->addToGame(getGame()); } } updateExtent(); } void Ship::damageObject(DamageInfo *theInfo) { --- 152,216 ---- if(currentTime - lastFireTime > FireDelay) { + mEnergy -= 1.f; lastFireTime = currentTime; Point dir(sin(mMoveState[ActualState].angle), cos(mMoveState[ActualState].angle) ); ! Point projVel = dir * 600 + dir * mMoveState[ActualState].vel.dot(dir); Projectile *proj = new Projectile(mMoveState[ActualState].pos + dir * (CollisionRadius-1), projVel, 500, this); proj->addToGame(getGame()); } } + + if(mTurbo != theMove->boost || mShield != theMove->shield) + setMaskBits(PowersMask); + + mShield = theMove->shield; + mTurbo = theMove->boost; + + burnEnergy(theMove->time); updateExtent(); } + void Ship::burnEnergy( U32 dT ) + { + if(isGhost()) return; + + F32 scaleFactor = ((F32)dT) / 1000.f; + + // Update things based on available energy... + if(mEnergy <= 5.f || mCooldown) + { + mShield = false; + mTurbo = false; + mCooldown = true; + } + + if(mCooldown && mEnergy >= 15.f) + { + mCooldown = false; + } + + if(mShield) + { + mEnergy -= 7.0f * scaleFactor; + } + + if(mTurbo) + { + mEnergy -= 20.0f * scaleFactor; + } + + + if(mEnergy < 100.f) + { + mEnergy += (F32)(dT * RechargeRate) / 1000.f; + + if(mEnergy < 0.f) + mEnergy = 0.f; + } + + if(mEnergy >= 100.f) + mEnergy = 100.f; + } + void Ship::damageObject(DamageInfo *theInfo) { *************** *** 160,163 **** --- 218,228 ---- return; + // Factor in shields + if(mShield && mEnergy >= 10.f) + { + mEnergy -= 10.f; + return; + } + mHealth -= theInfo->damageAmount; setMaskBits(HealthMask); *************** *** 275,278 **** --- 340,344 ---- setMaskBits(PositionMask); } + burnEnergy(deltaT); updateExtent(); } *************** *** 286,289 **** --- 352,357 ---- stream->write(mMoveState[ActualState].vel.y); stream->write(mEnergy); + stream->writeFlag(mTurbo); + stream->writeFlag(mShield); } *************** *** 296,299 **** --- 364,369 ---- stream->read(&mMoveState[ActualState].vel.y); stream->read(&mEnergy); + mTurbo = stream->readFlag(); + mShield = stream->readFlag(); Point delta = mMoveState[ActualState].pos - mMoveState[RenderState].pos; *************** *** 334,337 **** --- 404,413 ---- stream->writeFloat(mHealth, 6); + if(stream->writeFlag(updateMask & PowersMask)) + { + stream->writeFlag(mTurbo); + stream->writeFlag(mShield); + } + stream->writeFlag(hasExploded); *************** *** 388,395 **** --- 464,479 ---- } } + if(stream->readFlag()) mHealth = stream->readFloat(6); + if(stream->readFlag()) + { + mTurbo = stream->readFlag(); + mShield = stream->readFlag(); + } + bool explode = stream->readFlag(); + if(stream->readFlag()) { *************** *** 625,630 **** if(leftId == mLastTrailPoint[0] && rightId == mLastTrailPoint[1]) { ! mTrail[0].update(leftPt); ! mTrail[1].update(rightPt); mLastTrailPoint[0] = leftId; mLastTrailPoint[1] = rightId; --- 709,714 ---- if(leftId == mLastTrailPoint[0] && rightId == mLastTrailPoint[1]) { ! mTrail[0].update(leftPt, mTurbo); ! mTrail[1].update(rightPt, mTurbo); mLastTrailPoint[0] = leftId; mLastTrailPoint[1] = rightId; *************** *** 632,637 **** else if(leftId == mLastTrailPoint[1] && rightId == mLastTrailPoint[0]) { ! mTrail[1].update(leftPt); ! mTrail[0].update(rightPt); mLastTrailPoint[1] = leftId; mLastTrailPoint[0] = rightId; --- 716,721 ---- else if(leftId == mLastTrailPoint[1] && rightId == mLastTrailPoint[0]) { ! mTrail[1].update(leftPt, mTurbo); ! mTrail[0].update(rightPt, mTurbo); mLastTrailPoint[1] = leftId; mLastTrailPoint[0] = rightId; *************** *** 639,644 **** else { ! mTrail[0].update(leftPt); ! mTrail[1].update(rightPt); mLastTrailPoint[0] = leftId; mLastTrailPoint[1] = rightId; --- 723,728 ---- else { ! mTrail[0].update(leftPt, mTurbo); ! mTrail[1].update(rightPt, mTurbo); mLastTrailPoint[0] = leftId; mLastTrailPoint[1] = rightId; *************** *** 652,658 **** return; - for(U32 i=0; i<TrailCount; i++) - mTrail[i].render(); - if(posSegments.size()) { --- 736,739 ---- *************** *** 725,728 **** --- 806,815 ---- thrusts[3] += 0.25; + if(mTurbo) + { + for(U32 i = 0; i < 4; i++) + thrusts[i] *= 1.3; + } + // first render the thrusters *************** *** 825,828 **** --- 912,916 ---- glVertex2f(12.5, 0); glEnd(); + glColor4f(color.r,color.g,color.b, alpha); glBegin(GL_LINE_LOOP); *************** *** 831,834 **** --- 919,923 ---- glVertex2f(12, -13); glEnd(); + U32 health = 14 * mHealth; glBegin(GL_LINES); *************** *** 848,851 **** --- 937,951 ---- glEnd(); + // Render shield if appropriate + if(mShield) + { + glColor4f(1,1,0, alpha); + glBegin(GL_LINE_LOOP); + glVertex2f(-23, -18); + glVertex2f(0, 27); + glVertex2f(23, -18); + glEnd(); + } + if(hasExploded) { *************** *** 854,857 **** --- 954,958 ---- } + glPopMatrix(); *************** *** 862,864 **** } ! }; \ No newline at end of file --- 963,965 ---- } ! }; |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 21:36:14
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12265/zap Modified Files: UICredits.cpp UICredits.h Log Message: Added Zap title and GarageGames.com coypright notice to the credits. Index: UICredits.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UICredits.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UICredits.cpp 30 Apr 2004 06:55:52 -0000 1.1 --- UICredits.cpp 30 Apr 2004 21:36:05 -0000 1.2 *************** *** 98,110 **** void CreditsScroller::updateFX(U32 delta) { // scroll the credits text from bottom to top // based on time for(S32 i = 0; i < credits.size(); i++) { ! S32 pos = credits[i].currPos.x - (delta / 10); // reached the top, reset if(pos < -CreditSpace) ! pos = gCreditsUserInterface.canvasHeight + CreditSpace * 3; credits[i].currPos.x = pos; --- 98,116 ---- void CreditsScroller::updateFX(U32 delta) { + // draw the project information + S32 pos = mProjectInfo.currPos.x - (delta / 10); + if(pos < -CreditSpace) + pos = (UserInterface::canvasHeight * 2) + CreditSpace; + mProjectInfo.currPos.x = pos; + // scroll the credits text from bottom to top // based on time for(S32 i = 0; i < credits.size(); i++) { ! pos = credits[i].currPos.x - (delta / 10); // reached the top, reset if(pos < -CreditSpace) ! pos = (UserInterface::canvasHeight * 2) + CreditSpace; credits[i].currPos.x = pos; *************** *** 114,123 **** void CreditsScroller::render() { - // draw the credits text glColor3f(1,1,1); for(S32 i = 0; i < credits.size(); i++) { ! gCreditsUserInterface.drawCenteredString(credits[i].currPos.x, 25, credits[i].jobBuf); ! gCreditsUserInterface.drawCenteredString(credits[i].currPos.x + 50, 25, credits[i].nameBuf); } } --- 120,136 ---- void CreditsScroller::render() { glColor3f(1,1,1); + + // draw the project information + glLineWidth(10); + UserInterface::drawCenteredString(mProjectInfo.currPos.x, 100, mProjectInfo.titleBuf); + glLineWidth(1); + UserInterface::drawCenteredString(mProjectInfo.currPos.x + 120, 20, mProjectInfo.copyBuf); + + // draw the credits text for(S32 i = 0; i < credits.size(); i++) { ! UserInterface::drawCenteredString(credits[i].currPos.x, 25, credits[i].jobBuf); ! UserInterface::drawCenteredString(credits[i].currPos.x + 50, 25, credits[i].nameBuf); } } *************** *** 130,136 **** return; ! char name[MaxCreditLen]; ! char job[MaxCreditLen]; ! S32 pos = gCreditsUserInterface.canvasHeight + CreditSpace; // loop through each line in the credits file, expecting --- 143,150 ---- return; ! // read project information from the credits file ! fgets(mProjectInfo.titleBuf, MaxCreditLen, f); ! fgets(mProjectInfo.copyBuf, MaxCreditLen, f); ! mProjectInfo.currPos.x = (UserInterface::canvasHeight - 100) / 2; // loop through each line in the credits file, expecting *************** *** 138,141 **** --- 152,156 ---- // 1) job // 2) name + S32 pos = (UserInterface::canvasHeight + CreditSpace); while(!feof(f)) { *************** *** 143,152 **** // get job ! fgets(job, MaxCreditLen, f); ! strcpy(c.jobBuf, job); // get name ! fgets(name, MaxCreditLen, f); ! strcpy(c.nameBuf, name); // place credit in cache --- 158,165 ---- // get job ! fgets(c.jobBuf, MaxCreditLen, f); // get name ! fgets(c.nameBuf, MaxCreditLen, f); // place credit in cache Index: UICredits.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UICredits.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** UICredits.h 30 Apr 2004 07:16:00 -0000 1.2 --- UICredits.h 30 Apr 2004 21:36:05 -0000 1.3 *************** *** 52,58 **** enum Credits { MaxCreditLen = 32, ! CreditSpace = 200 }; ! struct CreditsInfo { char nameBuf[MaxCreditLen+1]; --- 52,63 ---- enum Credits { MaxCreditLen = 32, ! CreditSpace = 200, }; ! ! struct ProjectInfo { ! char titleBuf[MaxCreditLen+1]; ! char copyBuf[MaxCreditLen+1]; ! Point currPos; ! } mProjectInfo; struct CreditsInfo { char nameBuf[MaxCreditLen+1]; |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 21:36:14
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12265/exe Modified Files: credits.txt Log Message: Added Zap title and GarageGames.com coypright notice to the credits. Index: credits.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/credits.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** credits.txt 30 Apr 2004 06:56:50 -0000 1.1 --- credits.txt 30 Apr 2004 21:36:05 -0000 1.2 *************** *** 1,2 **** --- 1,4 ---- + Z A P + (c) 2004 GarageGames.com Lead Programmer Mark Frohnmayer *************** *** 4,6 **** John Quigley Programmer and Sound Effects ! Ben Garney \ No newline at end of file --- 6,10 ---- John Quigley Programmer and Sound Effects ! Ben Garney ! Programmer ! Robert Blanchet \ No newline at end of file |
From: Mark F. <mar...@us...> - 2004-04-30 20:27:53
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31349/zap Modified Files: CTFGame.cpp CTFGame.h ZAP.vcproj barrier.cpp game.cpp game.h gameConnection.h gameObject.h gameType.cpp gameType.h item.cpp moveObject.cpp point.h ship.cpp ship.h teleporter.cpp Added Files: soccerGame.cpp soccerGame.h Log Message: Added Soccer game type Index: moveObject.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/moveObject.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** moveObject.cpp 22 Apr 2004 05:22:32 -0000 1.5 --- moveObject.cpp 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 226,229 **** --- 226,234 ---- if((cp - mMoveState[stateIndex].pos).dot(mMoveState[stateIndex].vel) > velocityEpsilon) { + bool collide1 = collide(fillVector[i]); + bool collide2 = fillVector[i]->collide(this); + + if(!(collide1 && collide2)) + continue; collisionPoint = cp; delta *= collisionFraction; *************** *** 255,259 **** if(p.len() <= R) { ! if(!(collide(otherShip) && otherShip->collide(this))) continue; --- 260,267 ---- if(p.len() <= R) { ! bool collide1 = collide(otherShip); ! bool collide2 = otherShip->collide(this); ! ! if(!(collide1 && collide2)) continue; *************** *** 270,274 **** if(FindLowestRootInInterval(a, b, c, collisionTime, t)) { ! if(!(collide(otherShip) && otherShip->collide(this))) continue; --- 278,285 ---- if(FindLowestRootInInterval(a, b, c, collisionTime, t)) { ! bool collide1 = collide(otherShip); ! bool collide2 = otherShip->collide(this); ! ! if(!(collide1 && collide2)) continue; Index: gameType.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** gameType.cpp 28 Apr 2004 00:30:53 -0000 1.14 --- gameType.cpp 30 Apr 2004 20:27:41 -0000 1.15 *************** *** 349,354 **** --- 349,394 ---- } + Vector<RangedU32<0, GameType::MaxPing> > GameType::mPingTimes; ///< Static vector used for constructing update RPCs + Vector<Int<24> > GameType::mScores; + void GameType::updateClientScoreboard(S32 clientIndex) { + mPingTimes.clear(); + mScores.clear(); + + for(S32 i = 0; i < mClientList.size(); i++) + { + if(mClientList[i].ping < MaxPing) + mPingTimes.push_back(mClientList[i].ping); + else + mPingTimes.push_back(MaxPing); + mScores.push_back(mClientList[i].score); + } + + NetObject::setRPCDestConnection(mClientList[clientIndex].clientConnection); + s2cScoreboardUpdate(mPingTimes, mScores); + NetObject::setRPCDestConnection(NULL); + } + + TNL_DECLARE_RPC_MEM_ENUM(GameType, MaxPing); + + TNL_IMPLEMENT_NETOBJECT_RPC(GameType, s2cScoreboardUpdate, (const Vector<RangedU32<0, GameType::MaxPing> > &pingTimes, const Vector<Int<24> > &scores), + NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) + { + for(S32 i = 0; i < mClientList.size(); i++) + { + if(i >= pingTimes.size()) + break; + + mClientList[i].ping = pingTimes[i]; + mClientList[i].score = scores[i]; + } + } + + TNL_IMPLEMENT_NETOBJECT_RPC(GameType, s2cKillMessage, (StringTableEntry victim, StringTableEntry killer), + NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) + { + gGameUserInterface.displayMessage(Color(1.0f, 1.0f, 0.8f), + "%s zapped %s", killer.getString(), victim.getString()); } --- NEW FILE: soccerGame.cpp --- //----------------------------------------------------------------------------------- // // Torque Network Library - ZAP example multiplayer vector graphics space game // Copyright (C) 2004 GarageGames.com, Inc. // For more information see http://www.opentnl.org // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // For use in products that are not compatible with the terms of the GNU // General Public License, alternative licensing options are available // from GarageGames.com. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //------------------------------------------------------------------------------------ #include "soccerGame.h" #include "glutInclude.h" #include "UIGame.h" #include "sfx.h" #include "gameNetInterface.h" #include "ship.h" namespace Zap { class Ship; class SoccerBallItem; extern void renderFlag(Point pos, Color c); TNL_IMPLEMENT_NETOBJECT(SoccerGameType); void SoccerGameType::renderInterfaceOverlay(bool scoreboardVisible) { if(scoreboardVisible) { U32 totalWidth = 780; U32 teamWidth = totalWidth / mTeams.size(); U32 maxTeamPlayers = 0; countTeamPlayers(); for(S32 i = 0; i < mTeams.size(); i++) if(mTeams[i].numPlayers > maxTeamPlayers) maxTeamPlayers = mTeams[i].numPlayers; U32 totalHeight = 580; U32 maxHeight = (totalHeight - 40) / maxTeamPlayers; if(maxHeight > 30) maxHeight = 30; totalHeight = 40 + maxHeight * maxTeamPlayers; U32 yt = (600 - totalHeight) / 2; U32 yb = yt + totalHeight; for(S32 i = 0; i < mTeams.size(); i++) { U32 xl = 10 + i * teamWidth; U32 xr = xl + teamWidth - 2; Color c = mTeams[i].color; glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(c.r, c.g, c.b, 0.6); glBegin(GL_POLYGON); glVertex2f(xl, yt); glVertex2f(xr, yt); glVertex2f(xr, yb); glVertex2f(xl, yb); glEnd(); glDisable(GL_BLEND); glBlendFunc(GL_ONE, GL_ZERO); renderFlag(Point(xl + 20, yt + 18), c); renderFlag(Point(xr - 20, yt + 18), c); glColor3f(1,1,1); glBegin(GL_LINES); glVertex2f(xl, yt + 40); glVertex2f(xr, yt + 40); glEnd(); UserInterface::drawString(xl + 40, yt + 2, 30, mTeams[i].name.getString()); UserInterface::drawStringf(xr - 140, yt + 2, 30, "%d", mTeams[i].score); U32 curRowY = yt + 41; U32 fontSize = maxHeight * 0.8f; for(S32 j = 0; j < mClientList.size(); j++) { if(mClientList[j].teamId == i) { UserInterface::drawString(xl + 40, curRowY, fontSize, mClientList[j].name.getString()); static char buff[255] = ""; dSprintf(buff, sizeof(buff), "%d", mClientList[j].score); UserInterface::drawString(xr - (120 + UserInterface::getStringWidth(fontSize, buff)), curRowY, fontSize, buff); UserInterface::drawStringf(xr - 70, curRowY, fontSize, "%d", mClientList[j].ping); curRowY += maxHeight; } } } } else { for(S32 i = 0; i < mTeams.size(); i++) { Point pos(750, 550 - i * 38); renderFlag(pos + Point(-20, 18), mTeams[i].color); glColor3f(1,1,1); UserInterface::drawStringf(pos.x, pos.y, 32, "%d", mTeams[i].score); } } } void SoccerGameType::controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject) { GameConnection *killer = killerObject ? killerObject->getControllingClient() : NULL; S32 killerIndex = findClientIndexByConnection(killer); S32 clientIndex = findClientIndexByConnection(theClient); if(killerIndex != -1) { // Punish team killers slightly if(mClientList[killerIndex].teamId == mClientList[clientIndex].teamId) mClientList[killerIndex].score -= KillScore/4; else mClientList[killerIndex].score += KillScore; s2cKillMessage(mClientList[clientIndex].name, mClientList[killerIndex].name); } mClientList[clientIndex].respawnDelay = RespawnDelay; } bool SoccerGameType::objectCanDamageObject(GameObject *damager, GameObject *victim) { GameConnection *c1 = (damager ? damager->getControllingClient() : NULL); GameConnection *c2 = (victim ? victim->getControllingClient() : NULL); if(!c1 || !c2) return true; return mClientList[findClientIndexByConnection(c1)].teamId != mClientList[findClientIndexByConnection(c2)].teamId; } TNL_IMPLEMENT_NETOBJECT_RPC(SoccerGameType, s2cSoccerScoreMessage, (StringTableEntry clientName, U32 teamIndex), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) { gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), "%s scored a goal for team %s!", clientName.getString(), mTeams[teamIndex].name.getString()); SFXObject::play(SFXFlagCapture); } void SoccerGameType::scoreGoal(StringTableEntry playerName, U32 goalTeamIndex) { s2cSoccerScoreMessage(playerName, goalTeamIndex); } TNL_IMPLEMENT_NETOBJECT(SoccerBallItem); SoccerBallItem::SoccerBallItem(Point pos) : Item(pos, true, 30, 4) { mObjectTypeMask |= CommandMapVisType; mNetFlags.set(Ghostable); initialPos = pos; sendHomeTime = 0; } void SoccerBallItem::processArguments(S32 argc, const char **argv) { Parent::processArguments(argc, argv); initialPos = mMoveState[ActualState].pos; } void SoccerBallItem::renderItem(Point pos) { glPushMatrix(); glTranslatef(pos.x, pos.y, 0); glColor3f(1, 1, 1); glBegin(GL_LINE_LOOP); for(F32 theta = 0; theta < 2 * 3.1415; theta += 0.2) glVertex2f(cos(theta) * mRadius, sin(theta) * mRadius); glEnd(); glPopMatrix(); } void SoccerBallItem::processServer(U32 deltaT) { Parent::processServer(deltaT); if(sendHomeTime) { if(sendHomeTime > deltaT) sendHomeTime -= deltaT; else { sendHomeTime = 0; sendHome(); } } } void SoccerBallItem::damageObject(DamageInfo *theInfo) { // compute impulse direction Point dv = theInfo->impulseVector - mMoveState[ActualState].vel; Point iv = mMoveState[ActualState].pos - theInfo->collisionPoint; iv.normalize(); mMoveState[ActualState].vel += iv * dv.dot(iv) * 0.3; if(theInfo->damagingObject && (theInfo->damagingObject->getObjectTypeMask() & ShipType)) { lastPlayerTouch = ((Ship *) theInfo->damagingObject)->mPlayerName; } } void SoccerBallItem::sendHome() { mMoveState[ActualState].vel = mMoveState[RenderState].vel = Point(); mMoveState[ActualState].pos = mMoveState[RenderState].pos = initialPos; setMaskBits(PositionMask); updateExtent(); } bool SoccerBallItem::collide(GameObject *hitObject) { if(isGhost()) return true; if(hitObject->getObjectTypeMask() & ShipType) { lastPlayerTouch = ((Ship *) hitObject)->mPlayerName; } else { SoccerGoalObject *goal = dynamic_cast<SoccerGoalObject *>(hitObject); if(goal && sendHomeTime == 0) { SoccerGameType *g = (SoccerGameType *) getGame()->getGameType(); g->scoreGoal(lastPlayerTouch, goal->getTeamIndex()); sendHomeTime = 1500; } } return true; } TNL_IMPLEMENT_NETOBJECT(SoccerGoalObject); SoccerGoalObject::SoccerGoalObject() { teamIndex = 0; mObjectTypeMask |= CommandMapVisType; mNetFlags.set(Ghostable); } void SoccerGoalObject::onAddedToGame(Game *theGame) { if(!isGhost()) { setInterface(theGame->getNetInterface()); setScopeAlways(); } } void SoccerGoalObject::render() { F32 alpha = 0.5; Color theColor = getGame()->getGameType()->mTeams[teamIndex].color; glColor3f(theColor.r * alpha, theColor.g * alpha, theColor.b * alpha); glBegin(GL_POLYGON); for(S32 i = 0; i < mPolyBounds.size(); i++) glVertex2f(mPolyBounds[i].x, mPolyBounds[i].y); glEnd(); } bool SoccerGoalObject::getCollisionPoly(Vector<Point> &polyPoints) { for(S32 i = 0; i < mPolyBounds.size(); i++) polyPoints.push_back(mPolyBounds[i]); return true; } void SoccerGoalObject::processArguments(S32 argc, const char **argv) { if(argc < 7) return; teamIndex = atoi(argv[0]); for(S32 i = 1; i < argc; i += 2) { Point p; p.x = atof(argv[i]) * getGame()->getGridSize(); p.y = atof(argv[i+1]) * getGame()->getGridSize(); mPolyBounds.push_back(p); } computeExtent(); } void SoccerGoalObject::computeExtent() { Rect extent(mPolyBounds[0], mPolyBounds[0]); for(S32 i = 1; i < mPolyBounds.size(); i++) extent.unionPoint(mPolyBounds[i]); setExtent(extent); } bool SoccerGoalObject::collide(GameObject *hitObject) { return false; } U32 SoccerGoalObject::packUpdate(GhostConnection *connection, U32 updateMask, BitStream *stream) { stream->write(teamIndex); stream->writeRangedU32(mPolyBounds.size(), 0, MaxPoints); for(S32 i = 0; i < mPolyBounds.size(); i++) { stream->write(mPolyBounds[i].x); stream->write(mPolyBounds[i].y); } return 0; } void SoccerGoalObject::unpackUpdate(GhostConnection *connection, BitStream *stream) { stream->read(&teamIndex); S32 size = stream->readRangedU32(0, MaxPoints); for(S32 i = 0; i < size; i++) { Point p; stream->read(&p.x); stream->read(&p.y); mPolyBounds.push_back(p); } if(size) computeExtent(); } }; Index: teleporter.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/teleporter.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** teleporter.cpp 20 Apr 2004 19:25:49 -0000 1.3 --- teleporter.cpp 30 Apr 2004 20:27:42 -0000 1.4 *************** *** 49,52 **** --- 49,53 ---- r.expand(Point(TeleporterRadius, TeleporterRadius)); setExtent(r); + mObjectTypeMask |= CommandMapVisType; } Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** game.h 27 Apr 2004 21:43:04 -0000 1.9 --- game.h 30 Apr 2004 20:27:41 -0000 1.10 *************** *** 104,117 **** SafePtr<MasterServerConnection> mConnectionToMaster; SafePtr<GameType> mGameType; - - enum { - NumStars = 2048, - }; - Point mStars[NumStars]; - public: enum { - WorldSize = 4096, DefaultGridSize = 256, PlayerHorizVisDistance = 600, --- 104,110 ---- *************** *** 171,174 **** --- 164,172 ---- class ClientGame : public Game { + enum { + NumStars = 256, + }; + Point mStars[NumStars]; + SafePtr<GameConnection> mConnectionToServer; // If this is a client game, this is the connection to the server bool mInCommanderMap; *************** *** 184,187 **** --- 182,186 ---- void setConnectionToServer(GameConnection *connection); + void drawStars(F32 alphaFrac, Point cameraPos, Point visibleExtent); GameConnection *getConnectionToServer(); void render(); *************** *** 201,205 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.1.2" }; --- 200,204 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.1.3" }; Index: game.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** game.cpp 27 Apr 2004 23:27:51 -0000 1.13 --- game.cpp 30 Apr 2004 20:27:41 -0000 1.14 *************** *** 62,72 **** mLastIdleTime = Platform::getRealMilliseconds(); - // create random stars - for(U32 i = 0; i < NumStars; i++) - { - mStars[i].x = Random::readF() * WorldSize; - mStars[i].y = Random::readF() * WorldSize; - } - mNetInterface = new GameNetInterface(theBindAddress, this); } --- 62,65 ---- *************** *** 244,247 **** --- 237,246 ---- mInCommanderMap = false; mCommanderZoomDelta = 0; + // create random stars + for(U32 i = 0; i < NumStars; i++) + { + mStars[i].x = Random::readF(); + mStars[i].y = Random::readF(); + } } *************** *** 338,341 **** --- 337,382 ---- } + void ClientGame::drawStars(F32 alphaFrac, Point cameraPos, Point visibleExtent) + { + F32 starChunkSize = 1024; + + Point upperLeft = cameraPos - visibleExtent * 0.5f; + Point lowerRight = cameraPos + visibleExtent * 0.5f; + + upperLeft *= 1 / starChunkSize; + lowerRight *= 1 / starChunkSize; + + upperLeft.x = floor(upperLeft.x); + upperLeft.y = floor(upperLeft.y); + + lowerRight.x = floor(lowerRight.x) + 0.5; + lowerRight.y = floor(lowerRight.y) + 0.5; + + // render the stars + glPointSize( 1.0f ); + glColor3f(0.8 * alphaFrac, 0.8 * alphaFrac, 1.0 * alphaFrac); + + glPointSize(1); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, sizeof(Point), &mStars[0]); + + for(F32 xPage = upperLeft.x; xPage < lowerRight.x; xPage++) + { + for(F32 yPage = upperLeft.y; yPage < lowerRight.y; yPage++) + { + glPushMatrix(); + glScalef(starChunkSize, starChunkSize, 1); + glTranslatef(xPage, yPage, 0); + //glTranslatef(-xPage * starChunkSize, -yPage * starChunkSize, 0); + glDrawArrays(GL_POINTS, 0, NumStars); + glPopMatrix(); + } + } + + glDisableClientState(GL_VERTEX_ARRAY); + } + + + void ClientGame::renderCommander() { *************** *** 368,386 **** glTranslatef(-offset.x, -offset.y, 0); ! //glScalef(UserInterface::canvasHeight / worldExtents.x, UserInterface::canvasHeight / worldExtents.y, 0); ! //glTranslatef(-worldCenter.x, -worldCenter.y, 0); ! ! // render the stars, but only 1/8th of them so the screen isn't overcrowded. ! glPointSize( 1.0f ); ! glColor3f(0.8, 0.8, 1.0); ! ! // glEnableClientState(GL_VERTEX_ARRAY); ! // glVertexPointer(2, GL_FLOAT, 8*sizeof(Point), &mStars[0]); ! // glDrawArrays(GL_POINTS, 0, NumStars/8); ! // glDisableClientState(GL_VERTEX_ARRAY); // render the objects Vector<GameObject *> renderObjects; ! mDatabase.findObjects(BarrierType | ShipType | ItemType, renderObjects, worldBounds); // Deal with rendering sensor volumes --- 409,418 ---- glTranslatef(-offset.x, -offset.y, 0); ! if(zoomFrac < 0.95) ! drawStars(1 - zoomFrac, offset, modVisSize); // render the objects Vector<GameObject *> renderObjects; ! mDatabase.findObjects( CommandMapVisType, renderObjects, worldBounds); // Deal with rendering sensor volumes *************** *** 447,458 **** glTranslatef(-position.x, -position.y, 0); ! // render the stars ! glPointSize( 1.0f ); ! glColor3f(0.8, 0.8, 1.0); ! ! glEnableClientState(GL_VERTEX_ARRAY); ! glVertexPointer(2, GL_FLOAT, sizeof(Point), &mStars[0]); ! glDrawArrays(GL_POINTS, 0, NumStars); ! glDisableClientState(GL_VERTEX_ARRAY); // render the objects --- 479,483 ---- glTranslatef(-position.x, -position.y, 0); ! drawStars(1.0, position, Point(PlayerHorizVisDistance * 2, PlayerVertVisDistance * 2)); // render the objects Index: CTFGame.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CTFGame.h 23 Apr 2004 01:49:46 -0000 1.5 --- CTFGame.h 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 50,54 **** void shipTouchFlag(Ship *theShip, CTFFlagItem *theFlag); void renderInterfaceOverlay(bool scoreboardVisible); - void updateClientScoreboard(S32 clientIndex); void controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject); void controlObjectForClientRemoved(GameConnection *theClient, GameObject *clientObject); --- 50,53 ---- *************** *** 58,68 **** enum { - MaxPing = 999, - }; - - static Vector<RangedU32<0, MaxPing> > mPingTimes; ///< Static vector used for constructing update RPCs - static Vector<Int<24> > mScores; - - enum { CTFMsgReturnFlag, CTFMsgCaptureFlag, --- 57,60 ---- *************** *** 72,77 **** TNL_DECLARE_RPC(s2cCTFMessage, (U32 messageIndex, StringTableEntry clientName, U32 teamIndex)); - TNL_DECLARE_RPC(s2cKillMessage, (StringTableEntry victim, StringTableEntry killer)); - TNL_DECLARE_RPC(s2cScoreboardUpdate, (const Vector<RangedU32<0, MaxPing> > &pingTimes, const Vector<Int<24> > &scores)); TNL_DECLARE_CLASS(CTFGameType); }; --- 64,67 ---- Index: barrier.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/barrier.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** barrier.cpp 27 Apr 2004 20:41:53 -0000 1.5 --- barrier.cpp 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 111,115 **** Barrier::Barrier(Point st, Point e) { ! mObjectTypeMask = BarrierType; mNetFlags.set(Ghostable); start = st; --- 111,115 ---- Barrier::Barrier(Point st, Point e) { ! mObjectTypeMask = BarrierType | CommandMapVisType; mNetFlags.set(Ghostable); start = st; Index: gameConnection.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameConnection.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gameConnection.h 26 Apr 2004 07:36:06 -0000 1.5 --- gameConnection.h 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 88,91 **** --- 88,93 ---- float angle; bool fire; + bool boost; + bool shield; U32 time; *************** *** 94,98 **** }; ! Move() { left = right = up = down = angle = 0; fire = false; time = 32; } bool isEqualMove(Move *prev) --- 96,100 ---- }; ! Move() { left = right = up = down = angle = 0; boost = shield = fire = false; time = 32; } bool isEqualMove(Move *prev) *************** *** 103,107 **** prev->down == down && prev->angle == angle && ! prev->fire == fire; } --- 105,111 ---- prev->down == down && prev->angle == angle && ! prev->fire == fire && ! prev->boost == boost && ! prev->shield == shield; } *************** *** 118,121 **** --- 122,127 ---- stream->writeInt(writeAngle, 12); stream->writeFlag(fire); + stream->writeFlag(boost); + stream->writeFlag(shield); } stream->writeRangedU32(time, 0, MaxMoveTime); *************** *** 131,134 **** --- 137,142 ---- angle = unitToRadians(stream->readInt(12) / F32(0xFFF)); fire = stream->readFlag(); + boost = stream->readFlag(); + shield = stream->readFlag(); } time = stream->readRangedU32(0, MaxMoveTime); Index: gameObject.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameObject.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** gameObject.h 27 Apr 2004 20:41:53 -0000 1.3 --- gameObject.h 30 Apr 2004 20:27:41 -0000 1.4 *************** *** 48,51 **** --- 48,52 ---- ItemType = 1 << 5, + CommandMapVisType = 1 << 31, AllObjectTypes = 0xFFFFFFFF, }; Index: ship.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ship.h 30 Apr 2004 08:33:20 -0000 1.10 --- ship.h 30 Apr 2004 20:27:42 -0000 1.11 *************** *** 72,75 **** --- 72,78 ---- U32 lastFireTime; F32 mHealth; + F32 mEnergy; + bool mShieldActive; + StringTableEntry mPlayerName; Index: CTFGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.cpp,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CTFGame.cpp 30 Apr 2004 08:33:20 -0000 1.16 --- CTFGame.cpp 30 Apr 2004 20:27:41 -0000 1.17 *************** *** 36,40 **** { ! static void renderFlag(Point pos, Color c) { glPushMatrix(); --- 36,40 ---- { ! void renderFlag(Point pos, Color c) { glPushMatrix(); *************** *** 149,189 **** } - Vector<RangedU32<0, CTFGameType::MaxPing> > CTFGameType::mPingTimes; ///< Static vector used for constructing update RPCs - Vector<Int<24> > CTFGameType::mScores; - - void CTFGameType::updateClientScoreboard(S32 clientIndex) - { - mPingTimes.clear(); - mScores.clear(); - - for(S32 i = 0; i < mClientList.size(); i++) - { - if(mClientList[i].ping < MaxPing) - mPingTimes.push_back(mClientList[i].ping); - else - mPingTimes.push_back(MaxPing); - mScores.push_back(mClientList[i].score); - } - - NetObject::setRPCDestConnection(mClientList[clientIndex].clientConnection); - s2cScoreboardUpdate(mPingTimes, mScores); - NetObject::setRPCDestConnection(NULL); - } - - TNL_DECLARE_RPC_MEM_ENUM(CTFGameType, MaxPing); - - TNL_IMPLEMENT_NETOBJECT_RPC(CTFGameType, s2cScoreboardUpdate, (const Vector<RangedU32<0, CTFGameType::MaxPing> > &pingTimes, const Vector<Int<24> > &scores), - NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) - { - for(S32 i = 0; i < mClientList.size(); i++) - { - if(i >= pingTimes.size()) - break; - - mClientList[i].ping = pingTimes[i]; - mClientList[i].score = scores[i]; - } - } - void CTFGameType::shipTouchFlag(Ship *theShip, CTFFlagItem *theFlag) { --- 149,152 ---- *************** *** 305,343 **** } - static const char *CTFMessages[] = - { - "%s returned the %s flag.", - "%s captured the %s flag!", - "%s took the %s flag!", - "%s dropped the %s flag!", - }; - - static U32 CTFFlagSounds[] = - { - SFXFlagReturn, - SFXFlagCapture, - SFXFlagSnatch, - SFXFlagDrop, - }; - TNL_IMPLEMENT_NETOBJECT_RPC(CTFGameType, s2cCTFMessage, (U32 messageIndex, StringTableEntry clientName, U32 teamIndex), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) { ! S32 clientIndex = findClientIndexByName(clientName); gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), CTFMessages[messageIndex], ! mClientList[clientIndex].name.getString(), mTeams[teamIndex].name.getString()); SFXObject::play(CTFFlagSounds[messageIndex]); } - TNL_IMPLEMENT_NETOBJECT_RPC(CTFGameType, s2cKillMessage, (StringTableEntry victim, StringTableEntry killer), - NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) - { - gGameUserInterface.displayMessage(Color(1.0f, 1.0f, 0.8f), - "%s zapped %s", killer.getString(), victim.getString()); - } - TNL_IMPLEMENT_NETOBJECT(CTFFlagItem); --- 268,297 ---- } TNL_IMPLEMENT_NETOBJECT_RPC(CTFGameType, s2cCTFMessage, (U32 messageIndex, StringTableEntry clientName, U32 teamIndex), NetClassGroupGameMask, RPCGuaranteedOrdered, RPCToGhost, 0) { ! static const char *CTFMessages[] = ! { ! "%s returned the %s flag.", ! "%s captured the %s flag!", ! "%s took the %s flag!", ! "%s dropped the %s flag!", ! }; ! ! static U32 CTFFlagSounds[] = ! { ! SFXFlagReturn, ! SFXFlagCapture, ! SFXFlagSnatch, ! SFXFlagDrop, ! }; gGameUserInterface.displayMessage(Color(0.6f, 1.0f, 0.8f), CTFMessages[messageIndex], ! clientName.getString(), mTeams[teamIndex].name.getString()); SFXObject::play(CTFFlagSounds[messageIndex]); } TNL_IMPLEMENT_NETOBJECT(CTFFlagItem); *************** *** 346,349 **** --- 300,304 ---- teamIndex = 0; mNetFlags.set(Ghostable); + mObjectTypeMask |= CommandMapVisType; } Index: gameType.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gameType.h 27 Apr 2004 21:37:54 -0000 1.5 --- gameType.h 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 69,72 **** --- 69,79 ---- U32 mTimeUntilScoreboardUpdate; + enum { + MaxPing = 999, + }; + + static Vector<RangedU32<0, MaxPing> > mPingTimes; ///< Static vector used for constructing update RPCs + static Vector<Int<24> > mScores; + GameType(); void countTeamPlayers(); *************** *** 115,118 **** --- 122,128 ---- TNL_DECLARE_RPC(s2cDisplayChatMessage, (bool global, StringTableEntry clientName, const char *message)); + TNL_DECLARE_RPC(s2cKillMessage, (StringTableEntry victim, StringTableEntry killer)); + TNL_DECLARE_RPC(s2cScoreboardUpdate, (const Vector<RangedU32<0, MaxPing> > &pingTimes, const Vector<Int<24> > &scores)); + TNL_DECLARE_RPC(c2sRequestScoreboardUpdates, (bool updates)); Index: point.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/point.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** point.h 27 Apr 2004 20:41:53 -0000 1.5 --- point.h 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 113,116 **** --- 113,128 ---- } + void unionPoint(const Point &p) + { + if(p.x < min.x) + min.x = p.x; + else if(p.x > max.x) + max.x = p.x; + if(p.y < min.y) + min.y = p.y; + else if(p.y > max.y) + max.y = p.y; + } + void unionRect(const Rect &r) { Index: item.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/item.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** item.cpp 23 Apr 2004 01:49:46 -0000 1.5 --- item.cpp 30 Apr 2004 20:27:41 -0000 1.6 *************** *** 38,42 **** mIsCollideable = collideable; mInterpTime = 0; ! mObjectTypeMask = MoveableType | ItemType; } --- 38,42 ---- mIsCollideable = collideable; mInterpTime = 0; ! mObjectTypeMask = MoveableType | ItemType | CommandMapVisType; } Index: ZAP.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ZAP.vcproj,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ZAP.vcproj 30 Apr 2004 10:26:25 -0000 1.9 --- ZAP.vcproj 30 Apr 2004 20:27:41 -0000 1.10 *************** *** 223,226 **** --- 223,229 ---- </File> <File + RelativePath="..\exe\README.txt"> + </File> + <File RelativePath=".\sfx.cpp"> </File> *************** *** 235,238 **** --- 238,247 ---- </File> <File + RelativePath=".\soccerGame.cpp"> + </File> + <File + RelativePath=".\soccerGame.h"> + </File> + <File RelativePath=".\sparkManager.cpp"> </File> --- NEW FILE: soccerGame.h --- //----------------------------------------------------------------------------------- // // Torque Network Library - ZAP example multiplayer vector graphics space game // Copyright (C) 2004 GarageGames.com, Inc. // For more information see http://www.opentnl.org // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // For use in products that are not compatible with the terms of the GNU // General Public License, alternative licensing options are available // from GarageGames.com. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //------------------------------------------------------------------------------------ #ifndef _SOCCERGAME_H_ #define _SOCCERGAME_H_ #include "gameType.h" #include "item.h" namespace Zap { class Ship; class SoccerBallItem; class SoccerGameType : public GameType { enum Scores { KillScore = 100, GoalScore = 500, }; public: void renderInterfaceOverlay(bool scoreboardVisible); void controlObjectForClientKilled(GameConnection *theClient, GameObject *clientObject, GameObject *killerObject); bool objectCanDamageObject(GameObject *damager, GameObject *victim); void scoreGoal(StringTableEntry playerName, U32 goalTeamIndex); enum { SoccerMsgScoreGoal, }; TNL_DECLARE_RPC(s2cSoccerScoreMessage, (StringTableEntry clientName, U32 teamIndex)); TNL_DECLARE_CLASS(SoccerGameType); }; class SoccerBallItem : public Item { typedef Item Parent; Point initialPos; U32 sendHomeTime; StringTableEntry lastPlayerTouch; public: SoccerBallItem(Point pos = Point()); void renderItem(Point pos); void sendHome(); void damageObject(DamageInfo *theInfo); void processServer(U32 deltaT); void processArguments(S32 argc, const char **argv); bool collide(GameObject *hitObject); TNL_DECLARE_CLASS(SoccerBallItem); }; class SoccerGoalObject : public GameObject { typedef GameObject Parent; Vector<Point> mPolyBounds; U32 teamIndex; enum { MaxPoints = 10, }; public: SoccerGoalObject(); U32 getTeamIndex() { return teamIndex; } void render(); void processArguments(S32 argc, const char **argv); void onAddedToGame(Game *theGame); void computeExtent(); bool getCollisionPoly(Vector<Point> &polyPoints); bool collide(GameObject *hitObject); U32 packUpdate(GhostConnection *connection, U32 mask, BitStream *stream); void unpackUpdate(GhostConnection *connection, BitStream *stream); TNL_DECLARE_CLASS(SoccerGoalObject); }; }; #endif Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ship.cpp 30 Apr 2004 08:33:20 -0000 1.18 --- ship.cpp 30 Apr 2004 20:27:41 -0000 1.19 *************** *** 48,52 **** Ship::Ship(StringTableEntry playerName, Point p, F32 m) : MoveObject(p, CollisionRadius) { ! mObjectTypeMask = ShipType | MoveableType; mNetFlags.set(Ghostable); --- 48,52 ---- Ship::Ship(StringTableEntry playerName, Point p, F32 m) : MoveObject(p, CollisionRadius) { ! mObjectTypeMask = ShipType | MoveableType | CommandMapVisType; mNetFlags.set(Ghostable); *************** *** 285,288 **** --- 285,289 ---- stream->write(mMoveState[ActualState].vel.x); stream->write(mMoveState[ActualState].vel.y); + stream->write(mEnergy); } *************** *** 294,298 **** stream->read(&mMoveState[ActualState].vel.x); stream->read(&mMoveState[ActualState].vel.y); ! Point delta = mMoveState[ActualState].pos - mMoveState[RenderState].pos; if(delta.len() > MaxControlObjectInterpDistance) --- 295,300 ---- stream->read(&mMoveState[ActualState].vel.x); stream->read(&mMoveState[ActualState].vel.y); ! stream->read(&mEnergy); ! Point delta = mMoveState[ActualState].pos - mMoveState[RenderState].pos; if(delta.len() > MaxControlObjectInterpDistance) |
From: Mark F. <mar...@us...> - 2004-04-30 20:27:50
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31349/tnl Modified Files: tnlTypes.h Log Message: Added Soccer game type Index: tnlTypes.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlTypes.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tnlTypes.h 20 Apr 2004 04:27:19 -0000 1.1 --- tnlTypes.h 30 Apr 2004 20:27:40 -0000 1.2 *************** *** 296,394 **** /// @{ ! /// Returns the lesser of the two parameters: a & b. ! inline U32 getMin(U32 a, U32 b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline U16 getMin(U16 a, U16 b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline U8 getMin(U8 a, U8 b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline S32 getMin(S32 a, S32 b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline S16 getMin(S16 a, S16 b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline S8 getMin(S8 a, S8 b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline float getMin(float a, float b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the lesser of the two parameters: a & b. ! inline double getMin(double a, double b) ! { ! return a>b ? b : a; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline U32 getMax(U32 a, U32 b) ! { ! return a>b ? a : b; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline U16 getMax(U16 a, U16 b) ! { ! return a>b ? a : b; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline U8 getMax(U8 a, U8 b) ! { ! return a>b ? a : b; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline S32 getMax(S32 a, S32 b) ! { ! return a>b ? a : b; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline S16 getMax(S16 a, S16 b) ! { ! return a>b ? a : b; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline S8 getMax(S8 a, S8 b) ! { ! return a>b ? a : b; ! } ! ! /// Returns the greater of the two parameters: a & b. ! inline float getMax(float a, float b) ! { ! return a>b ? a : b; ! } ! /// Returns the greater of the two parameters: a & b. ! inline double getMax(double a, double b) ! { ! return a>b ? a : b; ! } /// @} --- 296,311 ---- /// @{ ! #define DeclareTemplatizedMinMax(type) \ ! inline type getMin(type a, type b) { return a > b ? b : a; } \ ! inline type getMax(type a, type b) { return a > b ? a : b; } ! DeclareTemplatizedMinMax(U32) ! DeclareTemplatizedMinMax(S32) ! DeclareTemplatizedMinMax(U16) ! DeclareTemplatizedMinMax(S16) ! DeclareTemplatizedMinMax(U8) ! DeclareTemplatizedMinMax(S8) ! DeclareTemplatizedMinMax(F32) ! DeclareTemplatizedMinMax(F64) /// @} |
From: Mark F. <mar...@us...> - 2004-04-30 20:27:50
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31349/exe Modified Files: level3.txt Added Files: README.txt Log Message: Added Soccer game type Index: level3.txt =================================================================== RCS file: /cvsroot/opentnl/tnl/exe/level3.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** level3.txt 20 Apr 2004 04:27:12 -0000 1.1 --- level3.txt 30 Apr 2004 20:27:27 -0000 1.2 *************** *** 1,8 **** ! ! GameType Team Yellow 1 1 0 ! Spawn 0 0.5 0.5 ! BarrierMaker 0 0 8 0 8 1 0 1 0 0 ! Teleporter 7.5 0.5 0.5 0.5 \ No newline at end of file --- 1,14 ---- ! SoccerGameType Team Yellow 1 1 0 ! Team Green 0 1 0 ! BarrierMaker 0 1 5 1 5.5 0 6.5 0 7 1 12 1 12 4 9 6 9 10 12 12 12 15 7 15 6.5 16 5.5 16 5 15 0 15 0 12 3 10 3 6 0 4 0 1 ! ! Spawn 0 0.5 1.5 ! Spawn 1 7.5 7.5 ! ! SoccerBallItem 4 4 ! ! SoccerGoalObject 1 5.2 1 5.6 0.2 6.4 0.2 6.8 1 ! SoccerGoalObject 0 5 15 7 15 6.5 16 5.5 16 --- NEW FILE: README.txt --- ZAP 1.1.2 Welcome to ZAP, the retro multiplayer team action game! Controls: W - move up S - move down A - move left D - move right T - chat to team G - chat global C - toggle commander map TAB - show scores Mouse: Aim and fire with mouse button 1 In the game you can press ESC to go to the game options screen. From there you can access the main options which include setting full screen mode, enabling relative controls and on the Windows platform enabling dual analog controller support. Command Line Options: Note - zap addresses are of the form transport:address:port like: IP:127.0.0.1:28000 or IP:Any:28000 or IP:www.foobar.com:24601 -server [bindAddress] hosts a game server/client on the specified bind address. -connect [connectAddress] starts as a game client and attempts to connect to the server at the specified address. -master [masterAddress] specfies the address of the master server to connect to. -dedicated [bindAddress] starts Zap as a dedicated server -name [playerName] sets the client's name to the specified name and skips the name entry screen. -level [levelName] sets the specified level to load when hosting -hostname [hostname] sets the name that will appear in the server browser when searching for servers. -maxplayers [number] sets the maximum number of players allowed on the server Credits: ZAP is free software provided by GarageGames.com, Inc. Team members are: Mark Frohnmayer, Ben Garney, John Quigley |
From: Ben G. <s_a...@us...> - 2004-04-30 10:26:38
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5456/zap Modified Files: ZAP.vcproj Log Message: Fixed some project brokenness. Index: ZAP.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ZAP.vcproj,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ZAP.vcproj 30 Apr 2004 06:55:52 -0000 1.8 --- ZAP.vcproj 30 Apr 2004 10:26:25 -0000 1.9 *************** *** 271,280 **** </File> <File - RelativePath=".\UILevelEditor.cpp"> - </File> - <File - RelativePath=".\UILevelEditor.h"> - </File> - <File RelativePath=".\UIMenus.cpp"> </File> --- 271,274 ---- |
From: Ben G. <s_a...@us...> - 2004-04-30 08:33:41
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16526/zap Modified Files: CTFGame.cpp ship.cpp ship.h sparkManager.cpp sparkManager.h Log Message: Added fxTrail motion trail helper class. Added ship motion trails based on position/orientation of ship. Small cleanups. Index: sparkManager.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/sparkManager.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sparkManager.h 26 Apr 2004 05:22:43 -0000 1.2 --- sparkManager.h 30 Apr 2004 08:33:20 -0000 1.3 *************** *** 44,47 **** --- 44,76 ---- }; + class fxTrail + { + private: + struct TrailNode + { + Point pos; + S32 ttl; + }; + + Vector<TrailNode> mNodes; + + U32 mDropFreq; + U32 mLength; + + public: + fxTrail(U32 dropFrequency = 32, U32 len = 15); + + /// Update the point this trail is attached to. + void update(Point pos); + + void tick(U32 dT); + + void render(); + + void reset(); + + Point getLastPos(); + }; + }; Index: ship.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ship.h 27 Apr 2004 22:36:48 -0000 1.9 --- ship.h 30 Apr 2004 08:33:20 -0000 1.10 *************** *** 29,32 **** --- 29,33 ---- #include "moveObject.h" + #include "sparkManager.h" namespace Zap *************** *** 56,68 **** FireDelay = 100, MaxControlObjectInterpDistance = 200, }; enum MaskBits { ! InitialMask = BIT(0), ! PositionMask = BIT(1), ! MoveMask = BIT(2), ! WarpPositionMask = BIT(3), ! ExplosionMask = BIT(4), ! HealthMask = BIT(5), }; --- 57,70 ---- FireDelay = 100, MaxControlObjectInterpDistance = 200, + TrailCount = 2, }; enum MaskBits { ! InitialMask = BIT(0), ! PositionMask = BIT(1), ! MoveMask = BIT(2), ! WarpPositionMask = BIT(3), ! ExplosionMask = BIT(4), ! HealthMask = BIT(5), }; *************** *** 72,75 **** --- 74,80 ---- StringTableEntry mPlayerName; + S32 mLastTrailPoint[TrailCount]; + fxTrail mTrail[TrailCount]; + Color color; // color of the ship F32 mass; // mass of ship Index: CTFGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/CTFGame.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** CTFGame.cpp 28 Apr 2004 01:10:32 -0000 1.15 --- CTFGame.cpp 30 Apr 2004 08:33:20 -0000 1.16 *************** *** 216,219 **** --- 216,220 ---- s2cSetTeamScore(cl.teamId, mTeams[cl.teamId].score); s2cCTFMessage(CTFMsgCaptureFlag, cl.name, mountedFlag->getTeamIndex()); + // score the flag for the client's team... mountedFlag->dismount(); Index: sparkManager.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/sparkManager.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sparkManager.cpp 26 Apr 2004 05:22:43 -0000 1.3 --- sparkManager.cpp 30 Apr 2004 08:33:20 -0000 1.4 *************** *** 166,168 **** --- 166,233 ---- }; + fxTrail::fxTrail(U32 dropFrequency, U32 len) + { + mDropFreq = dropFrequency; + mLength = len; + } + + void fxTrail::update(Point pos) + { + if(mNodes.size() < mLength) + { + TrailNode t; + t.pos = pos; + t.ttl = mDropFreq; + + mNodes.push_front(t); + } + else + mNodes[0].pos = pos; + } + + void fxTrail::tick(U32 dT) + { + if(mNodes.size() == 0) + return; + + mNodes.last().ttl -= dT; + if(mNodes.last().ttl <= 0) + mNodes.pop_back(); + } + + void fxTrail::render() + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glBegin(GL_LINE_STRIP); + + for(S32 i=0; i<mNodes.size(); i++) + { + F32 t = ((F32)i/(F32)mNodes.size()); + glColor4f(1.f - 2*t, 1.f - 2*t, 1.f, 1.f-t); + glVertex2f(mNodes[i].pos.x, mNodes[i].pos.y); + } + + glEnd(); + + glDisable(GL_BLEND); + glBlendFunc(GL_ONE, GL_ZERO); + } + + void fxTrail::reset() + { + mNodes.clear(); + } + + Point fxTrail::getLastPos() + { + if(mNodes.size()) + { + return mNodes[0].pos; + } + else + return Point(0,0); + } + }; \ No newline at end of file Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ship.cpp 27 Apr 2004 23:26:15 -0000 1.17 --- ship.cpp 30 Apr 2004 08:33:20 -0000 1.18 *************** *** 66,69 **** --- 66,72 ---- mPlayerName = playerName; + + for(S32 i=0; i<TrailCount; i++) + mTrail[i].reset(); } *************** *** 181,184 **** --- 184,191 ---- // Emit some particles emitMovementSparks(); + + for(U32 i=0; i<TrailCount; i++) + mTrail[i].tick(theMove->time); + SFXObject::setListenerParams(mMoveState[RenderState].pos, mMoveState[RenderState].vel); } *************** *** 191,194 **** --- 198,204 ---- // Emit some particles emitMovementSparks(); + + for(U32 i=0; i<TrailCount; i++) + mTrail[i].tick(deltaT); } *************** *** 287,291 **** --- 297,306 ---- Point delta = mMoveState[ActualState].pos - mMoveState[RenderState].pos; if(delta.len() > MaxControlObjectInterpDistance) + { + for(S32 i=0; i<TrailCount; i++) + mTrail[i].reset(); + interpTime = 0; + } else interpTime = 1; *************** *** 407,410 **** --- 422,428 ---- interpTime = 0; mMoveState[RenderState] = mMoveState[ActualState]; + + for(S32 i=0; i<TrailCount; i++) + mTrail[i].reset(); } } *************** *** 445,449 **** // Scope for all ships on our team. ! for(U32 i=0; i<gt->mClientList.size(); i++) { if(gt->mClientList[i].teamId == teamId) --- 463,467 ---- // Scope for all ships on our team. ! for(S32 i=0; i<gt->mClientList.size(); i++) { if(gt->mClientList[i].teamId == teamId) *************** *** 540,590 **** void Ship::emitMovementSparks() { ! // draw thrusters ! Point velDir(lastMove.right - lastMove.left, lastMove.down - lastMove.up); ! F32 len = velDir.len(); ! F32 thrusts[4]; ! for(U32 i = 0; i < 4; i++) ! thrusts[i] = 0; ! if(len > 0) { ! if(len > 1) ! velDir *= 1 / len; ! Point shipDirs[4]; ! shipDirs[0].set(sin(mMoveState[RenderState].angle), cos(mMoveState[RenderState].angle) ); ! shipDirs[1].set(-shipDirs[0]); ! shipDirs[2].set(shipDirs[0].y, -shipDirs[0].x); ! shipDirs[3].set(-shipDirs[0].y, shipDirs[0].x); ! for(U32 i = 0; i < 4; i++) { ! thrusts[i] = shipDirs[i].dot(velDir); ! if(thrusts[i] > 0.1) ! { ! // shoot some sparks... ! if(thrusts[i] >= 2*TNL::Random::readF() * velDir.len()) ! { ! Point chaos(TNL::Random::readF(),TNL::Random::readF()); ! chaos *= 5; ! //interp give us some nice enginey colors... ! Color dim(1, 0, 0); ! Color light(1, 1, 0); ! Color thrust; ! F32 t = TNL::Random::readF(); ! thrust.interp(t, dim, light); ! SparkManager::emitSpark( ! mMoveState[RenderState].pos - shipDirs[i] * 13, ! -shipDirs[i] * (F32)(1.f - mMoveState[RenderState].vel.len() * (1.f/(F32)MaxVelocity)) * 100 + chaos, ! thrust ! ); ! } ! } ! } } } --- 558,646 ---- void Ship::emitMovementSparks() { ! // Do nothing if we're under 0.001 vel ! if(hasExploded || mMoveState[ActualState].vel.len() < 0.1) ! return; ! Point corners[3]; ! Point shipDirs[3]; ! ! corners[0].set(-20, -15); ! corners[1].set( 0, 25); ! corners[2].set( 20, -15); ! ! F32 th = mMoveState[RenderState].angle; ! ! F32 sinTh = sin(th); ! F32 cosTh = cos(th); ! ! for(S32 i=0; i<3; i++) { ! shipDirs[i].x = corners[i].x * cosTh + corners[i].y * sinTh; ! shipDirs[i].y = corners[i].y * cosTh - corners[i].x * sinTh; ! } ! Point leftVec ( mMoveState[ActualState].vel.y, -mMoveState[ActualState].vel.x); ! Point rightVec(-mMoveState[ActualState].vel.y, mMoveState[ActualState].vel.x); ! leftVec.normalize(); ! rightVec.normalize(); ! ! S32 bestId = -1, leftId, rightId; ! F32 bestDot = -1; ! ! // Find the left-wards match ! for(S32 i = 0; i < 3; i++) ! { ! F32 d = leftVec.dot(shipDirs[i]); ! if(d >= bestDot) { ! bestDot = d; ! bestId = i; ! } ! } ! leftId = bestId; ! Point leftPt = mMoveState[RenderState].pos + shipDirs[bestId]; ! // Find the right-wards match ! bestId = -1; ! bestDot = -1; ! ! for(S32 i = 0; i < 3; i++) ! { ! F32 d = rightVec.dot(shipDirs[i]); ! if(d >= bestDot) ! { ! bestDot = d; ! bestId = i; ! } ! } ! rightId = bestId; ! Point rightPt = mMoveState[RenderState].pos + shipDirs[bestId]; ! // Stitch things up if we must... ! if(leftId == mLastTrailPoint[0] && rightId == mLastTrailPoint[1]) ! { ! mTrail[0].update(leftPt); ! mTrail[1].update(rightPt); ! mLastTrailPoint[0] = leftId; ! mLastTrailPoint[1] = rightId; } + else if(leftId == mLastTrailPoint[1] && rightId == mLastTrailPoint[0]) + { + mTrail[1].update(leftPt); + mTrail[0].update(rightPt); + mLastTrailPoint[1] = leftId; + mLastTrailPoint[0] = rightId; + } + else + { + mTrail[0].update(leftPt); + mTrail[1].update(rightPt); + mLastTrailPoint[0] = leftId; + mLastTrailPoint[1] = rightId; + } + } *************** *** 594,597 **** --- 650,656 ---- return; + for(U32 i=0; i<TrailCount; i++) + mTrail[i].render(); + if(posSegments.size()) { |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 07:16:20
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1270/zap Modified Files: UICredits.h Log Message: Simple exit credits for now. Index: UICredits.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UICredits.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UICredits.h 30 Apr 2004 06:55:52 -0000 1.1 --- UICredits.h 30 Apr 2004 07:16:00 -0000 1.2 *************** *** 34,38 **** { - class CreditsUserInterface; class CreditsFX { --- 34,37 ---- *************** *** 42,47 **** public: CreditsFX(); ! virtual void setActive(bool active) { activated = active; } ! virtual bool isActive() { return activated; } virtual void updateFX(U32 delta) = 0; virtual void render() = 0; --- 41,46 ---- public: CreditsFX(); ! void setActive(bool active) { activated = active; } ! bool isActive() { return activated; } virtual void updateFX(U32 delta) = 0; virtual void render() = 0; |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 07:05:33
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31971/zap Modified Files: Makefile zap.dsp Log Message: Simple exit credits for now. Index: Makefile =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/Makefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile 25 Apr 2004 19:09:24 -0000 1.3 --- Makefile 30 Apr 2004 07:05:23 -0000 1.4 *************** *** 26,29 **** --- 26,30 ---- UINameEntry.o\ UIQueryServers.o\ + UICredits.o\ projectile.o\ quickChat.o\ Index: zap.dsp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/zap.dsp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** zap.dsp 27 Apr 2004 22:36:48 -0000 1.3 --- zap.dsp 30 Apr 2004 07:05:23 -0000 1.4 *************** *** 293,296 **** --- 293,304 ---- # Begin Source File + SOURCE=.\UICredits.cpp + #End Source File + #Begin Source File + + SOURCE=.\UiCredits.h + #End Source File + #Begin Source File + SOURCE=.\winJoystick.cpp # End Source File |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 06:57:48
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30262/zap Modified Files: UIMenus.cpp Log Message: Simple exit credits for now. Index: UIMenus.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIMenus.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** UIMenus.cpp 27 Apr 2004 21:43:04 -0000 1.8 --- UIMenus.cpp 30 Apr 2004 06:57:39 -0000 1.9 *************** *** 29,32 **** --- 29,33 ---- #include "UIGame.h" #include "UIQueryServers.h" + #include "UICredits.h" #include "game.h" #include "gameType.h" *************** *** 158,162 **** break; case 4: ! exit(0); break; } --- 159,163 ---- break; case 4: ! gCreditsUserInterface.activate(); break; } |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 06:56:58
|
Update of /cvsroot/opentnl/tnl/exe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30111/exe Added Files: credits.txt Log Message: Simple exit credits for now. --- NEW FILE: credits.txt --- Lead Programmer Mark Frohnmayer Linux Programmer John Quigley Programmer and Sound Effects Ben Garney |
From: Robert B. Jr. <rbl...@us...> - 2004-04-30 06:56:01
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29916/zap Modified Files: ZAP.vcproj Added Files: UICredits.cpp UICredits.h Log Message: Simple exit credits for now. --- NEW FILE: UICredits.cpp --- //----------------------------------------------------------------------------------- // // Torque Network Library - ZAP example multiplayer vector graphics space game // Copyright (C) 2004 GarageGames.com, Inc. // For more information see http://www.opentnl.org // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // For use in products that are not compatible with the terms of the GNU // General Public License, alternative licensing options are available // from GarageGames.com. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //------------------------------------------------------------------------------------ #include "../tnl/tnlRandom.h" #include "UICredits.h" #include "glutInclude.h" #include <stdio.h> namespace Zap { CreditsUserInterface gCreditsUserInterface; void CreditsUserInterface::onActivate() { // construct the creditsfx objects here, they will // get properly deleted when the CreditsUI // destructor is envoked // add credits scroller first and make it active CreditsScroller *scroller = new CreditsScroller; scroller->setActive(true); // add CreditsFX effects below here, dont activate: // // choose randomly another CreditsFX effect // aside from CreditsScroller to activate if(fxList.size() > 1) { U32 rand = Random::readI(0, fxList.size() - 1); while(fxList[rand]->isActive()) { U32 value = Platform::getRealMilliseconds(); Random::addEntropy((U8 *) &value, sizeof(U32)); rand = Random::readI(0, fxList.size() - 1); } fxList[rand]->setActive(true); } } void CreditsUserInterface::render() { glViewport(0, 0, windowWidth, windowHeight); glClearColor(0, 0, 0, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // loop through all the attached effects and // call their render function for(S32 i = 0; i < fxList.size(); i++) if(fxList[i]->isActive()) fxList[i]->render(); } //----------------------------------------------------- // CreditsFX Objects //----------------------------------------------------- CreditsFX::CreditsFX() { activated = false; gCreditsUserInterface.addFX(this); } CreditsScroller::CreditsScroller() { credits.clear(); readCredits("credits.txt"); } void CreditsScroller::updateFX(U32 delta) { // scroll the credits text from bottom to top // based on time for(S32 i = 0; i < credits.size(); i++) { S32 pos = credits[i].currPos.x - (delta / 10); // reached the top, reset if(pos < -CreditSpace) pos = gCreditsUserInterface.canvasHeight + CreditSpace * 3; credits[i].currPos.x = pos; } } void CreditsScroller::render() { // draw the credits text glColor3f(1,1,1); for(S32 i = 0; i < credits.size(); i++) { gCreditsUserInterface.drawCenteredString(credits[i].currPos.x, 25, credits[i].jobBuf); gCreditsUserInterface.drawCenteredString(credits[i].currPos.x + 50, 25, credits[i].nameBuf); } } void CreditsScroller::readCredits(const char *file) { // try and open the file context FILE *f = fopen(file, "r"); if(!f) return; char name[MaxCreditLen]; char job[MaxCreditLen]; S32 pos = gCreditsUserInterface.canvasHeight + CreditSpace; // loop through each line in the credits file, expecting // the credits to be listed in this order: // 1) job // 2) name while(!feof(f)) { CreditsInfo c; // get job fgets(job, MaxCreditLen, f); strcpy(c.jobBuf, job); // get name fgets(name, MaxCreditLen, f); strcpy(c.nameBuf, name); // place credit in cache c.currPos.x = pos; credits.push_back(c); pos += CreditSpace; } // close the file context fclose(f); } }; --- NEW FILE: UICredits.h --- //----------------------------------------------------------------------------------- // // Torque Network Library - ZAP example multiplayer vector graphics space game // Copyright (C) 2004 GarageGames.com, Inc. // For more information see http://www.opentnl.org // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // For use in products that are not compatible with the terms of the GNU // General Public License, alternative licensing options are available // from GarageGames.com. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // //------------------------------------------------------------------------------------ #ifndef _UICREDITS_H_ #define _UICREDITS_H_ #include "UI.h" #include "game.h" namespace Zap { class CreditsUserInterface; class CreditsFX { protected: bool activated; public: CreditsFX(); virtual void setActive(bool active) { activated = active; } virtual bool isActive() { return activated; } virtual void updateFX(U32 delta) = 0; virtual void render() = 0; }; class CreditsScroller : public CreditsFX { //typedef CreditsFX Parent; enum Credits { MaxCreditLen = 32, CreditSpace = 200 }; struct CreditsInfo { char nameBuf[MaxCreditLen+1]; char jobBuf[MaxCreditLen+1]; Point currPos; }; Vector<CreditsInfo> credits; void readCredits(const char *file); public: CreditsScroller(); void updateFX(U32 delta); void render(); }; // Credits UI class CreditsUserInterface : public UserInterface { Vector<CreditsFX *> fxList; public: ~CreditsUserInterface() { for(S32 i = 0; i < fxList.size(); i++) { delete fxList[i]; fxList[i] = NULL; fxList.erase(i); } fxList.clear(); } void onActivate(); void addFX(CreditsFX *fx) { fxList.push_back(fx); } void idle(U32 t) { for(S32 i = 0; i < fxList.size(); i++) if(fxList[i]->isActive()) fxList[i]->updateFX(t); } void render(); void onKeyDown(U32 key) { exit(0); } // exit for now }; extern CreditsUserInterface gCreditsUserInterface; } #endif Index: ZAP.vcproj =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ZAP.vcproj,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ZAP.vcproj 27 Apr 2004 22:36:47 -0000 1.7 --- ZAP.vcproj 30 Apr 2004 06:55:52 -0000 1.8 *************** *** 259,262 **** --- 259,268 ---- </File> <File + RelativePath=".\UICredits.cpp"> + </File> + <File + RelativePath=".\UICredits.h"> + </File> + <File RelativePath=".\UIGame.cpp"> </File> *************** *** 265,268 **** --- 271,280 ---- </File> <File + RelativePath=".\UILevelEditor.cpp"> + </File> + <File + RelativePath=".\UILevelEditor.h"> + </File> + <File RelativePath=".\UIMenus.cpp"> </File> |