[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2709 - branches/pingus_sdl/src
From: |
jsalmon3 |
Subject: |
[Pingus-CVS] r2709 - branches/pingus_sdl/src |
Date: |
Wed, 11 Jul 2007 06:28:45 +0200 |
Author: jsalmon3
Date: 2007-07-11 06:28:40 +0200 (Wed, 11 Jul 2007)
New Revision: 2709
Modified:
branches/pingus_sdl/src/col_map.cpp
branches/pingus_sdl/src/ground_map.cpp
branches/pingus_sdl/src/world.cpp
Log:
Added World::remove, ColMap::remove, MapTile::remove,
GroundMap::put_alpha_surface
Modified: branches/pingus_sdl/src/col_map.cpp
===================================================================
--- branches/pingus_sdl/src/col_map.cpp 2007-07-11 03:21:54 UTC (rev 2708)
+++ branches/pingus_sdl/src/col_map.cpp 2007-07-11 04:28:40 UTC (rev 2709)
@@ -78,25 +78,24 @@
void
ColMap::remove(const CollisionMask& mask, int x, int y)
{
-#if 0
++serial;
- int swidth = provider.get_width();
- int sheight = provider.get_height();
- int y_offset = -y;
- int x_offset = -x;
- if (y_offset < 0) y_offset = 0;
- if (x_offset < 0) x_offset = 0;
+ int swidth = mask.get_width();
+ int sheight = mask.get_height();
+ int y_offset = -y;
+ int x_offset = -x;
+ if (y_offset < 0) y_offset = 0;
+ if (x_offset < 0) x_offset = 0;
- provider.lock();
+ mask.get_pixelbuffer().lock();
- if (provider.get_format().get_depth() == 32)
+ if (mask.get_pixelbuffer().get_surface()->format->BitsPerPixel == 32)
{
for(int line = y_offset; line < sheight && (line + y) < height;
++line)
{
for (int i = x_offset; i < swidth && (i+x) < width; ++i)
{
- if (provider.get_pixel(i, line).get_alpha() !=
0)
+ if (mask.get_pixelbuffer().get_pixel(i, line).a
!= 0)
{
if (colmap[i + (width*(line+y) + x)] !=
Groundtype::GP_SOLID)
colmap[i + (width*(line+y) +
x)] = Groundtype::GP_NOTHING;
@@ -104,10 +103,10 @@
}
}
}
- else if (provider.get_format().get_depth() == 8)
+ else if (mask.get_pixelbuffer().get_surface()->format->BitsPerPixel ==
8)
{
unsigned char* buffer;
- buffer = static_cast<unsigned char*>(provider.get_data());
+ buffer = static_cast<unsigned
char*>(mask.get_pixelbuffer().get_data());
for(int line = y_offset; line < sheight && (line + y) < height;
++line)
{
@@ -126,8 +125,7 @@
PingusError::raise("ColMap::remove() - image format not
supported");
}
- provider.unlock();
-#endif
+ mask.get_pixelbuffer().unlock();
}
void
Modified: branches/pingus_sdl/src/ground_map.cpp
===================================================================
--- branches/pingus_sdl/src/ground_map.cpp 2007-07-11 03:21:54 UTC (rev
2708)
+++ branches/pingus_sdl/src/ground_map.cpp 2007-07-11 04:28:40 UTC (rev
2709)
@@ -27,6 +27,7 @@
#include "gettext.h"
#include "col_map.hpp"
#include "math.hpp"
+#include "SDL.h"
MapTile::MapTile ()
{
@@ -56,13 +57,11 @@
MapTile::remove(PixelBuffer obj, int x, int y,
int real_x, int real_y, GroundMap* parent)
{
-#if 0
- if (surface)
+ if (sprite)
{
parent->put_alpha_surface(pixelbuffer, obj, x, y, real_x, real_y);
- surface = CL_Surface(pixelbuffer);
+ sprite = Sprite(pixelbuffer);
}
-#endif
}
void
@@ -196,11 +195,10 @@
GroundMap::put_alpha_surface(PixelBuffer provider, PixelBuffer sprovider,
int x_pos, int y_pos, int real_x_arg, int
real_y_arg)
{
-#if 0
- if (sprovider.get_format().get_depth() != 8)
+ if (sprovider.get_surface()->format->BitsPerPixel != 8)
{
PingusError::raise(std::string("SpotMap::put_alpha_surface: Image has
wrong color depth: "
- + sprovider.get_format().get_depth()));
+ +
sprovider.get_surface()->format->BitsPerPixel));
}
provider.lock();
@@ -218,28 +216,27 @@
if (end_x - start_x <= 0 || end_y - start_y <= 0)
return;
- cl_uint8* target_buf = static_cast<cl_uint8*>(provider.get_data());
- cl_uint8* source_buf = static_cast<cl_uint8*>(sprovider.get_data());
+ Uint8* target_buf = static_cast<Uint8*>(provider.get_data());
+ Uint8* source_buf = static_cast<Uint8*>(sprovider.get_data());
- CL_Palette palette = sprovider.get_palette();
-
- if (sprovider.get_format().has_colorkey())
+ if (sprovider.get_surface()->flags & SDL_SRCCOLORKEY)
{
- unsigned int colorkey = sprovider.get_format().get_colorkey();
+ Uint32 colorkey = sprovider.get_surface()->format->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;
+ Uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos + start_x);
+ 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)
- { // FIXME: Slow?! if inside a blit loop probally not such a
good idea
- if (!CL_Endian::is_system_big())
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*tptr = 0;
- else
+#else
tptr[3] = 0;
+#endif
}
tptr += 4;
@@ -251,17 +248,18 @@
{
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;
+ Uint8* tptr = target_buf + 4*((twidth*(y+y_pos)) + x_pos + start_x);
+ 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)
- { // FIXME: if inside blit loop might not be such a good idea
- if (!CL_Endian::is_system_big())
+ {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
*tptr = 0;
- else
+#else
tptr[3] = 0;
+#endif
}
tptr += 4;
@@ -272,7 +270,6 @@
sprovider.unlock();
provider.unlock();
-#endif
}
void
Modified: branches/pingus_sdl/src/world.cpp
===================================================================
--- branches/pingus_sdl/src/world.cpp 2007-07-11 03:21:54 UTC (rev 2708)
+++ branches/pingus_sdl/src/world.cpp 2007-07-11 04:28:40 UTC (rev 2709)
@@ -287,8 +287,10 @@
}
void
-World::remove(const CollisionMask&, int x, int y)
+World::remove(const CollisionMask& mask, int x, int y)
{
+ gfx_map->remove(mask.get_pixelbuffer(), x, y);
+ colmap->remove(mask, x, y);
}
/* EOF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2709 - branches/pingus_sdl/src,
jsalmon3 <=