Byte Knight Posted February 20, 2009 Share Posted February 20, 2009 Hi guys, I'm trying to set up levels for my adventure-type game. Ideally I'd like to be able to use data arrays to hold level data like the room and x/y coordinates of where the keys, staff, and chalice go. To access this, I'd like to store the data for the different levels under the same data name. I was hoping to be able to randomly select the data from 16 different levels this way. For example, t=rand/16 on t goto level1, level2, ..., level16 level1 data position 15, 77, 20, 12, 77, 20, 3, 78, 24 end goto main level2 data position 10, 77, 64, 21, 132, 17, 13, 49, 86 end goto main Then, later in the main loop of the program, to access the data to display something like the key: keyroom=position[1] player0x=position[2]:player0y=position[3] The problem, of course, is that you cannot write new data to rom even though only one data array is actually used for the program. Part of the reason I'd like to use data arrays is that I'm out of variables... Is there away around this? Thanks! Quote Link to comment Share on other sites More sharing options...
+batari Posted February 21, 2009 Share Posted February 21, 2009 One way around that is to create a large position table, as: data position 15, 77, 20, 12, 77, 20, 3, 78, 24 10, 77, 64, 21, 132, 17, 13, 49, 86 ... and so on ... end Access this large table by: t=rand/16 temp1=t*8 keyroom=position[temp1] temp1=temp+1 player0x=position[temp1] temp1=temp+1 player0y=position[temp1] This will leave t with your level, and will use data for the appropriate level without needing the on...goto or multiple arrays. Quote Link to comment Share on other sites More sharing options...
Byte Knight Posted February 21, 2009 Author Share Posted February 21, 2009 Thanks Batari! I didn't know you could use variables inside the brackets... I'll give 'er a try. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.