init
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/charb.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/charf.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3.1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/charl.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/charr.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 2.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/coal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/fire_coal.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 3 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/floor.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 2.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/grill.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 2.9 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								assets/img/sprites/wall.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
		 After Width: | Height: | Size: 2.8 KiB  | 
							
								
								
									
										2145
									
								
								assets/maps/microban.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
							
								
								
									
										103
									
								
								assets/script.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
						 | 
					@ -0,0 +1,103 @@
 | 
				
			||||||
 | 
					class Game {
 | 
				
			||||||
 | 
					  constructor() {
 | 
				
			||||||
 | 
					    this.mapInstance = null;
 | 
				
			||||||
 | 
					    this.level = 153;
 | 
				
			||||||
 | 
					    this.lives = 10;
 | 
				
			||||||
 | 
					    this.points = 0;
 | 
				
			||||||
 | 
					    this.totalMoves = 0;
 | 
				
			||||||
 | 
					    this.levelMoves = {};
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  initializeLevel() {
 | 
				
			||||||
 | 
					    this.mapInstance = new Map();
 | 
				
			||||||
 | 
					    this.mapInstance.generateMapArray();
 | 
				
			||||||
 | 
					    this.loop();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  loop() {
 | 
				
			||||||
 | 
					    this.mapInstance.display();
 | 
				
			||||||
 | 
					    // this.mapInstance.waitForInput();
 | 
				
			||||||
 | 
					    // this.mapInstance.checkWinCondition();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  handlePoints() {}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Map {
 | 
				
			||||||
 | 
					  constructor() {
 | 
				
			||||||
 | 
					    this.level = g.level;
 | 
				
			||||||
 | 
					    this.levelMap = levels[this.level][0];
 | 
				
			||||||
 | 
					    this.levelPar = levels[this.level][1];
 | 
				
			||||||
 | 
					    this.mapArray = [];
 | 
				
			||||||
 | 
					    this.storageLocations = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.playerX = null;
 | 
				
			||||||
 | 
					    this.playerY = null;
 | 
				
			||||||
 | 
					    this.previousElement = " ";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.win = false;
 | 
				
			||||||
 | 
					    this.lose = false;
 | 
				
			||||||
 | 
					    this.breakCondition = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    this.totalWin = g.level + 1 == levels.length;
 | 
				
			||||||
 | 
					    this.finalPointsGiven = false;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  generateMapArray() {
 | 
				
			||||||
 | 
					    g.levelMoves[this.level] = 0;
 | 
				
			||||||
 | 
					    let levelArray = this.levelMap.split("\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for (let i = 0; i < levelArray.length; i++) {
 | 
				
			||||||
 | 
					      if (i === 0 || i === levelArray.length - 1) {
 | 
				
			||||||
 | 
					        continue;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      let rowElements = levelArray[i].split("");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      if (rowElements.includes("@")) {
 | 
				
			||||||
 | 
					        this.playerX = i - 1;
 | 
				
			||||||
 | 
					        this.playerY = rowElements.indexOf("@");
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      let storageTypes = [".", "*"];
 | 
				
			||||||
 | 
					      for (let j = 0; j < storageTypes.length; j++) {
 | 
				
			||||||
 | 
					        if (storageTypes[j] in rowElements) {
 | 
				
			||||||
 | 
					          for (let k = 0; k < rowElements.length; k++) {
 | 
				
			||||||
 | 
					            if (rowElements[k] === storageTypes[j]) {
 | 
				
			||||||
 | 
					              this.storageLocations.push([i - 1, k]);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      this.mapArray.push(rowElements);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  display() {
 | 
				
			||||||
 | 
					    let map = "";
 | 
				
			||||||
 | 
					    for (let i = 0; i < this.mapArray.length; i++) {
 | 
				
			||||||
 | 
					      for (let j = 0; j < this.mapArray[i].length; j++) {
 | 
				
			||||||
 | 
					        if (this.mapArray[i][j] === "#") {
 | 
				
			||||||
 | 
					          map += '<img src="assets/img/sprites/wall.png">';
 | 
				
			||||||
 | 
					        } else if (this.mapArray[i][j] === " ") {
 | 
				
			||||||
 | 
					          map += '<img src="assets/img/sprites/floor.png">';
 | 
				
			||||||
 | 
					        } else if (this.mapArray[i][j] === "0") {
 | 
				
			||||||
 | 
					          map += '<img src="assets/img/sprites/coal.png">';
 | 
				
			||||||
 | 
					        } else if (this.mapArray[i][j] === "*") {
 | 
				
			||||||
 | 
					          map += '<img src="assets/img/sprites/fire_coal.png">';
 | 
				
			||||||
 | 
					        } else if (this.mapArray[i][j] === "@") {
 | 
				
			||||||
 | 
					          map += '<img src="assets/img/sprites/charf.png">';
 | 
				
			||||||
 | 
					        } else if (this.mapArray[i][j] === ".") {
 | 
				
			||||||
 | 
					          map += '<img src="assets/img/sprites/grill.png">';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      map += "<br>";
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    let mapDiv = document.getElementById("map");
 | 
				
			||||||
 | 
					    mapDiv.innerHTML = map;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					let levels = microban_levels;
 | 
				
			||||||
 | 
					let g = new Game();
 | 
				
			||||||
 | 
					g.initializeLevel();
 | 
				
			||||||
							
								
								
									
										29
									
								
								index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						| 
						 | 
					@ -0,0 +1,29 @@
 | 
				
			||||||
 | 
					<html>
 | 
				
			||||||
 | 
					  <head>
 | 
				
			||||||
 | 
					    <script src="assets/maps/microban.js"></script>
 | 
				
			||||||
 | 
					  </head>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  <body>
 | 
				
			||||||
 | 
					    <style>
 | 
				
			||||||
 | 
					      body {
 | 
				
			||||||
 | 
					        font-family: monospace;
 | 
				
			||||||
 | 
					        font-size: 30px;
 | 
				
			||||||
 | 
					        background-color: #efd4af;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      #map {
 | 
				
			||||||
 | 
					        white-space: pre;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					      #map > img {
 | 
				
			||||||
 | 
					        height: 50px;
 | 
				
			||||||
 | 
					        width: 50px;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    </style>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <center>
 | 
				
			||||||
 | 
					      <div id="map"></div>
 | 
				
			||||||
 | 
					    </center>
 | 
				
			||||||
 | 
					    <script src="assets/script.js"></script>
 | 
				
			||||||
 | 
					  </body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||