Subscribe to Project Apricot        RSS Feed

Mall'd: Maps! Maps Everywhere!

Icon Leave Comment
Posted Image

For the entirety of this morning, I've been working hard to rush the implementation of a map loader. The map loader consists of two classes: Map and Maps. They're confusingly named, but I managed to implement them without any naming errors (ie, calling Map instead of Maps due to a typo, or vice versa).

	public Hero hero;
	public Background background;	
	public List<ActionSprite> actionGrid = new ArrayList<ActionSprite>();
	public List<StaticObstacle> staticObstacles = new ArrayList<StaticObstacle>();
	public List<InteractiveObstacle> interactiveObstacles = new ArrayList<InteractiveObstacle>();
	public List<Zombie> zombies = new ArrayList<Zombie>();
	public Map(Hero hero, Background background, List<ActionSprite> actionGrid, List<StaticObstacle> staticObstacles, List<InteractiveObstacle> interactiveObstacles, 
			List<Zombie> zombies)
		this.hero = hero;
		this.background = background;
		this.actionGrid = actionGrid;
		this.staticObstacles = staticObstacles;
		this.interactiveObstacles = interactiveObstacles;
		this.zombies = zombies;

	public final Map setMap0001()
		//Dump map components
		background = new Background(backgroundBMP);

		//Initialise new map components [EDITED OUT FOR BREVITY]

		//return as new map object
		return (new Map(this.hero, this.background, this.actionGrid, this.staticObstacles, this.interactiveObstacles, this.zombies));

onDraw method changes to game loop
	Maps mapList = new Maps(this);
	private Map map = mapList.setMap0001();


	@SuppressLint({ "WrongCall", "DrawAllocation" }) @Override
	protected void onDraw(Canvas canvas)

The purpose of Map is to function as, well, a map. It gathers all of the sprites, and keeps them in a single object for later use by the game. Maps is to declare Map objects without cluttering up the game loop. As a result, Maps itself is cluttered, but it's a necessary sacrifice.

In programming, as in life: encapsulation, encapsulation, encapsulation.

It's not as efficient as it could be, but it is encapsulated, so I'm at a point where I can continue to program this game without having to worry about whether or not I'll be able to reproduce the results with a different map, or how I'm going to load each map so that the player can play them.

To celebrate this milstone, here's the first development screen of my game:

Posted Image

0 Comments On This Entry


Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

October 2015

45 6 78910

Recent Entries

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)