Re: RPG objects
- Posted by Igor Kachan <kinz at peterlink.ru> Nov 21, 2001
- 359 views
Hi John, ---------- > ïÔ: John McAdam <johnmcadam at clix.pt> > ëÏÍÕ: EUforum <EUforum at topica.com> > ôÅÍÁ: RPG objects > äÁÔÁ: Wednesday, November 21, 2001 22:12 > > OK, so I got some objects in the RPG laying on the floor at x, y coordinates. > Now then what happens when the hero picks them up and puts them in a sack > in a box in his pack in his boat or wherever, or maybe one of the enemies picks > up something and puts it in his whatever. The objects don't have fixed x,y coordinates > so how do I keep track of where they are? I use global or local variables for the *similar* tasks, I do not write the games. For example: integer obj_1_x, obj_1_y integer obj_2_x, obj_2_y ------- and so on Or global sequence things things={{x1,y1},{x2,y2},{x3,y3},{0,0},{0,0},{0,0}} ------- and so on Then you can just use things[1][1] for not fixed x coordinate of the 1st thing and things[1][2] for not fixed y coordinate of the 1st thing. You drag this thing with mouse and reassign the current mouse's coordinates to that your variable. These variables are global or local, not private, so they keep new coordinates outside procedures and functions. Local - for include file's procedures and functions (or for main file's procedures and functions). Global - for all after the point of declaration. (refman.doc 2.4.2 Scope section) If you then drag the box full of the things, you just add box's coordinates to all things' coordinates. If me understand your question well, this method must work. Regards, Igor Kachan kinz at peterlink.ru