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

List:       kde-commits
Subject:    playground/games/kapman
From:       Nathalie Liesse <nathalie.liesse () gmail ! com>
Date:       2008-02-01 14:07:14
Message-ID: 1201874834.865165.1231.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 769462 by liesse:

The Kapman was not eaten by the ghosts if it was not moving. The bug has 
been corrected.


 M  +3 -0      game.cpp  
 M  +4 -0      kapman.cpp  
 M  +15 -5     kapman.h  
 M  +4 -4      kapmanitem.cpp  
 M  +2 -4      kapmanitem.h  


--- trunk/playground/games/kapman/game.cpp #769461:769462
@@ -174,6 +174,9 @@
 		}
 	}	
 	m_kapman->updateMove();
+	
+	// tells to kapman to call the function that will emit a signal to Kapmanitem (in \
order to manage collisions) +	m_kapman->emitGameUpdated();
 }
 
 void Game::kapmanDeath() {
--- trunk/playground/games/kapman/kapman.cpp #769461:769462
@@ -129,6 +129,10 @@
 	emit(lifeLost());
 }
 
+void Kapman::emitGameUpdated() {
+	emit(gameUpdated());
+}
+
 /** Accessors */
 qreal Kapman::getAskedXSpeed() const {
 	return m_askedXSpeed;
--- trunk/playground/games/kapman/kapman.h #769461:769462
@@ -74,11 +74,6 @@
 		void updateMove();
 
 		/**
-		 * Manages the loss of a life
-		 */
-		void loseLife();
-
-		/**
 		 * @return the asked x speed value
 		 */
 		qreal getAskedXSpeed() const;
@@ -88,6 +83,16 @@
 		 */
 		qreal getAskedYSpeed() const;
 
+		/**
+		 * Manages the loss of a life
+		 */
+		void loseLife();
+		
+		/**
+		 * Emits a signal to Kapmanitem in order to manage collisions
+		 */
+		void emitGameUpdated();
+
 	private:
 
 		/**
@@ -111,6 +116,11 @@
 		 * Signals to the game that the kapman lost a life
 		 */
 		void lifeLost();
+		
+		/**
+		 * Signals to Kapmanitem that the game has been updated
+		 */
+		 void gameUpdated();
 };
 
 #endif
--- trunk/playground/games/kapman/kapmanitem.cpp #769461:769462
@@ -22,21 +22,21 @@
 #include "ghost.h"
 
 KapmanItem::KapmanItem(Kapman* p_model, QString p_imagePath) \
:	CharacterItem(p_model, p_imagePath) { +	connect(p_model, SIGNAL(gameUpdated()), \
this, SLOT(manageCollision()));  }
 
 KapmanItem::~KapmanItem() {
 
 }
 
-void KapmanItem::update(qreal p_x, qreal p_y) {
-	CharacterItem::update(p_x, p_y);
-
+void KapmanItem::manageCollision() {
 	QList<QGraphicsItem *> collidingList = collidingItems();
 
 	// The signal is emitted only if the list contains more than 1 items (to exclude \
                the case
-	// when the kapman only collides with the maze
+	// when the kapman only collides with the maze)
 	if(collidingList.size() > 1) {
 		for(int i = 0 ; i < collidingList.size() ; i++) {
+			// The maze has a negative zValue which allows to exclude it from the treatment \
of collisions  if (collidingList[i]->zValue() >= 0) {
 				((ElementItem*)collidingList[i])->getModel()->doActionOnCollision((Kapman*)getModel());
  }
--- trunk/playground/games/kapman/kapmanitem.h #769461:769462
@@ -46,11 +46,9 @@
 	public slots:
 
 		/**
-		 * Updates the view coordinates
-		 * @param p_x the new x-coordinate
-		 * @param p_y the new y-coordinate
+		 * Manages the colllisions between kapman and the other elements
 		 */
-		void update(qreal p_x, qreal p_y);
+		void manageCollision();
 };
 
 #endif


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

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