[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/games/astrododge/src
From:       Rivo Laks <rivolaks () hot ! ee>
Date:       2009-08-03 15:47:28
Message-ID: 1249314448.813717.15677.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1006366 by rivol:

- Add action to toggle ship's headlight (shortcut L)
- Comment out the light-per-bullet thing that I've accidentially committed.

 M  +3 -0      astrododgeui.rc  
 M  +7 -3      gameview.cpp  
 M  +5 -0      gameworld.cpp  
 M  +1 -0      gameworld.h  
 M  +7 -0      mainwindow.cpp  
 M  +1 -0      mainwindow.h  
 M  +1 -0      ship.cpp  
 M  +1 -0      ship.h  


--- trunk/playground/games/astrododge/src/astrododgeui.rc #1006365:1006366
@@ -7,6 +7,9 @@
                          http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd" >
 
     <MenuBar>
+        <Menu name="game">
+            <Action name="ship_light" />
+        </Menu>
         <Menu name="view">
             <Text>View</Text>
             <Action name="hdr_enable" />
--- trunk/playground/games/astrododge/src/gameview.cpp #1006365:1006366
@@ -138,10 +138,13 @@
     mShaderManager->setLightDirection(lightDir);
     renderObjects(mWorld->objects());
 
-    mShaderManager->setLight("spot");
-    mShaderManager->setLightColor(Vector3f(0.8, 0.8, 1.2));
-    renderObjects(mWorld->objects());
+    if (mWorld->ship()->lightOn) {
+        mShaderManager->setLight("spot");
+        mShaderManager->setLightColor(Vector3f(0.8, 0.8, 1.2));
+        renderObjects(mWorld->objects());
+    }
 
+    /*
     foreach (Bullet* obj, *mWorld->bullets()) {
         mShaderManager->setLight("point");
         mShaderManager->setLightColor(Vector3f(2.0, 1.6, 0.8));
@@ -151,6 +154,7 @@
         mShaderManager->setLightPosition(lightPos.start<3>());
         renderObjects(mWorld->objects());
     }
+    */
 
     // Restore states
     glDepthMask(GL_TRUE);
--- trunk/playground/games/astrododge/src/gameworld.cpp #1006365:1006366
@@ -350,6 +350,11 @@
     mBullets.append(b);
 }
 
+void GameWorld::setShipLight(bool on)
+{
+    mShip->lightOn = on;
+}
+
 GameObject* GameWorld::addTrackPoint(const Vector3f& pos)
 {
     mTrack.append(pos);
--- trunk/playground/games/astrododge/src/gameworld.h #1006365:1006366
@@ -83,6 +83,7 @@
     void slotToggleGamePaused();
 
     void slotShootBullet();
+    void setShipLight(bool on);
 
 protected:
     void applyShipRotation(float elapsed);
--- trunk/playground/games/astrododge/src/mainwindow.cpp #1006365:1006366
@@ -130,6 +130,11 @@
     mDetailDecreaseAction = new KAction("Decrease detail", this);
     mDetailDecreaseAction->setShortcut(Qt::CTRL + Qt::Key_Minus);
     actionCollection()->addAction("detail_decrease", mDetailDecreaseAction);
+
+    mShipLightAction = new KToggleAction("Ship's light", this);
+    mShipLightAction->setChecked(false);
+    mShipLightAction->setShortcut(Qt::Key_L);
+    actionCollection()->addAction("ship_light", mShipLightAction);
 }
 
 void MainWindow::startNewGame()
@@ -138,6 +143,8 @@
     mDisplay->hideMenus();
 
     mWorld = new GameWorld(this, mData);
+    mShipLightAction->setChecked(false);
+    connect(mShipLightAction, SIGNAL(triggered(bool)), mWorld, SLOT(setShipLight(bool)));
 
     mLoadingView = new LoadingView(mDisplay, mWorld, "test1");
     connect(mLoadingView, SIGNAL(loadingComplete()), this, SLOT(gameAboutToStart()));
--- trunk/playground/games/astrododge/src/mainwindow.h #1006365:1006366
@@ -74,6 +74,7 @@
         KToggleAction* mShowRenderInfoAction;
         KAction* mDetailIncreaseAction;
         KAction* mDetailDecreaseAction;
+        KToggleAction* mShipLightAction;
 };
 
 #endif
--- trunk/playground/games/astrododge/src/ship.cpp #1006365:1006366
@@ -31,6 +31,7 @@
 
     lastshoottime = -1000;
     health = 100;
+    lightOn = false;
 }
 
 Ship::~Ship()
--- trunk/playground/games/astrododge/src/ship.h #1006365:1006366
@@ -48,6 +48,7 @@
 
     float lastshoottime;
     float health;
+    bool lightOn;
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic