I have the following map system for my RPG: the world map is divided into smaller, screen-sized maps, and the world map consists of 20 by 15 of these. They are each labelled by four digits, two for the x-coordinate (starting at 10), and two for the y-coordinate (starting at 10), and thus, for instance, 1010 is in the upper left corner and is right above 1011. In this way, the x and y coordinates of the current screen-sized map can be changed by adding or subtracting 100 or 1, respectively.
The problem arises when tring to load the data for each of these maps (which reside within the actual source code) into the "map" array. As soon as the character moves down off the screen, 1 is added to the map number, changing 1010 to 1011, and it copies the data for 1011 into the map variable. It then loads the 1011 map without a problem. However, when I try to backtrack to 1010, the program errors, and remarks that it is out of data. I am not sure, but I believe that this may be due to the fact that I have no command to clear the "map" array before loading the new data, but I have looked into this, and cannot find a solution myself. Please help, if you know how I could solve the problem, or perhaps if you know how I could write the arrays to a file and load them at need (I feel that might work, but I am not adept in the art of loading and saving).
Thanks.
Array Issues
Moderators:Administrator, Global Moderator
Justly is our impending doom thrust upon us, for mightily did we scar Gaia with our conquest out of laze, and so long coming has been our demise. You have been warned. The anguish is yours. -Aaron-
-
- QBasic God
- Posts:166
- Joined:Tue Mar 25, 2003 12:45 am
- Location:U.S.A.
- Contact:
I wouldn't reccomend using DATA statements on the fly, but it sounds like you could just use RESTORE...
See how it works?
Code: Select all
Do
RESTORE MyData
For i = 1 to 2
Read Temp
Print Temp
Next
Loop Until Inkey$=Chr$(27)
MyData:
DATA 25338
DATA 17475
Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!