This topic is now archived and is closed to further replies.


Monster in Tile Game

Recommended Posts

PsYchOtroW    122
Hi, i have some probs with the monsters in my Tile Based RPG. My Object class looks like this: class cObject { public: cObject( ); virtual ~cObject( ); int LoadMap( char *path ); int Draw( ); int Create( ); int GetMaxX( ); int GetMaxY( ); int GetContent( int x, int y ); int objX; int objY; int Collision( ); private: int zeilen; int spalten; // ifstream Datei; // char *plan; int* plan; FILE* datei; int index; int index_x, index_y; // looping vars int start_map_x,start_map_y, // map positions end_map_x,end_map_y; int offset_x, offset_y; // pixel offsets within cell }; extern cObject obj; It loads the objects from a file. And Draws it. So now i don`t know how i can implement monsters. Does anyone have some examples or links for tutorials? Thanks Lutz Hören

Share this post

Link to post
Share on other sites
Zombie    122
Well, my data struct is like this: (visual basic )
type g_object
pointerx as int
pointery as int
left as int
top as int
+some others
end type

Now, I get this pointer by dividing left and top (x1, y1) by mapsize, which is in tiles. Now there''s the coordinates on the map. You can add an offset there, too. Then render it like you render the others, this is my way to do it (didn''t figure anything else, it is probably somewhat slow).
for xi= 1 to ubound(g_object)
if wx = g_object(xi).pointerx and wy = g_object(xi).pointery then
''render it
end if

wx and wy are the locations of the tile you''re currently rendering.

UBound is the upper bound of an array. You''re going to have more than one monster there too, don''t you?

(Yippee, this'' my first answer to a question :D)

Share this post

Link to post
Share on other sites