QA


Q&A

Q1:

What is the purpose of a file handle?

A1:

Similar to other handles in Windows, such as window handles and bitmap handles, a file handle is a reference to a location in memory that stores information about a file. More importantly, a file handle serves as your interface to a file, and is required in all file operations. You can think of a file handle as working a lot like a key for a locker in an airport terminal. When you open the file, you receive the handle (key) that you must then use in order to read from or write to the file. When you're finished with the file, you close the file, which returns the handle to Windows.

Q2:

Why exactly can't I read and write the scores as integers in the Space Out 4 game?

A2:

The reason for having to convert the integer scores to characters has to do with the fact that characters are a little easier to manipulate when it comes to reading and writing files. Because the number of digits in a score actually varies, it becomes difficult to parse a number from a data file if it is stored as a raw integer. Therefore, it's easier to convert the integers into readable text that can be read from and written to files a character at a time. A side benefit of this approach is that you can open the HiScores.dat file and see the scores. Of course, this could also be perceived as a drawback because technically people could cheat and change the scores in the data file, but only you know this secret!



Sams Teach Yourself Game Programming in 24 Hours
Sams Teach Yourself Game Programming in 24 Hours
ISBN: 067232461X
EAN: 2147483647
Year: 2002
Pages: 271

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net