00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef SPACEORG_H
00031 #define SPACEORG_H
00032
00033 #include <list>
00034 #include "Sprite.h"
00035
00036 #define SPACEORG_SOLID_BIT 0x40000000u
00037
00038 typedef struct{
00039 std::list<Sprite*> solid;
00040 std::list<Sprite*> transparent;
00041 }space_segment_t;
00042
00043 class SpaceOrg
00044 {
00045 protected:
00046 space_segment_t **space;
00047 float size_x, size_y;
00048 float resolution;
00049 int cull_segments;
00050 unsigned int squares_x;
00051 unsigned int squares_y;
00052
00053 public:
00054 SpaceOrg(float x_size, float y_size, float res, int no_segments_cull);
00055 ~SpaceOrg(void);
00056 void putSprite(Sprite *sprite, unsigned int index);
00057 int delSprite(Sprite *sprite, unsigned int index);
00058 int putTransparent(Sprite *sprite, unsigned int &index);
00059 void updateSpritePos(Sprite *sprite, unsigned int &index);
00060
00061
00062 std::list<Sprite*> *getSprites(unsigned int &index, int xoffset, int yoffset);
00063
00064 std::list<Sprite*> *getSprites(float x_pos, float y_pos);
00065 void getIndexForPos(float x_pos, float y_pos, unsigned int &index);
00066 void draw(void);
00067
00068
00069 int getIndexForSprite(Sprite *sprite, int *index_x, int *index_y);
00070
00071 protected:
00072 inline unsigned int coord2Index(float x, float y);
00073 inline int indexGetX(unsigned int index);
00074 inline int indexGetY(unsigned int index);
00075 inline bool indexIsSolid(unsigned int index);
00076 void setCullArea(int *check_start_x, int *check_start_y,
00077 int *check_stop_x, int *check_stop_y);
00078
00079 };
00080
00081 #endif