diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..737b4a70 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +script2bk.js +*.pptx +onionFace.png +playerRed.png +cow.png +bandit1.png +fireball.psd +char.png +bandit1.png diff --git a/README.md b/README.md index 317a3e58..9a29a8e6 100644 --- a/README.md +++ b/README.md @@ -1,96 +1,111 @@ -# Project Name (Start editing here) - +# Project 1: Crops and Robbers -#  Project #1: The Game +### Introduction -### Overview +1. Play as a farmer, Johnny Wicklebottom. +2. Defend your farm against the OnionFace Bandit Gang. +3. Survive them all to win. -Let's start out with something fun - **a game!** +Play the game at: https://soemn.github.io/project-1/ -Everyone will get a chance to **be creative**, and work through some really **tough programming challenges** – since you've already gotten your feet wet with Tic Tac Toe, it's up to you to come up with a fun and interesting game to build. + -**You will be working individually for this project**, but we'll be guiding you along the process and helping as you go. Show us what you've got! +##### Gameplay +Shoot the enemies while avoiding hit or getting your house damaged. The enemies keep spawning so defeat them fast and avoid being overrun! You will lose if the enemies destroy your house or kills you. ---- +### Controls -### Technical Requirements + -Your app must: -* **Render a game in the browser** -* **Any number of players** will be okay, switch turns will be great -* **Design logic for winning** & **visually display which player won** -* **Include separate HTML / CSS / JavaScript files** -* Stick with **KISS (Keep It Simple Stupid)** and **DRY (Don't Repeat Yourself)** principles -* Use **Javascript** for **DOM manipulation**, jQuery is not compulsory -* **Deploy your game online**, where the rest of the world can access it -* Use **semantic markup** for HTML and CSS (adhere to best practices) -* **No canvas** project will be accepted, only HTML5 + CSS3 + JS please +### In Game Screen Shot ---- + -### Necessary Deliverables +--- +### Game Flow -* A **working game, built by you**, hosted somewhere on the internet -* A **link to your hosted working game** in the URL section of your GitHub repo -* A **git repository hosted on GitHub**, with a link to your hosted game, and frequent commits dating back to the very beginning of the project -* **A ``readme.md`` file** with explanations of the technologies used, the approach taken, installation instructions, unsolved problems, etc. + --- -### Suggested Ways to Get Started +### Technical Assets -* **Break the project down into different components** (data, presentation, views, style, DOM manipulation) and brainstorm each component individually. Use whiteboards! -* **Use your Development Tools** (console.log, inspector, alert statements, etc) to debug and solve problems -* Work through the lessons in class & ask questions when you need to! Think about adding relevant code to your game each night, instead of, you know... _procrastinating_. -* **Commit early, commit often.** Don’t be afraid to break something because you can always go back in time to a previous version. -* **Consult documentation resources** (MDN, jQuery, etc.) at home to better understand what you’ll be getting into. -* **Don’t be afraid to write code that you know you will have to remove later.** Create temporary elements (buttons, links, etc) that trigger events if real data is not available. For example, if you’re trying to figure out how to change some text when the game is over but you haven’t solved the win/lose game logic, you can create a button to simulate that until then. +#### Content update +The update loop uses ```window.requestAnimationFrame()``` to update the game when not paused. ---- +The ```update``` function is used to move the characters using ```element.moveChar``` and check interaction using ```checkCollision()```. Each element behave differently upon collision. -### Potential Project Ideas -##### Blackjack -Make a one player game where people down on their luck can lose all their money by guessing which card the computer will deal next! +#### Element creation +The ```generateEnemy```, ```generateBullet```, ```generateUpgrade```, ```generateCat``` functions are used to create elements using the ```Character``` class. -##### Self-scoring Trivia -Test your wits & knowledge with whatever-the-heck you know about (so you can actually win). Guess answers, have the computer tell you how right you are! +The ```Character``` class is used to create all game elements on the gameBoard. +``` +class Character { + constructor( + type, //player, enemy, bullet, pet + id, //element identifier + sizeX, //element size + sizeY, + spdX, //movement speed + spdY, + hp, /character health + x, //location on gameBoard + y, + atkSpd, //attack speed + bulletOwner, //who shot the bullet + aniFrame, //animation counter + aimAngle //bullet direction + ) ---- + addChar() + //adds the character element to the gameBoard -### Useful Resources + removeChar() + //removes the character element from the gameBoard -* **[MDN Javascript Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript)** _(a great reference for all things Vanilla Javascript)_ -* **[jQuery Docs](http://api.jquery.com)** _(if you're using jQuery)_ -* **[GitHub Pages](https://pages.github.com)** _(for hosting your game)_ -* **[How to write readme - Markdown CheatSheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)** _(for editing this readme)_ -* **[How to write a good readme for github repo!](https://gist.github.com/PurpleBooth/109311bb0361f32d87a2)** _(to make it better)_ + moveChar() + //moves and animates the character ---- + shoot() + //Generates a bullet at the character's position + //Shoots direction base on aimAngle. + //All characters can shoot. Even pets and bullets. +``` -### Project Feedback + Evaluation -* __Project Workflow__: Did you complete the user stories, wireframes, task tracking, and/or ERDs, as specified above? Did you use source control as expected for the phase of the program you’re in (detailed above)? -* __Technical Requirements__: Did you deliver a project that met all the technical requirements? Given what the class has covered so far, did you build something that was reasonably complex? +##### Levels -* __Creativity__: Did you add a personal spin or creative element into your project submission? Did you deliver something of value to the end user (not just a login button and an index page)? +3 Levels with varying enemy spawn rates base on a timer. Past a certain point, enemies stop spawning and once all enemies are dead, the game is won. -* __Code Quality__: Did you follow code style guidance and best practices covered in class, such as spacing, modularity, and semantic naming? Did you comment your code as your instructors have in class? -* __Deployment__: Did you deploy your application to a public url using GitHub Pages? +##### Game Design Log -* __Total__: Your instructors will give you a total score on your project between: +###### First Idea: +Create a resource management game, where the player has to plant crops and then defend his crops from the enemies. Earning gold at the end of each level which can be used to buy seeds or defence for the next level. - Score | Expectations - ----- | ------------ - **0** | _Incomplete._ - **1** | _Does not meet expectations._ - **2** | _Meets expectations, good job!_ - **3** | _Exceeds expectations, you wonderful creature, you!_ +###### Idea Testing: +The fighting mechanic was tested first as it was more complicated than the resource management component. While testing the fighting mechanic, it was found to be quite fun and the game was then decided to be simplified to focus only on the fighting aspect. + +###### Detailed Design +Originally functions were used to create ```objects``` without the use of ```Class```. After refactoring the code to use a ```Class``` to define all characters, new entities and mechanics could be created quickly. + +###### Juicing +Pets and sounds were added. Improved sprites. + +###### To do: +1. Dog enemy (does not shoot, chases player and attacks) +2. Additional sounds for getting hit +3. Improvement to level design and difficulty adjustment +4. Reduce the use of `setInterval` and improve game performance + + +--- - This will serve as a helpful overall gauge of whether you met the project goals, but __the more important scores are the individual ones__ above, which can help you identify where to focus your efforts for the next project! +Sprites from: +- opengameart.org +- spriters-resource.com (Stardew Valley) +- charas-project.net diff --git a/assets/audio/catMeow.mp3 b/assets/audio/catMeow.mp3 new file mode 100644 index 00000000..7582771f Binary files /dev/null and b/assets/audio/catMeow.mp3 differ diff --git a/assets/audio/fightMusic.mp3 b/assets/audio/fightMusic.mp3 new file mode 100644 index 00000000..83e32571 Binary files /dev/null and b/assets/audio/fightMusic.mp3 differ diff --git a/assets/audio/shootSoundEnemy.wav b/assets/audio/shootSoundEnemy.wav new file mode 100755 index 00000000..d80bf3df Binary files /dev/null and b/assets/audio/shootSoundEnemy.wav differ diff --git a/assets/audio/shootSoundPlayer.wav b/assets/audio/shootSoundPlayer.wav new file mode 100755 index 00000000..0a0b69b2 Binary files /dev/null and b/assets/audio/shootSoundPlayer.wav differ diff --git a/assets/audio/spring.mp3 b/assets/audio/spring.mp3 new file mode 100644 index 00000000..f7295f72 Binary files /dev/null and b/assets/audio/spring.mp3 differ diff --git a/assets/css/stylesheet.css b/assets/css/stylesheet.css index e69de29b..4d62476a 100644 --- a/assets/css/stylesheet.css +++ b/assets/css/stylesheet.css @@ -0,0 +1,88 @@ +.container { + display: flex; + justify-content: left; +} + +body { + background: url("../images/background.png"); + font-family: "Press Start 2P"; +} + +.gameWrapper { + width: 800px; + height: 730px; +} + +.controls { + height: 400px; + width: 450px; + background: url("../images/controls.png"); + background-size: 100%; +} + +.startGame { + display: inline-block; + padding: 0; + height: 90px; + width: 250px; + background: green; + text-align: center; + color: white; + position: absolute; + top: 500px; + left: 500px; + font-size: 20px; +} + +#startGame { + margin: 7px auto; +} + +button { + margin-top: 20px; +} + +.gameBoard { + width: 800px; + height: 630px; + border: 3px solid black; + position: absolute; + display: inline-block; + background: url("../images/introScreen2.png"); + background-size: 103%; + background-repeat: no-repeat; +} + +.info { + width: 800px; + height: 60px; + display: flex; + justify-content: space-between; +} + +.aside { + display: inline-block; + padding: 0 50px; +} + +.hitpointsDiv { + display: inline-block; +} + +.scoreDiv { + display: inline-block; +} + +.cow1 { + background: url("../images/cow1.png"); + width: 80px; + height: 80px; + background-size: 100%; +} + +.cow2 { + background: url("../images/cow2.png"); + width: 80px; + height: 80px; + background-size: 100%; +} diff --git a/assets/images/annoyingDog.png b/assets/images/annoyingDog.png new file mode 100644 index 00000000..5a51a829 Binary files /dev/null and b/assets/images/annoyingDog.png differ diff --git a/assets/images/background.png b/assets/images/background.png new file mode 100644 index 00000000..7c5b61bb Binary files /dev/null and b/assets/images/background.png differ diff --git a/assets/images/bandit1.png b/assets/images/bandit1.png new file mode 100644 index 00000000..b8b51f28 Binary files /dev/null and b/assets/images/bandit1.png differ diff --git a/assets/images/char.png b/assets/images/char.png new file mode 100644 index 00000000..b21e494d Binary files /dev/null and b/assets/images/char.png differ diff --git a/assets/images/controls.png b/assets/images/controls.png new file mode 100644 index 00000000..e273c207 Binary files /dev/null and b/assets/images/controls.png differ diff --git a/assets/images/cow1.png b/assets/images/cow1.png new file mode 100644 index 00000000..cfe46149 Binary files /dev/null and b/assets/images/cow1.png differ diff --git a/assets/images/cow2.png b/assets/images/cow2.png new file mode 100644 index 00000000..8fe46e78 Binary files /dev/null and b/assets/images/cow2.png differ diff --git a/assets/images/doggo.png b/assets/images/doggo.png new file mode 100644 index 00000000..ef726b74 Binary files /dev/null and b/assets/images/doggo.png differ diff --git a/assets/images/fightPhase.png b/assets/images/fightPhase.png new file mode 100644 index 00000000..b668ad0d Binary files /dev/null and b/assets/images/fightPhase.png differ diff --git a/assets/images/fightPhase.svg b/assets/images/fightPhase.svg new file mode 100644 index 00000000..244a1073 --- /dev/null +++ b/assets/images/fightPhase.svg @@ -0,0 +1,360 @@ + \ No newline at end of file diff --git a/assets/images/fireball.png b/assets/images/fireball.png new file mode 100644 index 00000000..fd9b9595 Binary files /dev/null and b/assets/images/fireball.png differ diff --git a/assets/images/fireballBlue.png b/assets/images/fireballBlue.png new file mode 100644 index 00000000..844d5fe3 Binary files /dev/null and b/assets/images/fireballBlue.png differ diff --git a/assets/images/health.png b/assets/images/health.png new file mode 100644 index 00000000..afb29f15 Binary files /dev/null and b/assets/images/health.png differ diff --git a/assets/images/introScreen.png b/assets/images/introScreen.png new file mode 100644 index 00000000..e479c7ce Binary files /dev/null and b/assets/images/introScreen.png differ diff --git a/assets/images/introScreen2.png b/assets/images/introScreen2.png new file mode 100644 index 00000000..62affdbd Binary files /dev/null and b/assets/images/introScreen2.png differ diff --git a/assets/images/introScreen3.png b/assets/images/introScreen3.png new file mode 100644 index 00000000..4494d246 Binary files /dev/null and b/assets/images/introScreen3.png differ diff --git a/assets/images/onionFace2.png b/assets/images/onionFace2.png new file mode 100644 index 00000000..adbe1010 Binary files /dev/null and b/assets/images/onionFace2.png differ diff --git a/assets/images/overallFlow.png b/assets/images/overallFlow.png new file mode 100644 index 00000000..d82efd59 Binary files /dev/null and b/assets/images/overallFlow.png differ diff --git a/assets/images/overallFlow.svg b/assets/images/overallFlow.svg new file mode 100644 index 00000000..914e6b56 --- /dev/null +++ b/assets/images/overallFlow.svg @@ -0,0 +1,360 @@ + \ No newline at end of file diff --git a/assets/images/plantingPhase.png b/assets/images/plantingPhase.png new file mode 100644 index 00000000..3166c585 Binary files /dev/null and b/assets/images/plantingPhase.png differ diff --git a/assets/images/plantingPhase.svg b/assets/images/plantingPhase.svg new file mode 100644 index 00000000..da12575a --- /dev/null +++ b/assets/images/plantingPhase.svg @@ -0,0 +1,360 @@ + \ No newline at end of file diff --git a/assets/images/playerRed1.png b/assets/images/playerRed1.png new file mode 100644 index 00000000..e2ef87f8 Binary files /dev/null and b/assets/images/playerRed1.png differ diff --git a/assets/images/screenShot.png b/assets/images/screenShot.png new file mode 100644 index 00000000..1967fbb5 Binary files /dev/null and b/assets/images/screenShot.png differ diff --git a/assets/images/spring.png b/assets/images/spring.png new file mode 100644 index 00000000..8131e0a4 Binary files /dev/null and b/assets/images/spring.png differ diff --git a/assets/images/spring2.png b/assets/images/spring2.png new file mode 100644 index 00000000..42fc25f0 Binary files /dev/null and b/assets/images/spring2.png differ diff --git a/assets/images/weilisCat1.png b/assets/images/weilisCat1.png new file mode 100644 index 00000000..88194ade Binary files /dev/null and b/assets/images/weilisCat1.png differ diff --git a/assets/images/weilisCat2.png b/assets/images/weilisCat2.png new file mode 100644 index 00000000..46bf4971 Binary files /dev/null and b/assets/images/weilisCat2.png differ diff --git a/assets/images/weilisCat3.png b/assets/images/weilisCat3.png new file mode 100644 index 00000000..9e5198f1 Binary files /dev/null and b/assets/images/weilisCat3.png differ diff --git a/assets/js/script.js b/assets/js/script.js index e69de29b..3af91059 100644 --- a/assets/js/script.js +++ b/assets/js/script.js @@ -0,0 +1,990 @@ +const $gameBoard = $(".gameBoard") +const $body = $("body") +const gameWidth = parseInt($gameBoard.css("width")) +const gameHeight = parseInt($gameBoard.css("height")) +const $score = $(".score") +const $hitpoint = $(".hitpoints") +const $pauseBtn = $("#pauseBtn") +const $startBtn = $("#startBtn") +const $restartBtn = $("#restartBtn") +const $loseDiv = $("
Avoid enemies and shoot them to reduce their number. Can you kill them before they destroy your farm?
+