@Connor_Hindle wrote:
So i am trying to create a clone of Pacman for part of a college project however i am currently stuck for efficient ways to load a maze in. So far i have created an Object called "MazePieces" which each have a Vector2 Location, Orientation Enumerator(Horizontal, Vertical) for picking the correct piece to use from the Spritemap. And a rectangle Edge for collision detection with the player. I am currently able to create a list of Maze Pieces and load these into the game with working collision.
However now i am trying to think of an efficient way to fill the Maze Piece list. I have tried using a database and creating a database entry for each piece, However this has been way too tedious to fill in. Is there any other more efficient ways to load in a maze? The Constructor for the Maze Piece requires a Location, X and Y, and an orientation for the piece.
Maze Piece Class:
class MazePiece : CharacterObject
{
public int PieceHeight;
public int PieceWidth;
OrientationEnum PieceOrientation = OrientationEnum.Vertical;
public Rectangle Edge;public override void LoadContent(Microsoft.Xna.Framework.Content.ContentManager Content) //LOADING CONTENT { SpriteMap = Content.Load<Texture2D>(@"FullSprites"); } public enum OrientationEnum //ORIENTATION OF MAZE PIECES { Vertical, Horizontal, } public MazePiece(int x, int y, string _orientation) //CONSTRUCTOR -- TAKES X AND Y FROM INPUT { this.Location.X = x; this.Location.Y = y; this.PieceOrientation = (OrientationEnum)Enum.Parse(typeof(OrientationEnum), _orientation); Edge = new Rectangle((int)Location.X, (int)Location.Y, PieceWidth, PieceHeight); } public override void Draw(SpriteBatch spriteBatch) //DRAWING EACH PIECE IN { if (PieceOrientation == OrientationEnum.Vertical) //CHECKING WHICH PIECE NEEDS TO BE DRAWN { int X = 30; int Y = 96; spriteBatch.Draw(SpriteMap, Location, new Rectangle(X, Y, 12, 24), Color.White); PieceHeight = 24; PieceWidth = 12; } if (PieceOrientation == OrientationEnum.Horizontal) //CHECKING WHICH PIECE NEEDS TO BE DRAWN { int X = 0; int Y = 102; spriteBatch.Draw(SpriteMap, Location, new Rectangle(X, Y, 24, 12), Color.White); PieceHeight = 12; PieceWidth = 24; } } }
Posts: 1
Participants: 1