Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
minkus
22
Years of Service
User Offline
Joined: 18th Jan 2003
Location: My House
Posted: 27th Aug 2003 23:51 Edited at: 28th Aug 2003 00:06
im making a game with like 100 different levels (so far ive made 1) and i need to know how to store data under the data command without writing every single "read word" for every bit of data... because have a 60*40 grid with a 2 - digit number for each square )like 54

[edit]

maybe that wasnt very clear

my file that i have made:



my code:



but now, it comes up with 20 seemingly random numbers... not the contents of the file... HELP!!

They say I'm crazy
but I'm actually REALLY crazy
Chiwawa
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location: Canada
Posted: 28th Aug 2003 01:24
lol..... it wont read a WORD....it will reay 2 byte (a word) ..but this is not a STRING...you should use: read STRING!!!!!!

minkus
22
Years of Service
User Offline
Joined: 18th Jan 2003
Location: My House
Posted: 28th Aug 2003 02:10 Edited at: 28th Aug 2003 02:11
but i dont want to get a string i want a 2*-digit number

* = 2 digits, 2 bytes?

They say I'm crazy
but I'm actually REALLY crazy
Wik
21
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 28th Aug 2003 04:45


The rock has rolled!
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 28th Aug 2003 13:53
your file is actualy a text file, I guess you made it in word or something, if you had written the file from DarkBasic with write word, then you would have got back the correct numbers, but if you had opened it in word it would have been gibberish, different formats, so you need to load each line as a string and then convert it to a number, for example the first line in text will be....

0=ascii 48.......these are the two bytes
1=ascii 49.......you will get in the first word
return=ascii 13

so when you read the word it returns a totaly wrong numeric value (several thousand for a guess), the next time you read a word you get 13 and the ascii for zero from the next number (48) and so on, this is because the numbers are saved as text (strings) so to read them correctly you need to get them as a string and then convert to numbers with val, cheers.

Mentor.
minkus
22
Years of Service
User Offline
Joined: 18th Jan 2003
Location: My House
Posted: 28th Aug 2003 20:01 Edited at: 28th Aug 2003 20:22
actually, i made it in notepad...

[edit] oh... i get it now! thanks

but if i were to make it like a group of data statements like so:



it would return 1, 7 and a bunch of 0s

They say I'm crazy
but theyre wrong
I'm actually REALLY crazy
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 29th Aug 2003 07:53
make a 2d array
dim myarray(60,40)
rem its really 61,41 but for sanity and clarity we skip the zero


location of the array
store the contents of the 2dimensional data into each array location.

for x = 1 to 60
for y = 1 to 40
myarray(x,y)= rnd(9)+1 :rem your data value eg 1 - 10
next x
next y

save the array using save array
rem use a zero regardless of created size if using classic
save array "lvlX.dat",myarray(0)
load it back in using load array
rem use a zero regardless of created size
load array "lvlX.dat",myarray(0)


undim arrays when you end your proggy or dont need to use them any more

http://www.lunarpixel.com
It's already tomorrow in Australia

Login to post a reply

Server time is: 2025-05-20 01:53:33
Your offset time is: 2025-05-20 01:53:33