[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] CVS: Games/Pingus/src/editor sprite_editorobj.cxx,1.8,1.9
From: |
grumbel |
Subject: |
[Pingus-CVS] CVS: Games/Pingus/src/editor sprite_editorobj.cxx,1.8,1.9 |
Date: |
31 Mar 2003 23:26:16 -0000 |
Update of /var/lib/cvs/Games/Pingus/src/editor
In directory dark:/tmp/cvs-serv3706/src/editor
Modified Files:
sprite_editorobj.cxx
Log Message:
- fixed missing align handling
- added range-check
- made generic entrance a bit less transparent
Index: sprite_editorobj.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/editor/sprite_editorobj.cxx,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- sprite_editorobj.cxx 28 Sep 2002 11:52:23 -0000 1.8
+++ sprite_editorobj.cxx 31 Mar 2003 23:26:13 -0000 1.9
@@ -17,8 +17,10 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#include <iostream>
#include <assert.h>
#include <ClanLib/Display/Display/surfaceprovider.h>
+#include "../math.hxx"
#include "editor_view.hxx"
#include "sprite_editorobj.hxx"
@@ -104,18 +106,35 @@
// FIXME: We don't handle animated objects special (do we need to?)
if (RectEditorObj::is_over (pos))
{
- //std::cout << "ClickPos: " << pos.x << ", " << pos.y
- //<< " ObjectPos: " << pos_ref.x << ", " << pos_ref.y << std::endl;
-
+#if 1 // EDITOR_PIXEL_PERFECT_IS_OVER
CL_SurfaceProvider* provider = sprite.get_surface ().get_provider ();
- float r, g, b, a;
- // Position relative to the surface, not world
- Vector provider_pos = pos;
- provider_pos -= *pos_ref;
+ if (provider)
+ {
+ // Position relative to the surface, not world
+ int provider_pos_x = (int)pos.x;
+ int provider_pos_y = (int)pos.y;
- provider->get_pixel (int(provider_pos.x), int(provider_pos.y), &r, &g,
&b, &a);
- //std::cout << "Color: " << r << " " << g << " " << b << " " << a <<
std::endl;
- return (a >= 0.0f);
+ provider_pos_x -= int(pos_ref->x);
+ provider_pos_y -= int(pos_ref->y);
+
+ provider_pos_x -= sprite.get_x_align();
+ provider_pos_y -= sprite.get_y_align();
+
+ provider_pos_x = Math::mid(0, provider_pos_x,
int(provider->get_width()-1));
+ provider_pos_y = Math::mid(0, provider_pos_y,
int(provider->get_height()-1));
+
+ float r, g, b, a;
+ provider->get_pixel (int(provider_pos_x), int(provider_pos_y), &r,
&g, &b, &a);
+ return (a > 0.0f);
+ }
+ else
+ {
+ std::cout << "ERROR: SpriteEditorObj: Failed to get provider for
surface" << std::endl;
+ return true;
+ }
+#else
+ return true;
+#endif
}
else
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] CVS: Games/Pingus/src/editor sprite_editorobj.cxx,1.8,1.9,
grumbel <=
- Prev by Date:
[Pingus-CVS] CVS: Games/Pingus/src pingus_main.cxx,1.59,1.60 pingus_main.hxx,1.8,1.9
- Next by Date:
[Pingus-CVS] CVS: Games/Pingus/data/images/entrances generic.png,1.2,1.3
- Previous by thread:
[Pingus-CVS] CVS: Games/Pingus/src pingus_main.cxx,1.59,1.60 pingus_main.hxx,1.8,1.9
- Next by thread:
[Pingus-CVS] CVS: Games/Pingus/data/images/entrances generic.png,1.2,1.3
- Index(es):