Jump to content
IGNORED

Data array question


Byte Knight

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...