Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Making Monsters in a game?
Index -> Programming, Turing -> Turing Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
feebas200




PostPosted: Sun Jun 19, 2011 2:17 pm   Post subject: RE:Making Monsters in a game?

how do I make a save file for my game so that people can recontinue?
Sponsor
Sponsor
Sponsor
sponsor
goroyoshi




PostPosted: Sun Jun 19, 2011 2:34 pm   Post subject: RE:Making Monsters in a game?

http://compsci.ca/v3/viewtopic.php?t=12972
check file input/output
essentially it is using a text file to save a bunch of variables
feebas200




PostPosted: Sun Jun 19, 2011 11:15 pm   Post subject: RE:Making Monsters in a game?

I can get the score to save, but it overwrites the old one each time a new one is entered.
Tony




PostPosted: Sun Jun 19, 2011 11:32 pm   Post subject: RE:Making Monsters in a game?

What do you want it to do instead?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
feebas200




PostPosted: Sun Jun 19, 2011 11:49 pm   Post subject: RE:Making Monsters in a game?

i want it to make a list of the top 10 scores.
this is what i tried, it would overite the old one each time. I want to make a list of top 10 players.
This is for my final culminating project that is due tomorrow. Please help! Thanks

for i : 1 .. 1
open : stream, "myText.txt", get
get : stream, name (i)
open : stream, "myText.txt", put
cls
put "What is your name"
View.Update
get name (i) : *
View.Update
put : stream, name (i), " " : 10, minutes, ":", seconds, ".", milliseconds
put "Your score will be saved!"
put name (i), " ", minutes, ":", seconds, ".", milliseconds
View.Update
close : stream
end for
Tony




PostPosted: Mon Jun 20, 2011 1:34 am   Post subject: RE:Making Monsters in a game?

Nothing in that code suggests that 10 players are involved.

- you need to remember that writing to a file starts from the top, and will over-write previous content.
- "top 10" suggests that scores need to be sorted, to figure out which ones are in that list.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
feebas200




PostPosted: Mon Jun 20, 2011 7:40 am   Post subject: RE:Making Monsters in a game?

how will I be able to add code with out overwriting? I tried retrieving the file first so it has the current info and then writing it but it still overites the old text.
Tony




PostPosted: Mon Jun 20, 2011 10:02 am   Post subject: RE:Making Monsters in a game?

You are opening a new stream for writing _after_ reading, so that starts at the start again. Besides, this wound't works with variable-sized lines.

Overwriting the entire file is the easiest thing to do.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 23 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: