Monster in Tile Game

Started by
1 comment, last by PsYchOtroW 23 years, 5 months ago
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
psYchOtroW
Advertisement
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)
yes, that`s my prob.
psYchOtroW

This topic is closed to new replies.

Advertisement