Android Open Source - Apocalypse-Defense Map






From Project

Back to project page Apocalypse-Defense.

License

The source code is released under:

MIT License

If you think the Android project Apocalypse-Defense listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.apocalypsedefense.core;
//  ww  w. j a v  a  2 s.c  o  m
import java.io.Serializable;
import java.util.ArrayList;

/**
 */
public class Map implements Serializable {
    /**
     */
    public boolean[][] blockedSpaces;

    /**
     */
    public int height;

    /**
     */
    public int width;

    /**
     * @param height 
     * @param width 
     * @param blockedSpaces 
     */
    public Map(ArrayList<Point> blockedSpaces, int height, int width) {
      this.blockedSpaces = new boolean[width][height];
      this.height = height;
      this.width = width;
      update(blockedSpaces);
    }

    
    /**
     * @param position 
     * @return Boolean
     * Purpose: Returns true if the position is blocked, false if not.
     */
    public Boolean isBlocked(Point position) {
      //Check bounds of map:
        if (position.x >= this.width || position.x < 0){
          return true;
        }
        if (position.y >= this.height || position.y <0){
          return true;
        }
        //If not out of bounds, return the value of the position (blocked or not):
        return this.blockedSpaces[position.x][position.y];
    }

    /**
     * @param blockedSpaces 
     * Purpose: Update map elements in map.
     */
    public void update(ArrayList<Point> blockedSpaces) {
      //Reset blocked spaces to false:
      for (int i=0;i<width;i++){
        for (int j=0; j<height;j++){
          
          this.blockedSpaces[i][j] = false; 
        }
      }
      
      //Block updated spaces:
      for (Point element : blockedSpaces){
        this.blockedSpaces[element.x][element.y] = true;
      }
    }
}

/*

Python code:

class Map():#Keeps track of the positions that are blocked
    def __init__(self, mapElements=[], height=100, width=100):
        self.mapElements = mapElements
        self.height = height
        self.width = width

    def isBlocked(self,position):
        if position in self.mapElements:
            return True
        else:
            return False

    def update(self,mapElements):
        self.mapElements = mapElements


*/




Java Source Code List

com.apocalypsedefense.app.AchievementsActivity.java
com.apocalypsedefense.app.ApocalypseDefenseActivity.java
com.apocalypsedefense.app.EndOfGameDialog.java
com.apocalypsedefense.app.ExitConfirmationDialog.java
com.apocalypsedefense.app.InGameActivity.java
com.apocalypsedefense.app.InstructionsDialog.java
com.apocalypsedefense.app.NewGameSettingsActivity.java
com.apocalypsedefense.app.OverwriteExistingGameDialog.java
com.apocalypsedefense.app.gameplay_visuals.AndroidLogAdapter.java
com.apocalypsedefense.app.gameplay_visuals.GameFacade.java
com.apocalypsedefense.app.gameplay_visuals.GameObject.java
com.apocalypsedefense.app.gameplay_visuals.GameSurfaceView.java
com.apocalypsedefense.app.gameplay_visuals.GameThread.java
com.apocalypsedefense.app.gameplay_visuals.OnGameEndListener.java
com.apocalypsedefense.app.gameplay_visuals.OnStatsChangedListener.java
com.apocalypsedefense.app.gameplay_visuals.Sprite.java
com.apocalypsedefense.core.ActorType.java
com.apocalypsedefense.core.Armor.java
com.apocalypsedefense.core.GameData.java
com.apocalypsedefense.core.GameState.java
com.apocalypsedefense.core.Game.java
com.apocalypsedefense.core.Gun.java
com.apocalypsedefense.core.LogAdapter.java
com.apocalypsedefense.core.MapElement.java
com.apocalypsedefense.core.Map.java
com.apocalypsedefense.core.Movement.java
com.apocalypsedefense.core.Person.java
com.apocalypsedefense.core.Point.java
com.apocalypsedefense.core.PrintLogAdapter.java
com.apocalypsedefense.core.Shared.java
com.apocalypsedefense.core.SurvivorManager.java
com.apocalypsedefense.core.Survivor.java
com.apocalypsedefense.core.Weapon.java
com.apocalypsedefense.core.ZombieManager.java
com.apocalypsedefense.core.Zombie.java
com.apocalypsedefense.core.testDriver.java