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

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Fri Jul 3 19:39:13 CEST 2009


Revision: 42067
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42067&view=rev
Author:   dkasak13
Date:     2009-07-03 17:39:13 +0000 (Fri, 03 Jul 2009)

Log Message:
-----------
Added support for mirrored sprites.

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

Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-07-03 16:41:11 UTC (rev 42066)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.cpp	2009-07-03 17:39:13 UTC (rev 42067)
@@ -61,7 +61,8 @@
 	 _x = x;
 	 _y = y;
 	 _z = z;
-	
+	_mirror = false;
+
 	_data = new byte[width * height];
 	
 	memcpy(_data, raw_data, width * height);
@@ -82,7 +83,8 @@
 	 _x = x;
 	 _y = y;
 	 _z = z;
-	
+	_mirror = false;	
+
 	Common::MemoryReadStream reader(sprite_data, length);
 
 	_width = reader.readUint16LE();
@@ -102,6 +104,14 @@
 	delete[] _data;
 }
 
+void Sprite::setMirrorOn() {
+	_mirror = true;
+}
+
+void Sprite::setMirrorOff() {
+	_mirror = false;
+}
+
 /**
  *  @brief Draws the sprite to a Draci::Surface
  *	@param surface Pointer to a Draci::Surface
@@ -113,14 +123,25 @@
 	byte *src = _data;	
 	
 	// Blit the sprite to the surface
-	for (unsigned int i = 0; i < _height; ++i) {
-		for(unsigned int j = 0; j < _width; ++j, ++src) {
+	for (int i = 0; i < _height; ++i) {
 
-			// Don't blit if the pixel is transparent on the target surface
-			if (*src != surface->getTransparentColour())			
-				dst[j] = *src;
+		// Draw the sprite mirrored if the _mirror flag is set
+		if (_mirror) {
+			for(int j = _width - 1; j >= 0; --j, ++src) {
+
+				// Don't blit if the pixel is transparent on the target surface
+				if (*src != surface->getTransparentColour())			
+					dst[j] = *src;
+			}		
+		} else {
+			for(int j = 0; j < _width; ++j, ++src) {
+
+				// Don't blit if the pixel is transparent on the target surface
+				if (*src != surface->getTransparentColour())			
+					dst[j] = *src;
+			}
 		}
-		
+
 		dst += surface->pitch;
 	}
 

Modified: scummvm/branches/gsoc2009-draci/engines/draci/sprite.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-07-03 16:41:11 UTC (rev 42066)
+++ scummvm/branches/gsoc2009-draci/engines/draci/sprite.h	2009-07-03 17:39:13 UTC (rev 42067)
@@ -84,11 +84,15 @@
 	~Sprite();
 
 	void draw(Surface *surface, bool markDirty = true) const;
+	
+	void setMirrorOn();
+	void setMirrorOff();
 
 	const byte *getBuffer() const { return _data; }
 
 private:
 	byte *_data;	//!< Pointer to a buffer containing raw sprite data (row-wise)
+	bool _mirror;
 };
 
 class Text : public Drawable {


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