Results 1 to 4 of 4
- 05-11-2012, 08:26 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 6
- Rep Power
- 0
how to save and load and pause a game ?
I'm working on a game and I need to save and load and pause it .
I search but I run out of time so I need some good and easy examples of this .
I would be really thankful if somebody helps me .
by the I have a map that consists of 0 , 1 , 2 so I have to save that too.
- 05-16-2012, 08:00 PM #2
Member
- Join Date
- Apr 2012
- Posts
- 6
- Rep Power
- 0
Re: how to save and load and pause a game ?
I found out the answer myself . I saved the map that is a 2D array in a file line by line by the following code :
public void save() {
File f1 = new File("savedmap.txt") ;
FileOutputStream fos ;
try {
fos = new FileOutputStream(f1) ;
PrintStream ps ;
ps = new PrintStream(fos) ;
for (int i = 0 ; i < 20 ; i++) {
for (int j = 0 ; j < 19 ; j++) {
ps.print(map[i][j]) ;
}
ps.println(map[i][19]) ;
}
ps.close() ;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
- 07-03-2012, 12:53 AM #3
Member
- Join Date
- Jul 2012
- Posts
- 27
- Rep Power
- 0
Re: how to save and load and pause a game ?
I did much of the same thing.
- 07-03-2012, 03:58 AM #4
Re: how to save and load and pause a game ?
Why do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Save/Load ArrayList
By chielt in forum New To JavaReplies: 3Last Post: 05-08-2011, 06:12 PM -
Vector load/save with swing
By petosiso in forum AWT / SwingReplies: 0Last Post: 04-20-2011, 08:14 AM -
Load and Save images
By shakeel in forum Java 2DReplies: 13Last Post: 12-29-2010, 06:38 PM -
Arraylist Save and Load
By frankycool in forum Advanced JavaReplies: 1Last Post: 11-14-2009, 10:29 PM -
save will work but load wont?!?!
By Sticks_ll in forum New To JavaReplies: 1Last Post: 06-12-2008, 04:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks