[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2486 - in trunk/src: . actions
From: |
David Philippi at BerliOS |
Subject: |
[Pingus-CVS] r2486 - in trunk/src: . actions |
Date: |
Sun, 6 Nov 2005 18:16:25 +0100 |
Author: torangan
Date: 2005-11-06 18:16:24 +0100 (Sun, 06 Nov 2005)
New Revision: 2486
Modified:
trunk/src/actions/digger.cxx
trunk/src/blitter.cxx
trunk/src/blitter.hxx
trunk/src/spot_map.cxx
trunk/src/spot_map.hxx
Log:
patch to fix removing of tiles
Modified: trunk/src/actions/digger.cxx
===================================================================
--- trunk/src/actions/digger.cxx 2005-11-06 17:10:08 UTC (rev 2485)
+++ trunk/src/actions/digger.cxx 2005-11-06 17:16:24 UTC (rev 2486)
@@ -93,12 +93,12 @@
Digger::dig ()
{
WorldObj::get_world()->get_colmap()->remove(digger_radius,
- static_cast<int>(pingu->get_x() -
(digger_radius_width / 2)),
- static_cast<int>(pingu->get_y() -
digger_radius_height + 2));
+
static_cast<int>(pingu->get_pos().x - (digger_radius_width / 2)),
+
static_cast<int>(pingu->get_pos().y - digger_radius_height + 2));
WorldObj::get_world()->get_gfx_map()->remove(digger_radius_gfx,
- static_cast<int>(pingu->get_x ()
- (digger_radius_gfx_width / 2)),
- static_cast<int>(pingu->get_y()
- digger_radius_gfx_height + 2));
- pingu->set_y(pingu->get_y() + 1);
+
static_cast<int>(pingu->get_pos().x - (digger_radius_gfx_width / 2)),
+
static_cast<int>(pingu->get_pos().y - digger_radius_gfx_height + 2));
+ pingu->set_pos(pingu->get_pos().x, pingu->get_pos().y + 1.0f);
}
void
Modified: trunk/src/blitter.cxx
===================================================================
--- trunk/src/blitter.cxx 2005-11-06 17:10:08 UTC (rev 2485)
+++ trunk/src/blitter.cxx 2005-11-06 17:16:24 UTC (rev 2486)
@@ -230,72 +230,6 @@
}
void
-Blitter::put_alpha_surface(CL_PixelBuffer target, CL_PixelBuffer source,
- int x_pos, int y_pos)
-{
- assert(target.get_format().get_depth() == 32);
-
- target.lock();
- source.lock();
-
- int swidth = source.get_width();
- int twidth = target.get_width();
-
- int start_x = std::max(0, -x_pos);
- int start_y = std::max(0, -y_pos);
-
- int end_x = std::min(swidth, twidth - x_pos);
- int end_y = std::min(source.get_height(), target.get_height() - y_pos);
-
- if (end_x - start_x <= 0 || end_y - start_y <= 0)
- return;
-
- cl_uint8* target_buf = static_cast<cl_uint8*>(target.get_data());
- cl_uint8* source_buf = static_cast<cl_uint8*>(source.get_data());
-
- CL_Palette palette = source.get_palette();
-
- if (source.get_format().has_colorkey())
- {
- unsigned int colorkey = source.get_format().get_colorkey();
-
- for (int y = start_y; y < end_y; ++y)
- {
- cl_uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos +
start_x);
- cl_uint8* sptr = source_buf + swidth*y + start_x;
-
- for (int x = start_x; x < end_x; ++x)
- {
- if (*sptr != colorkey)
- *tptr = 0;
-
- tptr += 4;
- sptr += 1;
- }
- }
- }
- else
- {
- for (int y = start_y; y < end_y; ++y)
- {
- cl_uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos +
start_x);
- cl_uint8* sptr = source_buf + swidth*y + start_x;
-
- for (int x = start_x; x < end_x; ++x)
- {
- *tptr = 0;
-
- tptr += 4;
- sptr += 1;
- }
- }
- }
-
- source.unlock();
- target.unlock();
-}
-
-void
Blitter::fill_rect(CL_PixelBuffer target, const CL_Rect& rect, const CL_Color&
color)
{
if (target.get_format().get_depth() != 32
Modified: trunk/src/blitter.hxx
===================================================================
--- trunk/src/blitter.hxx 2005-11-06 17:10:08 UTC (rev 2485)
+++ trunk/src/blitter.hxx 2005-11-06 17:16:24 UTC (rev 2486)
@@ -57,11 +57,6 @@
static void put_surface(CL_PixelBuffer target, CL_PixelBuffer source,
int x, int y);
- /** Makes all pixels in canvas tranparent, when their indexed value
- in provider is larger than zero.*/
- static void put_alpha_surface(CL_PixelBuffer target, CL_PixelBuffer source,
- int x, int y);
-
/** Returns a newly allocated canvas. The canvas contains the same
image as the given surface. */
static CL_PixelBuffer create_canvas(const CL_Surface&);
Modified: trunk/src/spot_map.cxx
===================================================================
--- trunk/src/spot_map.cxx 2005-11-06 17:10:08 UTC (rev 2485)
+++ trunk/src/spot_map.cxx 2005-11-06 17:16:24 UTC (rev 2486)
@@ -30,6 +30,8 @@
#include "gettext.h"
#include "col_map.hxx"
#include "math.hxx"
+#include <ClanLib/Core/IOData/datatypes.h>
+#include <ClanLib/Display/palette.h>
namespace Pingus {
@@ -52,11 +54,12 @@
}
void
-MapTile::remove(CL_PixelBuffer obj, int x, int y)
+MapTile::remove(CL_PixelBuffer obj, int x, int y,
+ int real_x, int
real_y, PingusSpotMap* parent)
{
if (surface)
{
- Blitter::put_alpha_surface(pixelbuffer, obj, x, y);
+ parent->put_alpha_surface(pixelbuffer, obj, x, y, real_x, real_y);
surface = CL_Surface(pixelbuffer);
}
}
@@ -139,13 +142,16 @@
if (tile[x][y].get_surface())
{
gc.color().draw(tile[x][y].get_surface(),
- Vector(x * tile_size, y * tile_size));
+ Vector(static_cast<float>(x * tile_size),
+
static_cast<float>(y *
tile_size)));
}
else
{
if (pingus_debug_flags & PINGUS_DEBUG_TILES)
- gc.color().draw_fillrect(x * tile_size, y * tile_size,
- x * tile_size + tile_size, y *
tile_size + tile_size,
+ gc.color().draw_fillrect(static_cast<float>(x * tile_size),
+
static_cast<float>(y * tile_size),
+ static_cast<float>(x * tile_size +
tile_size),
+
static_cast<float>(y * tile_size + tile_size),
CL_Color(255, 0, 0, 75));
}
}
@@ -181,104 +187,80 @@
for(int iy = start_y; iy <= end_y; ++iy)
{
tile[ix][iy].remove(sprovider, x - (ix * tile_size),
- y - (iy * tile_size));
+ y - (iy * tile_size), x, y, this);
}
}
void
PingusSpotMap::put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer
sprovider,
- int x, int y, int real_x_arg, int real_y_arg)
+ int x_pos, int y_pos, int real_x_arg, int
real_y_arg)
{
- int start_i;
- unsigned char* tbuffer; // Target buffer
- int twidth, theight, tpitch;
-
- unsigned char* sbuffer; // Source buffer
- int swidth, sheight, spitch;
-
- int x_offset, y_offset;
-
- int real_x;
- int real_y;
-
- // assert(sprovider->get_depth() == 8);
if (sprovider.get_format().get_depth() != 8)
{
- char str[128];
- snprintf(str, 128, _("Image has wrong color depth: %d"),
sprovider.get_format().get_depth());
- PingusError::raise(str);
+
PingusError::raise(std::string("SpotMap::put_alpha_surface: Image has wrong
color depth: "
+ + sprovider.get_format().get_depth()));
}
- // assert(provider->get_pixel_format() == RGBA8888);
provider.lock();
sprovider.lock();
- tbuffer = static_cast<unsigned char*>(provider.get_data());
- sbuffer = static_cast<unsigned char*>(sprovider.get_data());
+ int swidth = sprovider.get_width();
+ int twidth = provider.get_width();
- twidth = provider.get_width();
- theight = provider.get_height();
- tpitch = provider.get_pitch();
+ int start_x = std::max(0, -x_pos);
+ int start_y = std::max(0, -y_pos);
- swidth = sprovider.get_width();
- sheight = sprovider.get_height();
- spitch = sprovider.get_pitch();
+ int end_x = std::min(swidth, twidth - x_pos);
+ int end_y = std::min(sprovider.get_height(), provider.get_height() - y_pos);
- if (y < 0) {
- y_offset = 0-y;
- } else {
- y_offset = 0;
- }
+ if (end_x - start_x <= 0 || end_y - start_y <= 0)
+ return;
- if (x < 0) {
- x_offset = -x;
- } else {
- x_offset = 0;
- }
+ cl_uint8* target_buf = static_cast<cl_uint8*>(provider.get_data());
+ cl_uint8* source_buf = static_cast<cl_uint8*>(sprovider.get_data());
- real_y = real_y_arg;
- real_x = real_x_arg;
+ CL_Palette palette = sprovider.get_palette();
- for(int line=y_offset; line < sheight && (line + y) < theight; ++line)
+ if (sprovider.get_format().has_colorkey())
{
- start_i = ((line + y) * tpitch) + (x*4);
+ unsigned int colorkey = sprovider.get_format().get_colorkey();
- real_x = real_x_arg;
- for(int i=start_i+(4*x_offset),j=line*spitch+x_offset;
- i < start_i + (4*swidth) && (i-start_i+(x*4)) < (4*twidth); i+=4,++j)
- {
- if (sbuffer[j])
- {
- if (pingus_debug_flags & PINGUS_DEBUG_ACTIONS)
- {
- if (!(colmap->getpixel(real_x, real_y) ==
Groundtype::GP_SOLID))
- {
- tbuffer[i + 0] = 255;
- tbuffer[i + 1] = 255;
- tbuffer[i + 2] = 255;
- tbuffer[i + 3] = 255;
- }
- else
- {
- tbuffer[i + 0] = 255;
- tbuffer[i + 1] = 255;
- tbuffer[i + 2] = 0;
- tbuffer[i + 3] = 0;
- }
- }
- else
- {
- if (!(colmap->getpixel(real_x, real_y) ==
Groundtype::GP_SOLID))
- {
- tbuffer[i + 0] = 0;
- }
- }
- }
- ++real_x;
- }
- ++real_y;
+ for (int y = start_y; y < end_y; ++y)
+ {
+ cl_uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos +
start_x);
+ cl_uint8* sptr = source_buf + swidth*y + start_x;
+
+ for (int x = start_x; x < end_x; ++x)
+ {
+ if (*sptr != colorkey
&&
+
colmap->getpixel(real_x_arg+x, real_y_arg+y)
+ !=
Groundtype::GP_SOLID)
+ *tptr = 0;
+
+ tptr += 4;
+ sptr += 1;
+ }
+ }
}
+ else
+ {
+ for (int y = start_y; y < end_y; ++y)
+ {
+ cl_uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos +
start_x);
+ cl_uint8* sptr = source_buf + swidth*y + start_x;
+ for (int x = start_x; x < end_x; ++x)
+ {
+ if (colmap->getpixel(real_x_arg+x, real_y_arg+y)
+ !=
Groundtype::GP_SOLID)
+ *tptr = 0;
+
+ tptr += 4;
+ sptr += 1;
+ }
+ }
+ }
+
sprovider.unlock();
provider.unlock();
}
Modified: trunk/src/spot_map.hxx
===================================================================
--- trunk/src/spot_map.hxx 2005-11-06 17:10:08 UTC (rev 2485)
+++ trunk/src/spot_map.hxx 2005-11-06 17:16:24 UTC (rev 2486)
@@ -33,6 +33,7 @@
class PingusLevel;
class ColMap;
+class PingusSpotMap;
class MapTile
{
@@ -45,7 +46,7 @@
MapTile();
~MapTile();
- void remove(CL_PixelBuffer, int x, int y);
+ void remove(CL_PixelBuffer, int x, int y, int real_x, int real_y,
PingusSpotMap*);
void put(CL_PixelBuffer, int x, int y);
CL_Surface get_surface() const { return surface; }
@@ -85,17 +86,18 @@
void put(CL_PixelBuffer, int x, int y);
/** Remove the gives surface provider onto the given coordinates
- (everything non-transparent is removed from the map) */
+ (everything non-transparent that isn't Groundtype::GP_Solid
+ is removed from the map) */
void remove(CL_PixelBuffer, int x, int y);
float get_z_pos () const { return 0; }
-private:
- /** Low level version of the remove() call, acts on a single canvas
- instead on the complete map-tiles */
+ /** Low level version of the remove() call, acts on a single tile
+ instead of the complete map-tiles */
void put_alpha_surface(CL_PixelBuffer provider, CL_PixelBuffer sprovider,
int x, int y, int real_x, int real_y);
+private:
/** Draw the collision map onto the screen */
void draw_colmap(SceneContext& gc);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2486 - in trunk/src: . actions,
David Philippi at BerliOS <=