[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r2884 - in branches/pingus_sdl: . src src/worldobjs
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r2884 - in branches/pingus_sdl: . src src/worldobjs |
Date: |
Mon, 13 Aug 2007 17:55:03 +0200 |
Author: grumbel
Date: 2007-08-13 17:55:01 +0200 (Mon, 13 Aug 2007)
New Revision: 2884
Modified:
branches/pingus_sdl/TODO
branches/pingus_sdl/src/col_map.cpp
branches/pingus_sdl/src/col_map.hpp
branches/pingus_sdl/src/collision_mask.cpp
branches/pingus_sdl/src/collision_mask.hpp
branches/pingus_sdl/src/ground_map.cpp
branches/pingus_sdl/src/worldobjs/exit.cpp
branches/pingus_sdl/src/worldobjs/exit.hpp
Log:
- fixed ColMap::remove
- fixed Exit removing itself from the colmap
Modified: branches/pingus_sdl/TODO
===================================================================
--- branches/pingus_sdl/TODO 2007-08-13 15:11:04 UTC (rev 2883)
+++ branches/pingus_sdl/TODO 2007-08-13 15:55:01 UTC (rev 2884)
@@ -44,8 +44,9 @@
Important:
==========
-- exit wrong at data/levels/tutorial/snow12-grumbel.scm (colmap removal buggy?)
+- only auto/border-scroll with screengrab or fullscreen
+
- in old levels the exits float high up in the air (conversion likely wrong)
- update INSTALL.* file
Modified: branches/pingus_sdl/src/col_map.cpp
===================================================================
--- branches/pingus_sdl/src/col_map.cpp 2007-08-13 15:11:04 UTC (rev 2883)
+++ branches/pingus_sdl/src/col_map.cpp 2007-08-13 15:55:01 UTC (rev 2884)
@@ -81,25 +81,28 @@
}
void
-ColMap::remove(const CollisionMask& mask, int x, int y)
+ColMap::remove(const CollisionMask& mask, int x_pos, int y_pos)
{
++serial;
int swidth = mask.get_width();
- int spitch = mask.get_pitch();
int sheight = mask.get_height();
- int y_offset = Math::max(-y, 0);
- int x_offset = Math::max(-x, 0);
uint8_t* buffer = mask.get_data();
- for (int line = y_offset; line < sheight && (line + y) < height; ++line)
+ int start_x = Math::max(0, -x_pos);
+ int start_y = Math::max(0, -y_pos);
+ int end_x = Math::min(swidth, width - x_pos);
+ int end_y = Math::min(sheight, height - y_pos);
+
+ for (int y = start_y; y < end_y; ++y)
{
- for (int i = x_offset; i < swidth && (i+x) < width; ++i)
+ for (int x = start_x; x < end_x; ++x)
{
- if (buffer[i + (spitch*line)])
+ if (buffer[y*swidth + x])
{
- if (colmap[i + (width*(line+y) + x)] != Groundtype::GP_SOLID)
- colmap[i + (width*(line+y) + x)] = Groundtype::GP_NOTHING;
+ uint8_t& pixel = colmap[(y+y_pos)*width + (x+x_pos)];
+ if (pixel != Groundtype::GP_SOLID)
+ pixel = Groundtype::GP_NOTHING;
}
}
}
@@ -175,64 +178,50 @@
canvas.lock();
buffer = static_cast<unsigned char*>(canvas.get_data());
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ const int red = 3;
+ const int green = 2;
+ const int blue = 1;
+ const int alpha = 0;
+#else
+ const int red = 0;
+ const int green = 1;
+ const int blue = 2;
+ const int alpha = 3;
+#endif
+
+ uint8_t trans = 220;
+
for(int i = 0; i < (width * height); ++i)
{
switch(colmap[i])
{
case Groundtype::GP_NOTHING:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- buffer[i * 4 + 0] = 0;
- buffer[i * 4 + 1] = 0;
- buffer[i * 4 + 2] = 0;
- buffer[i * 4 + 3] = 0;
-#else
- buffer[i * 4 + 3] = 0;
- buffer[i * 4 + 2] = 0;
- buffer[i * 4 + 1] = 0;
- buffer[i * 4 + 30] = 0;
-#endif
+ buffer[i * 4 + red ] = 0;
+ buffer[i * 4 + green] = 0;
+ buffer[i * 4 + blue ] = 0;
+ buffer[i * 4 + alpha] = 0;
break;
case Groundtype::GP_SOLID:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- buffer[i * 4 + 0] = 255;
- buffer[i * 4 + 1] = 100;
- buffer[i * 4 + 2] = 100;
- buffer[i * 4 + 3] = 100;
-#else
- buffer[i * 4 + 3] = 255;
- buffer[i * 4 + 2] = 100;
- buffer[i * 4 + 1] = 100;
- buffer[i * 4 + 30] = 100;
-#endif
+ buffer[i * 4 + red ] = 100;
+ buffer[i * 4 + green] = 100;
+ buffer[i * 4 + blue ] = 100;
+ buffer[i * 4 + alpha] = trans;
break;
case Groundtype::GP_BRIDGE:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- buffer[i * 4 + 0] = 255;
- buffer[i * 4 + 1] = 0;
- buffer[i * 4 + 2] = 0;
- buffer[i * 4 + 3] = 200;
-#else
- buffer[i * 4 + 3] = 255;
- buffer[i * 4 + 2] = 0;
- buffer[i * 4 + 1] = 0;
- buffer[i * 4 + 0] = 200;
-#endif
+ buffer[i * 4 + red ] = 200;
+ buffer[i * 4 + green] = 0;
+ buffer[i * 4 + blue ] = 0;
+ buffer[i * 4 + alpha] = trans;
break;
default:
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- buffer[i * 4 + 0] = 255;
- buffer[i * 4 + 1] = 200;
- buffer[i * 4 + 2] = 200;
- buffer[i * 4 + 3] = 200;
-#else
- buffer[i * 4 + 3] = 255;
- buffer[i * 4 + 2] = 200;
- buffer[i * 4 + 1] = 200;
- buffer[i * 4 + 0] = 200;
-#endif
+ buffer[i * 4 + red ] = 200;
+ buffer[i * 4 + green] = 200;
+ buffer[i * 4 + blue ] = 200;
+ buffer[i * 4 + alpha] = trans;
break;
}
}
@@ -240,7 +229,7 @@
canvas.unlock();
Sprite sprite(canvas);
- gc.draw(sprite, 0, 0);
+ gc.draw(sprite, 0, 0, 1000);
}
unsigned
Modified: branches/pingus_sdl/src/col_map.hpp
===================================================================
--- branches/pingus_sdl/src/col_map.hpp 2007-08-13 15:11:04 UTC (rev 2883)
+++ branches/pingus_sdl/src/col_map.hpp 2007-08-13 15:55:01 UTC (rev 2884)
@@ -46,7 +46,7 @@
int height;
/** A array of uchar, each uchar represents a pixel on the map. */
- unsigned char* colmap;
+ uint8_t* colmap;
public:
/** Init the colmap from a given area of memory.
Modified: branches/pingus_sdl/src/collision_mask.cpp
===================================================================
--- branches/pingus_sdl/src/collision_mask.cpp 2007-08-13 15:11:04 UTC (rev
2883)
+++ branches/pingus_sdl/src/collision_mask.cpp 2007-08-13 15:55:01 UTC (rev
2884)
@@ -65,7 +65,7 @@
{
uint8_t* source = static_cast<uint8_t*>(surface->pixels);
if (surface->flags & SDL_SRCCOLORKEY)
- {
+ { // surface with transparent areas
for(int y = 0; y < height; ++y)
for(int x = 0; x < width; ++x)
{
@@ -76,7 +76,7 @@
}
}
else
- {
+ { // completly opaque surface
memset(buffer, 1, width*height);
}
}
@@ -119,12 +119,6 @@
return height;
}
-int
-CollisionMask::get_pitch() const
-{
- return pixelbuffer.get_surface()->pitch;
-}
-
PixelBuffer
CollisionMask::get_pixelbuffer() const
{
Modified: branches/pingus_sdl/src/collision_mask.hpp
===================================================================
--- branches/pingus_sdl/src/collision_mask.hpp 2007-08-13 15:11:04 UTC (rev
2883)
+++ branches/pingus_sdl/src/collision_mask.hpp 2007-08-13 15:55:01 UTC (rev
2884)
@@ -47,7 +47,6 @@
int get_width() const;
int get_height() const;
- int get_pitch() const;
PixelBuffer get_pixelbuffer() const;
uint8_t* get_data() const;
Modified: branches/pingus_sdl/src/ground_map.cpp
===================================================================
--- branches/pingus_sdl/src/ground_map.cpp 2007-08-13 15:11:04 UTC (rev
2883)
+++ branches/pingus_sdl/src/ground_map.cpp 2007-08-13 15:55:01 UTC (rev
2884)
@@ -118,38 +118,34 @@
// FIXME: delete the next four lines and replace them with gc.get_clip_rect()
if (draw_collision_map)
- {
- draw_colmap(gc);
- }
- else
- {
- // Trying to calc which parts of the tilemap needs to be drawn
- int start_x = Math::max(0, display.left/tile_size);
- int start_y = Math::max(0, display.top/tile_size);
- int tilemap_width = display.get_width() / tile_size + 1;
- int tilemap_height = display.get_height() / tile_size + 1;
+ draw_colmap(gc);
- // drawing the stuff
- for (int x = start_x; x <= (start_x + tilemap_width) && x <
int(tile.size()); ++x)
- for (int y = start_y; y <= start_y + tilemap_height && y <
int(tile[x].size()); ++y)
+ // Trying to calc which parts of the tilemap needs to be drawn
+ int start_x = Math::max(0, display.left/tile_size);
+ int start_y = Math::max(0, display.top/tile_size);
+ int tilemap_width = display.get_width() / tile_size + 1;
+ int tilemap_height = display.get_height() / tile_size + 1;
+
+ // drawing the stuff
+ for (int x = start_x; x <= (start_x + tilemap_width) && x <
int(tile.size()); ++x)
+ for (int y = start_y; y <= start_y + tilemap_height && y <
int(tile[x].size()); ++y)
+ {
+ if (tile[x][y].get_sprite())
{
- if (tile[x][y].get_sprite())
- {
- //std::cout << "Drawing GroundMap Tile " << std::endl;
- gc.color().draw(tile[x][y].get_sprite(),
- Vector3f((float)x * tile_size, (float)y *
tile_size));
- }
- else
- {
- if (0 /*pingus_debug_flags & PINGUS_DEBUG_TILES*/)
- gc.color().draw_fillrect((float)x * tile_size,
- (float)y * tile_size,
- (float)x * tile_size + tile_size,
- (float)y * tile_size + tile_size,
- Color(255, 0, 0, 75));
- }
+ //std::cout << "Drawing GroundMap Tile " << std::endl;
+ gc.color().draw(tile[x][y].get_sprite(),
+ Vector3f((float)x * tile_size, (float)y *
tile_size));
}
- }
+ else
+ {
+ if (0 /*pingus_debug_flags & PINGUS_DEBUG_TILES*/)
+ gc.color().draw_fillrect((float)x * tile_size,
+ (float)y * tile_size,
+ (float)x * tile_size + tile_size,
+ (float)y * tile_size + tile_size,
+ Color(255, 0, 0, 75));
+ }
+ }
}
// Returns the width of the map, it is read directly from the *.psm file
Modified: branches/pingus_sdl/src/worldobjs/exit.cpp
===================================================================
--- branches/pingus_sdl/src/worldobjs/exit.cpp 2007-08-13 15:11:04 UTC (rev
2883)
+++ branches/pingus_sdl/src/worldobjs/exit.cpp 2007-08-13 15:55:01 UTC (rev
2884)
@@ -34,8 +34,6 @@
Exit::Exit(const FileReader& reader)
: smallmap_symbol(Resource::load_sprite("core/misc/smallmap_exit"))
{
- ResDescriptor desc;
-
reader.read_vector("position", pos);
reader.read_desc ("surface", desc);
reader.read_int ("owner-id", owner_id);
@@ -58,7 +56,8 @@
void
Exit::on_startup ()
{
- CollisionMask mask =
Resource::load_collision_mask("core/misc/smallmap_exit");
+ // FIXME: This will fail with exits that contain multiple frames
+ CollisionMask mask(desc);
world->get_colmap()->remove(mask,
static_cast<int>(pos.x) - sprite.get_width()/2,
static_cast<int>(pos.y) - sprite.get_height());
Modified: branches/pingus_sdl/src/worldobjs/exit.hpp
===================================================================
--- branches/pingus_sdl/src/worldobjs/exit.hpp 2007-08-13 15:11:04 UTC (rev
2883)
+++ branches/pingus_sdl/src/worldobjs/exit.hpp 2007-08-13 15:55:01 UTC (rev
2884)
@@ -32,6 +32,7 @@
class Exit : public WorldObj
{
private:
+ ResDescriptor desc;
Vector3f pos;
int owner_id;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r2884 - in branches/pingus_sdl: . src src/worldobjs,
grumbel at BerliOS <=