Im not even asking for pseudo code or anything, just a concept. I thought pac man would be a good project because it is simple (even the AI i have an idea for, ghosts start moving one way, hit a wall, make a turn towards pac-man)
I never understood how to link those tile based map editors into my code -- and loading up a bitmap/png is not going to work since there will be no 'solid' objects.
I could use individual sprites for the maze walls, and create SDL-rectangles to blit them on and then also create collision detection for them. This is the most logical way I can think of, however it will be pretty messy, since I'll have to hard-code each map into the game, and wont be able to load map files. Each maze will be pretty annoying to implement, and time consuming in this fashion -- whereas if I could simply create a load up a file that contained the maze data, creating more mazes and such would be relatively simple and quick.
is there a way I could sort of, script the mazes together rather than having to hard-code the walls as SDL rectangles? like, load up a text file that gets 'converted' into maze sprites, or even use a scripting language like python or ruby in conjuction with C++, just for the maze generation?
I dont even want random mazes -- just trying to figure out the ideal way to implement getting the maze there to begin with.
another possibility would be somehow 'defining' where the walls are and just loading up a bitmap picture of the maze. as long as the game knows where you can/cant move, it would work -- but I dont know how I could plot out those points (Id probably still need to create invisible rectangles)
if I still have to create the invisible rectangles, is it not easier to simply hard code the graphics in already? like I already need the rectangle function -- so I may as well create a subroutine like int createwall() that loads up a graphic for the wall and also sets the collision detection of that rectangle.
its something so stupid to ask, or even be confused by, im sure, but hey -- itd just be soooo much simpler if I could even code up or somehow use an existing map editor rather than having to sit there and hard code the graphics in.
plus it would be a ROYAL pain in the balls to have to hard code each piece of wall in the exact right spot.
doing it that way, the plotting alone would take hours creating a maze because Id have to get each x and y coordinate exactly spot on, and thats a lot more work then coding in the starting points of minor sprites (seeing as the whole screen/window is going to have to be layed out with collision detection)
but arent there always going to be pixel values? there are other objects, such as the dots and the sprites themselves.
I dont know how I could dynamically allocate a certain color in the picture as an object on the fly...
the whole map is a set of pixel values. it would have to scan through the image and set whatever binary value is equal to the color of the wall outline as a wall. and I dont even know how bitmaps or pngs are encoded, so that would be quite a task I imagine.
there are other objects, such as the dots and the sprites themselves.
I dont know how I could dynamically allocate a certain color in the picture as an object on the fly...
Dynamic objects are not part of the map, obviously.
Objects that don't move but whose location depends on the map can be encoded as special colors. For example, pure red could indicate the location of a pellet. When scanning the map you'd store these locations somewhere, then you'd clear these pixels to some other value before drawing the map on the screen.
it would have to scan through the image and set whatever binary value is equal to the color of the wall outline as a wall. and I dont even know how bitmaps or pngs are encoded, so that would be quite a task I imagine.
Understanding the file format can be left to a library (SDL can load BMPs). Once the bitmap has been loaded to memory, you can directly inspect the pixel values as you would any other type of memory.