STATEMENT OF THE PROBLEM: Redo my Pac Man clone and do it better. 6/4/08 Started fiddle-fussing in the evening trying to work out the data file, after a day of familiarizing myself with my math textbooks. 6/5/08 Established the data file (phew!). I did not want to start coding too late in the day today, because I will be on campus tomorrow and therefore will not be coding much tomorrow. Why start coding just to be interrupted almost immediately? So I did not write any code today, except for the rather surprising amount of code that I wrote just to manipulate pictures. 6/7/08 I should mention that I normally exercise every day, and that keeps me mentally alert and relatively positive, but now I do not have my orthotics. Ever since I started working on this program, I have not had my orthotics. My orthopedist has them; he is replacing the gelatin. I had anticipated getting my orthotics back today, but I did not. The orthopedist had expressed some uncertainty when he said I would have my orthotics back today. That is fair. I ate a slice of cake this morning because I was assuming that I had the orthotics and therefore could exercise using the sugar from the cake. I took my time eating every last bit of frosting off the package because I was waiting before exercising (to avoid getting a stomach cramp). Then I realized that I did not have my orthotics, and I needed to eat some sort of breakfast, as the piece of cake was just not big enough to pass as a meal. I washed my bedclothes today, and of course I cannot use this computer when my bedclothes are in the wash. I started with the blanket, and while the blanket was in the washing machine, I had to start bringing fallen tree branches (the product of hail) to the fire pit, even though I do not have my orthotics. I took an inordinate amount of time to do that, and only when I was done could I resume washing the bedclothes. I had to take a thorough shower before I could make the bed, especially given that I had worn the sandals. Of course, I could not take a shower until the mattress protector was in the dryer. I spent about forty-five minutes in the shower. After restoring some bedclothes to the mattress, it was time for another meal. Having thoroughly established boredom for today, I took a long time to eat again. I ate too much, and I generally assume that detracts from my mental alertness. It was not until 7:00 PM that I was able to actually start coding. I would also like to mention that my entry for 6/4/08 was not actually written on 6/4/08. At that time, I was not able to identify the significance of my fiddle-fussing. Only when I found how time consuming it actually was to establish the data file did I realize that it was worth beginning with 6/4/08. Overall, SHEESH! 6/8/08 I made a reasonable amount of progress coding today. However, the program behavior is still limited to error messages (not error messages indicating mistakes on my part, but error messages that prove that I am being very good about error handling). 6/10/08 Today, I observed that on this computer, some sequences of calls to create_video_bitmap(int, int) can cause request_video_bitmap(BITMAP*) to fail unexpectedly. I have written a short C program to do a simple demonstration of this problem for whomever I may choose to ask about it (if anyone). Because of the problem, my program behavior on this computer now consists of an error message, courtesy of my own error handling. 6/11/08 Here is the deal: first of all, the video memory pages have to be the first VRAM bitmaps that you create, and secondly, sometimes you just cannot request a video page when another operation (such as a blit) is in progress. I fixed my code to reflect both of these nuances. I also made several corrections/revisions for the code as a whole. I got my orthotics back today, and so I got new shoes today. I then ran on the treadmill as soon as possible. Unfortunately, it was late afternoon/early evening. Had it been any later, I would not even have run on the treadmill at all. I did not work on this program at all subsequent to running on the treadmill. 6/12/08 First I added fading, which was quite simple because Allegro includes fading routines. Then I added a prompt function to the GUI. That was quite complicated, because I am not skimping on functionality at all. In fact, I still want to add more functionality to the prompt function. I want to add the familiar context menu (Shift+F10). Before I can do that, I will need to refactor the whole function. That is probably a good idea anyway, because the function is untested and I probably made a mistake or two (although I was pleasantly surprised to find not a single compiler error). When I figure out how to refactor this function, I may feel prompted to refactor the menu function, too. Unlike the menu function, the prompt function currently identifies keys by their ASCII codes. The underlying idea is that when you type, what you get is the ASCII characters corresponding to the keys that you press. To make this method work, I let Ctrl play the role of Shift, and I left out the legacy keyboard commands for the clipboard operations. Now that I have explained that, I can say that I want to add Ctrl+Home and Ctrl+End. But I also want to rethink the way that I do the keyboard input. If I do it right for this function, then I will do it right for the level editor, and, in general, I will do it right from now on. 6/18/08 I started coding today at 1:45. I refactored the prompt function and added Ctrl+A, Alt+Bksp (although Ctrl+Z was already present), Ctrl+Home, Ctrl+End, and Shift+F10. Doing the keyboard input properly is more important than I had realized, because the ASCII code actually does not even come close to uniquely identifying keys. I will have to fix that, and, in the process, add the legacy keyboard commands for the clipboard operations. I actually see no good reason to refactor my menu function. I did, however, make a change to my menu function, because accelerator keys should not be case sensitive. 6/21/08 It seems like I must have gotten some sort of food poisoning at my dad's place. That is why I did not work on this project in the past two days. But I think I made a fair amount of progress today. Basically, I finished the prompt function and I added a menu bar. 6/22/08 I made a reasonable amount of progress today. Basically, I started on the level editor. 6/23/08 I need to write implementations for the commands in the "Level" menu for editing the two routes. Also, the level editor currently has an extra layer for the mouse controls (which I intend to implement later). After I add these two things, the level editor will be fully functional. I need to catch bad_alloc, because apparently if I do not catch it then memory gets corrupted. I want to reintroduce the configurable restriction on the size of the undo buffer. I want to play the logo animation directly from disk instead of loading it into system memory. 6/24/08 I was wrong about bad_alloc; I do not need to catch it. The problem was actually that I failed to implement the copy constructor and assignment operator for InputMenu. I have implemented these functions now. I think I do not really want to reintroduce the configurable restriction on the size of the undo buffer, after all. That decision was based on the idea that bad_alloc was being thrown. But if there seems to be enough memory to expand the undo buffer until all of the telephone poles turn turquoise, then I should probably keep this amusing functionality until it proves to actually pose a problem. I am now investigating the problem of calling request_video_bitmap almost immediately after blit. 6/26/08 * I made some subtle changes yesterday and forgot to log them. Oh well. * The logo animation now plays directly from disk. I separated the data file into two data files, smalldat.dat and bigdat.dat, so that I could compress the logo animation with individual compression and everything else with global compression. * I wrote implementations for the commands in the "Level" menu for editing the two routes. * I read up on the Allegro mouse stuff and I set up the mouse pointer. Now I just have to write the actual mouse input. 6/27/08 I have been doing a lot of code refactoring today, and I am currently in the middle of working on mouse input. 6/28/08 I completed the code refactoring and mouse input, and I also added "set_color_conversion(COLORCONV_NONE);" (which really should make no difference). Now all that my program does is cause an invalid page fault. I had been thinking of possibly reading all of my code over anyway now that I have done so much refactoring, but truthfully I should probably wait until the whole program is finished before I really consider reading all my code over again. I am sure I can think of a more efficient way to track down the invalid page fault. Then I can add shift+clicking. 6/29/08 Today I debugged and made some relatively subtle changes. I think shift+clicking is actually probably not a good idea. The level editor is now fully functional. 6/30/08 I fixed a bug in prepareToGetDirty(), and I added remove_int(setHeartBeat) after the main loop of edit(Level*). 7/1/08 I am now in the middle of working on the game-play. I also fixed the way that I handle KEY_MENU, and I changed one of the parameters of a constructor in the GUI so that it is passed by constant reference, and I added free(dummyLevel.getFileName()); to unload(). 7/2/08 The gameplay is now almost fully functional but completely untested. I am now writing functions for dealing with CSV files. I also removed "oldMousePos = 0x0;" from the level editor because it is a pointless line of code. 7/10/08 This evening, I finished writing the functions for dealing with CSV files (though these functions are still entirely untested), and I have been resolving compiler errors. It appears that because of limitations on how an inner class can use nonstatic member data of the owning class, there is not much point in my use of inner classes. If that is true, then I will put those classes in their own files instead. My program fails on the Pentium 90 and on my dad's Windows Vista computer, and I still think there may be some problem with Allegro's triple buffering. 7/11/08 I pulled out the inner classes and put them in their own files, and I finished resolving the compiler errors. I am now working on a class HighScoresList to represent the high scores list. I have implemented all of the methods except judge(), but I think I will need to rethink the memory management for this class (a change big enough for the term code refactoring) before I can write judge(). 7/12/08 I refactored HighScoresList and added judge(), as described yesterday, and I put everything together. Now I think it is time for a debugging marathon. 7/13/08 Today I worked on debugging. I lost my main.cpp and had to redo today's changes to it, so now I feel uncertain of main.cpp. There is still a bug as evidenced by an error when saving the high scores. There also seems to be a flaw in the logic that controls the monsters. Once I have fixed these two problems, I will continue testing and see what else is wrong. 7/14/08 I think I am done debugging for now. I still have not done anything about the buggy triple buffering and compatibility issues. I added pause and quit features to the gameplay, I added a "Game Over" message, I made the high scores prettier, and I did a few simple optimizations. I am now using Pacmania, and I would not be surprised if the character spacing is wrong, considering Shawn Hargreaves's disclaimer and the fact that the character spacing for Joystix was indeed wrong until I touched it up. 7/15/08 * Changed the declaration of jawStep (in constant.h) from int to fixed, even though on 32-bit machines, fixed is in fact int. * Fixed the actor collision detection, which previously had not taken into account looping around the screen. * Wrote a separate program to convert from the file format from my old Pac Man clone to the file format for this one. I might have to do something about the fact that the keyboard frequently locks up on this computer. It deters me from playing on this computer (although it is not a big deal when testing specific functionality). 7/16/08 * Bug fix: My CSV reading function had stored the return value of getc as type char before attempting to detect EOF, which is outside the range of char. It was rather silly of me to store the return value as a type different from the one in the function signature anyway. * Bug fix: My CSV reading function had not taken into account the possibility of a null character in the file. * I added stuff to the GUI, but I did not test it. I should probably add a "retry" option to both of the menus that can come up when a level is bad. 7/17/08 * Bug fix: There was an off-by-one error in the loop that validates the bonus route before playing a level. * Bug fix (sort of): The high score dates had been generated with two-digit years, while the default high scores had had four-digit years. * Bug fix (sort of): The death animation had not looped around the screen. It sounds subtle, but I discovered that it actually looks rather odd when applicable if the death animation does not loop around the screen. * Improved the error-checking functionality in the function that takes in an array of file names and plays levels from them. Firstly, I added a "retry" command to both menus, as described yesterday; secondly, I added the "fix level" functionality (which was already a command on the invalid level menu); thirdly, I simplified the function, and *might* have fixed a subtle bug in the process. * Made some subtle changes to the GUI. * Added more information to all menu screens. * Added a settings command, which currently just lets you choose triple buffering, double buffering, or neither. * Added a command to play all files matching a given wildcard specification. * May have done something subtle and forgotten about it. (I am basically writing that because I am tired.) The error checking functionality of Allegro's low-level wildcard functions is peculiar and does not fit the documentation. I shall have to ask someone about that. 7/19/08 * Fixed a bug in parse(), which permitted enemies to leave the cage into an inaccessible area (without going to a tile bordering the "enemy route"). * Changed the definition of yellow to the default for color #14 because I use it to set color #14 when drawing the high scores. (It had been a darker shade of yellow than the default for color #14.) * It seems like the triple buffering is not a problem after all; I am getting unexpected changes in the color palette even with just double buffering. I think I will just dismiss this problem as a problem with this video card, because this video card obviously has problems anyway, and it is not uncommon for video cards to have buggy VESA implementations. * Added information to the settings dialog, describing what is the best graphics technique available. * Debugged InputText. * Wrote a file browser, adding much to the GUI in the process, and put this file browser to use in the "Play files listed in CSV file" functionality. There seems to be an important memory management problem now. My GUI code seems to be getting a bit convoluted. If I still feel that way when I am no longer tired, then I certainly might plan on refactoring my GUI. 7/20/08 * Removed "free(dummyLevel.getFileName());" from unload(). Note that on 7/1/08, I wrote that I added this line of code to unload(). I then asked Mike Cooley if it is really good practice to free memory before exiting. He said no, but I left this line in here anyway. Now I am removing it, mostly because I do not set the dummy level's file name until near the end of main(). * Fixed the important memory management problem that I wrote about yesterday. * Fixed the divide-by-zero problem for scrollbars with a limit of zero. * Fixed the problem of always reading from the current directory when using wildcard specifications. * Incorporated my file browser into the level editor. 7/21/08 * Bug fix: Replaced allegro_message(allegro_error); with allegro_message("%s", allegro_error); (sheesh!). * Bug fix: Added mouse polling to the function logoMenu. * Added joystick configuration functionality (but no actual joystick input yet). 7/22/08 Today I improved the joystick configuration functionality, and I also added actual joystick input. 7/24/08 Today I did a quick bug fix related to the direction that a monster faces if it is aligned to the grid when it shows up in the cage (at the start of a level or when you eat it). That is important because the monsters only turn around when they have no other option, but when the monster leaves the cage, I want it to be free to choose among all the gates adjacent to it. If it is facing in the proper direction, then turning around means going in an impossible direction anyway, so the "don't turn around" restriction is inconsequential. 8/10/08 Today I added audio. Unfortunately, the MIDI functionality does not seem to work very well on the upstairs computer. 8/12/08 * Improved the behavior that you get when you switch to another application while fading in. (This required a different change for every case where fading in occurs.) * Created an icon. * Added credits. 8/13/08 * Fixed major bug in discardChanges(bool), which had resulted in nonsense behaviour when reverting. * Removed char *fileName from Level, and accordingly changed all code dealing with file names of levels. That should mean better program behaviour. * Made the level file format endian-independent.