[Opentnl-cvs] tnl/zap UIGame.cpp,1.47,1.48 flagItem.cpp,1.5,1.6 footballGame.cpp,1.10,1.11 game.cpp,
Brought to you by:
mark_frohnmayer,
s_alanet
From: Mark F. <mar...@us...> - 2004-10-01 00:21:51
|
Update of /cvsroot/opentnl/tnl/zap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2166/zap Modified Files: UIGame.cpp flagItem.cpp footballGame.cpp game.cpp game.h gameObject.cpp gameObject.h gameType.cpp gameType.h goalZone.cpp goalZone.h input.cpp item.cpp point.h ship.cpp Log Message: Added objective waypoints facility to main game screen Removed weapon switch on stick press Index: flagItem.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/flagItem.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** flagItem.cpp 6 Aug 2004 00:02:46 -0000 1.5 --- flagItem.cpp 1 Oct 2004 00:21:40 -0000 1.6 *************** *** 44,49 **** void FlagItem::onAddedToGame(Game *theGame) { ! if(!isGhost()) ! theGame->getGameType()->addFlag(this); } --- 44,48 ---- void FlagItem::onAddedToGame(Game *theGame) { ! theGame->getGameType()->addFlag(this); } Index: gameType.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.cpp,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** gameType.cpp 6 Aug 2004 00:02:47 -0000 1.58 --- gameType.cpp 1 Oct 2004 00:21:40 -0000 1.59 *************** *** 220,223 **** --- 220,292 ---- } + void GameType::renderObjectiveArrow(GameObject *target, Color c) + { + GameConnection *gc = gClientGame->getConnectionToServer(); + GameObject *co = NULL; + if(gc) + co = gc->getControlObject(); + if(!co) + return; + Rect r = target->getBounds(MoveObject::RenderState); + Point nearestPoint = co->getRenderPos(); + + if(r.max.x < nearestPoint.x) + nearestPoint.x = r.max.x; + if(r.min.x > nearestPoint.x) + nearestPoint.x = r.min.x; + if(r.max.y < nearestPoint.y) + nearestPoint.y = r.max.y; + if(r.min.y > nearestPoint.y) + nearestPoint.y = r.min.y; + + Point rp = gClientGame->worldToScreenPoint(nearestPoint); + + Point center(400, 300); + Point arrowDir = rp - center; + if(rp.x > UserInterface::horizMargin && + rp.x < UserInterface::canvasWidth - UserInterface::horizMargin && + rp.y > UserInterface::vertMargin && + rp.y < UserInterface::canvasHeight - UserInterface::vertMargin) + return; + + Point np = rp; + if(rp.x < UserInterface::horizMargin) + rp.x = UserInterface::horizMargin; + if(rp.x > UserInterface::canvasWidth - UserInterface::horizMargin) + rp.x = UserInterface::canvasWidth - UserInterface::horizMargin; + if(rp.y < UserInterface::vertMargin) + rp.y = UserInterface::vertMargin; + if(rp.y > UserInterface::canvasHeight - UserInterface::vertMargin) + rp.y = UserInterface::canvasHeight - UserInterface::vertMargin; + + F32 dist = (np - rp).len(); + + arrowDir.normalize(); + Point crossVec(arrowDir.y, -arrowDir.x); + F32 alpha = (1 - gClientGame->getCommanderZoomFraction()) * 0.8; + if(!alpha) + return; + + if(dist < 50) + alpha *= dist * 0.02; + + glEnable(GL_BLEND); + glColor(c * 0.7, alpha); + Point p2 = rp - arrowDir * 20 + crossVec * 10; + Point p3 = rp - arrowDir * 20 - crossVec * 10; + glBegin(GL_POLYGON); + glVertex(rp); + glVertex(p2); + glVertex(p3); + glEnd(); + glColor(c, alpha); + glBegin(GL_LINE_LOOP); + glVertex(rp); + glVertex(p2); + glVertex(p3); + glEnd(); + glDisable(GL_BLEND); + } + void GameType::renderTimeLeft() { Index: UIGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/UIGame.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** UIGame.cpp 29 Sep 2004 23:53:21 -0000 1.47 --- UIGame.cpp 1 Oct 2004 00:21:40 -0000 1.48 *************** *** 132,137 **** } ! if(gClientGame) ! gClientGame->render(); glMatrixMode(GL_MODELVIEW); --- 132,136 ---- } ! gClientGame->render(); glMatrixMode(GL_MODELVIEW); Index: game.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** game.cpp 23 Aug 2004 19:32:44 -0000 1.49 --- game.cpp 1 Oct 2004 00:21:40 -0000 1.50 *************** *** 551,554 **** --- 551,594 ---- } + Point ClientGame::worldToScreenPoint(Point p) + { + GameObject *controlObject = mConnectionToServer->getControlObject(); + Ship *u = (Ship *) controlObject; + Point position = u->getRenderPos(); + + if(mCommanderZoomDelta) + { + F32 zoomFrac = getCommanderZoomFraction(); + Point worldCenter = mWorldBounds.getCenter(); + Point worldExtents = mWorldBounds.getExtents(); + worldExtents.x *= UserInterface::canvasWidth / F32(UserInterface::canvasWidth - (UserInterface::horizMargin * 2)); + worldExtents.y *= UserInterface::canvasHeight / F32(UserInterface::canvasHeight - (UserInterface::vertMargin * 2)); + + F32 aspectRatio = worldExtents.x / worldExtents.y; + F32 screenAspectRatio = UserInterface::canvasWidth / F32(UserInterface::canvasHeight); + if(aspectRatio > screenAspectRatio) + worldExtents.y *= aspectRatio / screenAspectRatio; + else + worldExtents.x *= screenAspectRatio / aspectRatio; + + Point offset = (worldCenter - position) * zoomFrac + position; + Point visSize = computePlayerVisArea(u) * 2; + Point modVisSize = (worldExtents - visSize) * zoomFrac + visSize; + + Point visScale(UserInterface::canvasWidth / modVisSize.x, + UserInterface::canvasHeight / modVisSize.y ); + + Point ret = (p - offset) * visScale + Point(400, 300); + return ret; + } + else + { + Point visExt = computePlayerVisArea((Ship *) u); + Point scaleFactor(400 / visExt.x, 300 / visExt.y); + Point ret = (p - position) * scaleFactor + Point(400, 300); + return ret; + } + } + void ClientGame::renderCommander() { *************** *** 561,564 **** --- 601,605 ---- // Set up the view to show the whole level. Rect worldBounds = computeWorldObjectExtents(); + mWorldBounds = worldBounds; Point worldCenter = worldBounds.getCenter(); Index: gameObject.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameObject.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** gameObject.cpp 26 Jun 2004 18:07:43 -0000 1.19 --- gameObject.cpp 1 Oct 2004 00:21:40 -0000 1.20 *************** *** 280,283 **** --- 280,304 ---- } + Rect GameObject::getBounds(U32 stateIndex) + { + Rect ret; + Point p; + float radius; + Vector<Point> bounds; + + if(getCollisionCircle(stateIndex, p, radius)) + { + ret.max = p + Point(radius, radius); + ret.min = p - Point(radius, radius); + } + else if(getCollisionPoly(bounds)) + { + ret.min = ret.max = bounds[0]; + for(S32 i = 1; i < bounds.size(); i++) + ret.unionPoint(bounds[i]); + } + return ret; + } + void GameObject::render() { Index: goalZone.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/goalZone.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** goalZone.cpp 1 Jul 2004 23:07:46 -0000 1.1 --- goalZone.cpp 1 Oct 2004 00:21:40 -0000 1.2 *************** *** 44,49 **** void GoalZone::render() { ! bool isFlashing = mFlashCount & 1; ! renderGoalZone(mPolyBounds, getGame()->getGameType()->getTeamColor(getTeam()), isFlashing); } --- 44,48 ---- void GoalZone::render() { ! renderGoalZone(mPolyBounds, getGame()->getGameType()->getTeamColor(getTeam()), isFlashing()); } *************** *** 78,85 **** { if(!isGhost()) - { setScopeAlways(); ! theGame->getGameType()->addZone(this); ! } } --- 77,82 ---- { if(!isGhost()) setScopeAlways(); ! theGame->getGameType()->addZone(this); } Index: point.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/point.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** point.h 26 Jun 2004 18:07:44 -0000 1.9 --- point.h 1 Oct 2004 00:21:40 -0000 1.10 *************** *** 54,57 **** --- 54,59 ---- Point &operator*=(const member_type f) { x *= f; y *= f; return *this; } + Point operator*(const Point &pt) { return Point(x * pt.x, y * pt.y); } + Point &operator=(const Point &pt) { x = pt.x; y = pt.y; return *this; } bool operator==(const Point &pt) { return x == pt.x && y == pt.y; } Index: gameObject.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameObject.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** gameObject.h 26 Jun 2004 18:07:43 -0000 1.27 --- gameObject.h 1 Oct 2004 00:21:40 -0000 1.28 *************** *** 137,140 **** --- 137,141 ---- virtual bool getCollisionPoly(Vector<Point> &polyPoints); virtual bool getCollisionCircle(U32 stateIndex, Point &point, float &radius); + Rect getBounds(U32 stateIndex); const Move &getCurrentMove() { return mCurrentMove; } Index: footballGame.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/footballGame.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** footballGame.cpp 4 Aug 2004 18:25:27 -0000 1.10 --- footballGame.cpp 1 Oct 2004 00:21:40 -0000 1.11 *************** *** 40,50 **** --- 40,54 ---- Vector<GoalZone*> mZones; + SafePtr<FlagItem> mFlag; public: void shipTouchFlag(Ship *theShip, FlagItem *theFlag); void flagDropped(Ship *theShip, FlagItem *theFlag); void addZone(GoalZone *z); + void addFlag(FlagItem *theFlag) { mFlag = theFlag; } void shipTouchZone(Ship *s, GoalZone *z); const char *getGameTypeString() { return "Zone Control"; } const char *getInstructionString() { return "Carry the flag into each of the capture zones!"; } + void renderInterfaceOverlay(bool scoreboardVisible); + void performProxyScopeQuery(GameObject *scopeObject, GameConnection *connection); TNL_DECLARE_CLASS(ZoneControlGameType); *************** *** 144,146 **** --- 148,213 ---- } + void ZoneControlGameType::performProxyScopeQuery(GameObject *scopeObject, GameConnection *connection) + { + Parent::performProxyScopeQuery(scopeObject, connection); + S32 uTeam = scopeObject->getTeam(); + if(mFlag.isValid()) + { + if(mFlag->isAtHome()) + connection->objectInScope(mFlag); + else + { + Ship *mount = mFlag->getMount(); + if(mount && mount->getTeam() == uTeam) + { + connection->objectInScope(mount); + connection->objectInScope(mFlag); + } + } + } + } + + void ZoneControlGameType::renderInterfaceOverlay(bool scoreboardVisible) + { + Ship *u = (Ship *) gClientGame->getConnectionToServer()->getControlObject(); + if(u) + { + if(mFlag.isValid() && mFlag->getMount() == u) + { + // the ship has the flag, so render zones not controlled by his team + for(S32 i = 0; i < mZones.size(); i++) + if(mZones[i]->getTeam() != u->getTeam()) + renderObjectiveArrow(mZones[i], getTeamColor(mZones[i]->getTeam())); + } + else + { + if(mFlag.isValid()) + { + if(!mFlag->isMounted()) + renderObjectiveArrow(mFlag, getTeamColor(mFlag->getTeam())); + else + { + Ship *mount = mFlag->getMount(); + if(mount) + renderObjectiveArrow(mount, getTeamColor(mount->getTeam())); + } + } + for(S32 i = 0; i < mZones.size(); i++) + { + if(mZones[i]->didRecentlyChangeTeam()) + { + Color c = getTeamColor(mZones[i]->getTeam()); + if(mZones[i]->isFlashing()) + c *= 0.8; + renderObjectiveArrow(mZones[i], c); + + } + } + } + } + + Parent::renderInterfaceOverlay(scoreboardVisible); + } + + }; \ No newline at end of file Index: gameType.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/gameType.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** gameType.h 4 Aug 2004 18:25:27 -0000 1.33 --- gameType.h 1 Oct 2004 00:21:40 -0000 1.34 *************** *** 144,147 **** --- 144,149 ---- virtual void renderInterfaceOverlay(bool scoreboardVisible); + void renderObjectiveArrow(GameObject *target, Color c); + void renderTimeLeft(); void renderTalkingClients(); Index: goalZone.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/goalZone.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** goalZone.h 1 Jul 2004 23:07:46 -0000 1.1 --- goalZone.h 1 Oct 2004 00:21:40 -0000 1.2 *************** *** 51,54 **** --- 51,57 ---- GoalZone(); void render(); + + bool isFlashing() { return mFlashCount & 1; } + bool didRecentlyChangeTeam() { return mFlashCount != 0; } S32 getRenderSortValue(); void processArguments(S32 argc, const char **argv); Index: item.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/item.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** item.cpp 4 Aug 2004 18:25:27 -0000 1.19 --- item.cpp 1 Oct 2004 00:21:40 -0000 1.20 *************** *** 172,176 **** retMask = MountMask; } ! return MountMask; } --- 172,176 ---- retMask = MountMask; } ! return retMask; } Index: input.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/input.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** input.cpp 29 Sep 2004 23:53:21 -0000 1.4 --- input.cpp 1 Oct 2004 00:21:40 -0000 1.5 *************** *** 178,182 **** ControllerButtonRightTrigger, 0, ! ControllerButton1, ControllerButtonBack, 0, --- 178,182 ---- ControllerButtonRightTrigger, 0, ! 0, ControllerButtonBack, 0, *************** *** 201,205 **** ControllerButtonBack, 0, ! ControllerButton1, ControllerButtonStart, }; --- 201,205 ---- ControllerButtonBack, 0, ! 0, ControllerButtonStart, }; *************** *** 222,226 **** ControllerButtonBack, 0, ! ControllerButton1, ControllerButtonLeftTrigger, ControllerButtonRightTrigger, --- 222,226 ---- ControllerButtonBack, 0, ! 0, ControllerButtonLeftTrigger, ControllerButtonRightTrigger, Index: game.h =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/game.h,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** game.h 29 Sep 2004 23:53:21 -0000 1.65 --- game.h 1 Oct 2004 00:21:40 -0000 1.66 *************** *** 200,203 **** --- 200,204 ---- }; Point mStars[NumStars]; + Rect mWorldBounds; SafePtr<GameConnection> mConnectionToServer; // If this is a client game, this is the connection to the server *************** *** 214,217 **** --- 215,219 ---- F32 getCommanderZoomFraction() { return mCommanderZoomDelta / F32(CommanderMapZoomTime); } + Point worldToScreenPoint(Point p); void setConnectionToServer(GameConnection *connection); void drawStars(F32 alphaFrac, Point cameraPos, Point visibleExtent); *************** *** 234,238 **** extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.4.3" }; --- 236,240 ---- extern void endGame(); ! #define ZAP_GAME_STRING "ZAP 1.4.4" }; Index: ship.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/zap/ship.cpp,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** ship.cpp 17 Sep 2004 00:14:34 -0000 1.76 --- ship.cpp 1 Oct 2004 00:21:40 -0000 1.77 *************** *** 354,359 **** { GameObject *s = hitObjects[i]; ! if(!s->isDestroyed() && s->getHealth() < 1 && (s->getRenderPos() - pos).len() < (RepairRadius + CollisionRadius)) ! mRepairTargets.push_back(s); } return mRepairTargets.size() != 0; --- 354,364 ---- { GameObject *s = hitObjects[i]; ! if(s->isDestroyed() || s->getHealth() >= 1) ! continue; ! if((s->getRenderPos() - pos).len() > (RepairRadius + CollisionRadius)) ! continue; ! if(s->getTeam() != -1 && s->getTeam() != getTeam()) ! continue; ! mRepairTargets.push_back(s); } return mRepairTargets.size() != 0; |