[Scummvm-cvs-logs] SF.net SVN: scummvm:[42581] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Sat Jul 18 05:00:13 CEST 2009


Revision: 42581
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42581&view=rev
Author:   dkasak13
Date:     2009-07-18 03:00:12 +0000 (Sat, 18 Jul 2009)

Log Message:
-----------
* Added support for "walking" with the hero (i.e. moving the sprite to locations allowed by the walking map)
* Enabled drawing the walking map with the 'w' hotkey for testing

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/game.cpp

Modified: scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-07-18 02:58:11 UTC (rev 42580)
+++ scummvm/branches/gsoc2009-draci/engines/draci/draci.cpp	2009-07-18 03:00:12 UTC (rev 42581)
@@ -171,6 +171,7 @@
 
 	Common::Event event;
 	bool quit = false;
+	bool showWalkingMap = false;
 	while (!quit) {
 		while (_eventMan->pollEvent(event)) {
 			switch (event.type) {
@@ -182,7 +183,17 @@
 					_game->changeRoom(_game->nextRoomNum());
 				else if (event.kbd.keycode == Common::KEYCODE_LEFT)
 					_game->changeRoom(_game->prevRoomNum());
-				break;
+				else if (event.kbd.keycode == Common::KEYCODE_w) { // Show walking map toggle
+					// Toggle
+					showWalkingMap = !showWalkingMap;
+
+					if (showWalkingMap) {
+						_anims->play(-2);
+					} else {
+						_anims->stop(-2);
+					}
+				}
+				break;					
 			default:
 				_mouse->handleEvent(event);
 			}		

Modified: scummvm/branches/gsoc2009-draci/engines/draci/game.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/game.cpp	2009-07-18 02:58:11 UTC (rev 42580)
+++ scummvm/branches/gsoc2009-draci/engines/draci/game.cpp	2009-07-18 03:00:12 UTC (rev 42581)
@@ -155,6 +155,7 @@
 	debugC(4, kDraciLogicDebugLevel, "Running init program for the dragon object...");
 	_vm->_script->run(dragon->_program, dragon->_init);
 
+	_currentRoom._roomNum = _info._startRoom;
 	changeRoom(_info._startRoom);
 
 	_vm->_mouse->setCursorType(kNormalCursor);
@@ -165,7 +166,22 @@
 	if (_currentRoom._mouseOn) {
 		int x = _vm->_mouse->getPosX();
 		int y = _vm->_mouse->getPosY();
+
 		if (_vm->_mouse->lButtonPressed() && _currentRoom._walkingMap.isWalkable(x, y)) {
+			
+			int animID = getObject(kDragonObject)->_anims[0];
+
+			Animation *anim = _vm->_anims->getAnimation(animID);
+			Drawable *frame = anim->getFrame();
+			y -= frame->getHeight();
+			
+			// HACK: Z needs to be handled according to Y position
+			anim->setZ(256);
+
+			anim->setRelative(x, y); 
+
+			_vm->_anims->play(animID);
+
 			debugC(4, kDraciLogicDebugLevel, "Walk to x: %d y: %d", x, y);
 		}
 	}
@@ -221,7 +237,6 @@
 	debugC(4, kDraciLogicDebugLevel, "EscRoom: %d", _currentRoom._escRoom);
 	debugC(4, kDraciLogicDebugLevel, "Gates: %d", _currentRoom._numGates);
 
-
 	// Set cursor state
 	if (_currentRoom._mouseOn) {
 		debugC(6, kDraciLogicDebugLevel, "Mouse: ON");
@@ -231,7 +246,6 @@
 		_vm->_mouse->cursorOff();
 	}
 
-
 	Common::Array<int> gates;
 
 	for (uint i = 0; i < _currentRoom._numGates; ++i) {
@@ -276,6 +290,23 @@
 
 	f = _vm->_paletteArchive->getFile(_currentRoom._palette);
 	_vm->_screen->setPalette(f->_data, 0, kNumColours);
+
+	// HACK: Create a visible overlay from the walking map so we can test it
+	byte *wlk = new byte[kScreenWidth * kScreenHeight];
+	memset(wlk, 255, kScreenWidth * kScreenHeight);
+
+	for (uint i = 0; i < kScreenWidth; ++i) {
+		for (uint j = 0; j < kScreenHeight; ++j) {
+			if (_currentRoom._walkingMap.isWalkable(i, j)) {
+				wlk[j * kScreenWidth + i] = 2;
+			}
+		}
+	}
+
+	Sprite *ov = new Sprite(wlk, kScreenWidth, kScreenHeight, 0, 0, false);
+
+	Animation *map = _vm->_anims->addAnimation(-2, 255, false);
+	map->addFrame(ov);
 }
 
 int Game::loadAnimation(uint animNum, uint z) {
@@ -404,17 +435,20 @@
 	_vm->_screen->clearScreen();
 
 	_vm->_anims->deleteOverlays();
+	
+	// Delete walking map testing overlay
+	_vm->_anims->deleteAnimation(-2);
 
 	int oldRoomNum = _currentRoom._roomNum;
 
 	for (uint i = 0; i < _info._numObjects; ++i) {
 		GameObject *obj = &_objects[i];
-	
-		if (i != 0 && obj->_location == oldRoomNum) {
+		
+		if (i != 0 && (obj->_location == oldRoomNum)) {
 			for (uint j = 0; j < obj->_anims.size(); ++j) {
 					_vm->_anims->deleteAnimation(obj->_anims[j]);
-					obj->_anims.pop_back();
 			}
+			obj->_anims.clear();
 		}
 	}
 
@@ -459,4 +493,5 @@
 	return mapByte & (1 << pixelIndex % 8);
 }
 
+
 } 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list