Follow the instructions provided on my.kenzie.academy for this challenge. The code.js
file is a placeholder. Feel free to rename it add additional files to the project.
Customize this README.md however you want to turn it into documentation for your project (including deleting these opening paragraphs). The only required sections are the Project Plan and Reflection below. Be sure to use proper Markdown syntax in this file (here's a cheatsheet PDF of the basic syntax).
- Create the maps for the player to chose
- Create string maps
- create buttons that select each map as the layout
- set eventlisteners for each button that will set the variable "mapLayout" as what the button is
- Create function that displays map
- Accepts mapString as param
- map through mapString, (W = wall, S= start, F= finish)
- if W, dispay block for wall
- if S, display word start
- if F, display word finish
- Create function to display player
- find place of start, place player there through relative positioning and set coords as where start exists in array
- change isPlayerDisplayed to true
- Create function to move player
- Create an eventListener for "keydown"
- Create movePlayer function
- accepts event as param
- if hasWon = true, return mapLayout = mapString
- Create code that reacts to arrow keys
- for each arrow press, map through mapString
- for each arrow, find where player coords are and where they would be if player moved
- create function that checks if it is wall
- use coords to search array for that spot, if it = "W", player cannot move
- run isWall before moving player
- run win function after each turn
- Create win function
- finds players coords
- search through array for that spot in it
- if that spot = "F", change hasWon to true, and display "You won!" on page
- Create Sokoban puzzle out of maze
- create crate and storage locations
- repersented on the map a C, s, X, and @
- create display crate
- in display map, it looks for C to repersent crates, classname is crate, id is crate${number}, and give it the styles the player has so it can move
- push the x and y of the spot to cratesX and cratesY
- if path = X, crate is already on storage x and y are pushed to crates x and y, and won x and y arrays
- create how player moves crate
- function for moving left, right, up and down
- if player is aginst crate, function for moving it runs based on the arrow
- moving itself runs similar to player, but crate x and y is held in arrays so you loop through array to get x for crate being moved, and use that index to get y
- check for wall and other crates the same as the isWall function works, but for crates use the array for crates x and y instead of map
- create storage spots
- in display map function, if path = s, classname is storage
- push its x and y to win x and y arrays
- if path = @, classname is "storage start", everything else is same for this storage spot
- create win function
- in win function, edit so origional only runs on the maze maps, and new will only run on the new maps
- run function to check if all storage spots are occupied, if true run the code that origional runs when game is won
- create check if all occupied function
- loop through winX array, and use index to get matching y array, storage occupied = false
- loop through crates x array, and use index to get matching y
- compare win x and x, and win y and y, if all are the same, storage occupied = true, else it returns false
- if it gets through loops, return true
- create crate and storage locations
What different approaches or techniques did you consider when planning your implementation? What were the advantages and disadvantages of those alternatives?
I started with thinking that I should move the player through the maze array itself, and just display that, but I was not able to work out how to actually do that properly.
I originally was going to check if game was won by using an array that would hold false for each storage spot, but i could not figure out a way to change the true back to false if the player moved the crate back off the storage