GithubHelp home page GithubHelp logo

ptrcklehmann / ironhack-lab-p5-treasure-hunt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from j-1000/ironhack-lab-p5-treasure-hunt

0.0 1.0 0.0 65 KB

Simple game using P5.js

CSS 15.11% HTML 53.21% JavaScript 31.67%

ironhack-lab-p5-treasure-hunt's Introduction

logo_ironhack_blue 7

JS | P5 Treasure Hunt

Introduction

Let's implement a simple treasure hunt game, where you would need to move a player around in search for a not-so-hidden treasure.

Iteration 1

The goal is to reproduce the following grid.

The main.js (that you will not forget from importing in your html too) will contain the starter code to manipulate your canvas.

To finish this iteration, you have to write the code of the drawGrid function.

Iteration 2

Next step is creating a class Player. It should have at least:

  • a col property, to indicate the column
  • a row property, to indicate the row the player is in.
  • a moveUp() method, to move the player up one row
  • a moveDown() method, to move the player down one row
  • a moveLeft() method
  • a moveRight() method

Expected output:

const player = new Player(0,0) // (0,0) = Initial position (col, row)
player.moveDown() // Increase by 1 the value of player.row
player.moveDown() // Increase by 1 the value of player.row
player.moveRight() // Increase by 1 the value of player.col
console.log(player.col, player.row) // => 1,2

Iteration 3

Write the draw method in the Player class that should display the player on the canvas, based on its col and row.

Use assets/character-down.png from the assets for this iteration.

Call the player's draw() method from the main draw function.

Iteration 4

Write the keyPressed method that should detect LEFT_ARROW, RIGHT_ARROW, UP_ARROW, DOWN_ARROW and move the player accordingly.

Make sure you clear() before drawing your player again ๐Ÿ˜‰

Iteration 5

Create a class Treasure with a method setRandomPosition() and a property col and row.

Create a function drawTreasure() that displays the treasure on the canvas. The picture is images/treasure.png

Iteration 6 (BONUS)

Find some bonuses to the game!

  • Scores
  • Add a second player ๐Ÿ’กkeycode.info
  • Try to make use of all the assets provided

You can find a demo here

ironhack-lab-p5-treasure-hunt's People

Contributors

j-1000 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.