Creating a Pacman game in C#/Winforms

Started by
0 comments, last by gixslayer 8 years, 3 months ago

Hello all,

take care, this is an absolute beginners question:

I'm making a Pacman game in C#/Winforms. I have set up my board as an array of GameObjects. GameObject is an abstract class, and has two derived classes: GameSpace and GameWall.

So far, so good. What I'm unsure of is how to move my Player across the board. Should Player be another class derived from GameObject, and should I renitialize the array field where player leaves? Or should "bool hasPlayer" be an attribute of GameSpace?

Any input appreciated :)

Advertisement

I'd personally recommend separating tiles (wall and space as you mentioned) and entities. The 'world' is made out of tiles and entities reside on top of one or several tiles (depending how you handle movement). You could then define an Entity base class which all entities inherit (be it an AI mob, player or whatever). The entity class would contain the location and move logic so you only have to write it once.

The exact implementation depends on how you want the movement to work. If you just jump entities from one tile to another it's much simpler, but visually less attractive.

This topic is closed to new replies.

Advertisement