Loading up an Array from string in DAT section
CassLan
Posts: 586
Hi,
I'm assuming the DAT section in a spin program would be the place to keep a game level.
I have a simple map:
DAT···········
map1···· byte· "SSSSSSSSSSSSSSSSS·SSSS· SSSSSSSSSSSSSSΔ"
I'm actually using other chars but they wont display in this post..anyway.
I'd like to·have these read into an array:
·mapdata[noparse][[/noparse]mapindex]
So that I may draw the map on screen as well as navigate through.
Whats the best way to read these values into my array?
Thanks,
Rick
I'm assuming the DAT section in a spin program would be the place to keep a game level.
I have a simple map:
DAT···········
map1···· byte· "SSSSSSSSSSSSSSSSS·SSSS· SSSSSSSSSSSSSSΔ"
I'm actually using other chars but they wont display in this post..anyway.
I'd like to·have these read into an array:
·mapdata[noparse][[/noparse]mapindex]
So that I may draw the map on screen as well as navigate through.
Whats the best way to read these values into my array?
Thanks,
Rick
Comments
Page 167 in prop manual
Index := 0
repeat
· Temp := BYTE[noparse][[/noparse]@MyString][noparse][[/noparse]Index++] 'Read chars into Temp
· <do something with Temp> 'Perform task with character
while Temp > 0 'Loop until end found
Rick
[noparse][[/noparse]code]
bytemove(@myarray, @mydata, 200) 'move 200 bytes from the address of mydata and write it to the address at myarray.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
Advertisement sponsored by dfletch:
Come and join us on the Propeller IRC channel for fast and easy help!
Channel: #propeller
Server: irc.freenode.net or freenode.net
If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
Once I'm at the point where I need to trim the code up I will def do that!!!!
Atm its not sure how long the level is so when the level is loaded from the DAT section it reads until it hits an end char. However when things are complete I guess I will know how long each level will be and have that length bytemove'd as a whole chunk like that and not char by char.
thanks again,
Rick