Posts: 3,616
Threads: 287
Joined: Jan 2003
What I did to display/move all the men is just run through a FOR loop 50 times, iterator called i, (assuming you have 50 men), and for each man(i), move him.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 691
Threads: 5
Joined: Apr 2002
You can combine the use of types and files for storing data. Try the following:
Code:
'**** Type for storing player information ****
TYPE playerType
cname AS STRING * 8
weapon AS INTEGER
health AS INTEGER
END TYPE
DIM player(3) AS playerType
'**** Setup 3 players ****
player(1).cname = "Fred"
player(1).weapon = 2
player(1).health = 100
player(2).cname = "Bob"
player(2).weapon = 9
player(2).health = 54
player(3).cname = "Sam"
player(3).weapon = 5
player(3).health = 34
'**** Save the player information to a file ****
OPEN "players.dat" FOR BINARY AS #1
FOR i = 1 TO 3
PUT #1, , player(i)
NEXT
CLOSE #1
'**** Clear the player information ****
FOR i = 1 TO 3
player(i).cname = "no name"
player(i).weapon = 0
player(i).health = 0
NEXT
'**** Load the player information from the file ****
OPEN "players.dat" FOR BINARY AS #1
FOR i = 1 TO 3
GET #1, , player(i)
NEXT
CLOSE #1
'**** Display the player information ****
FOR i = 1 TO 3
PRINT "Player"; i; " name: "; player(i).cname
PRINT "Player"; i; " weapon:"; player(i).weapon
PRINT "Player"; i; " health:"; player(i).health
PRINT
NEXT
You can use this to save memory by only loading the types that you currently need into memory and leaving the rest on disk. For example, if your game allowed you to play as one of 10 different characters, you could have the information for each of the 10 characters saved in a file, when the player makes their choice you then load only the character they selected.
esus saves.... Passes to Moses, shoots, he scores!
Posts: 6
Threads: 2
Joined: Aug 2003
Thanks for that, I'll run with those ideas and use them the way I can.