Jump to content
  • Advertisement
Sign in to follow this  
ginkeq

How is this design?

This topic is 3904 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just started working on pacman, haven't implemented any kind of sprite classes yet. What do you think of this design? [Edited by - Shannon Barber on April 5, 2008 2:14:35 AM]

Share this post


Link to post
Share on other sites
Advertisement
Perhaps you are looking for a different kind of 'design' critique.

The game design forum is more about game theory than designing a programming structure.
There should be plenty of help available in the other forums though...

Share this post


Link to post
Share on other sites
If by BlackTile you mean anywhere on the map where there isn't a wall, enemy, pacman, or prize, then you certainly don't want to have an object to represent the absence of any of the other objects. You don't need to waste memory storing those tiles and processing time iterating through those tiles.

Instead, remove the BlackTile, and just assume that PacMan can move around everywhere. Just make the background black. Now that PacMan is free to move around the screen, create all your other tiles and place them on the screen/map, and then place PacMan inside your WallTiles. Now whenever anything moves, check to see if it collides with any of the Tile classes and react appropriately.

Share this post


Link to post
Share on other sites
I disagree with using inheritance for tiles.

First, you're confusing tiles and tile contents: give each tile zero or one prizes, instead of inheriting a class for that purpose.

Second, you're deriving classes to represent a simple boolean property: give each tile a passable property, instead of inheriting a class for that purpose.

For the rest, I see no issue.

Share this post


Link to post
Share on other sites
I don't see anything in your diagram about input, pacman, ghosts, AI, pathfinding, rendering, animation... you get the idea :)

One thing you should consider is that just because you can use inheritance, you shouldn't do that unless there is a need, and in the case of tiles there is no concrete need. Most tiles would have very similar data, like a walkable flag and a sprite description.

PrizeTile should probably be a type of actor/object/entity/whatever and not a tile, but that really depends on how you wanna code it.

Share this post


Link to post
Share on other sites
Great suggestions everyone.

I got rid of the inheritance, put in a bool, and now it contains a Prize.

As for not creating a blank tile (I assume you meant leave it null?), doesn't it simplify everything? I don't have to do null checks or anything like that if I can assume every tile is some sort of tile.


One thing that concerns me is the storage of bitmaps etc. for the tiles and prizes. What is the standard way of storing that? Should they each be made into resources in VS? I don't like how I have it now which is figuring out what directory the bin is in and then traversing the structure appropriately to find the Tiles Prizes and Sprites.

Share this post


Link to post
Share on other sites
You can handle resources a number of ways. Generally they will be in some directory or archive below the executable, so you would just prefix the current working directory whenever you grab a resource, and you can refer to the resources themselves with something like "data/sprites.png". Another way would be defining archives and then looking inside them, sort of a virtual filesystem, but that is probably too complicated for your needs (and you still need to get the current directory ofc, but that's not a big deal normally). For a really small game like pacman I suppose you could embed the sprites as resources in the executable.

Share this post


Link to post
Share on other sites
Quote:
Original post by ginkeq
As for not creating a blank tile (I assume you meant leave it null?), doesn't it simplify everything? I don't have to do null checks or anything like that if I can assume every tile is some sort of tile.


Ah, I think I see where you're coming from. I assume you want to be able to have different tiles to represent the floor, like having a wooden floor or a metal floor, or a grass "floor." Okay, I figured that you just wanted to have a black screen with walls, prizes, and characters, just like the original PacMan. If that was the case, then my previous post would apply.

But, if you want to be able to have different floors rather than just a black background behind everything, then you would have a BlackTile, as well as a GrassTile and MetalTile and WoodenTile -- whatever tiles you want to use as your floor.

But, if you have mostly BlackTiles everywhere, then, as I mentioned before, it is unnecessary to actually have a BlackTile; you'd be better off just having a black background with no tiles. The BlackTiles would be useful for creating rooms or areas that are hidden from the player where the room or area is created normally (i.e. the wall, character, prize tiles are placed), but then BlackTiles are placed on top of the entire room or area to make it "hidden."

Anyways, it depends on how you want to make your game. If you're going just for a constant black background like the original PacMan, then get rid of BlackTiles. The only reason I could imagine for using BlackTiles would be as I mentioned above, to hide something from the player, but other than that just have a black background and simply don't place a tile over that particular spot.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!