Skip to content

Instantly share code, notes, and snippets.

@CraigMorton
Created September 21, 2016 12:06
Show Gist options
  • Save CraigMorton/4277ad04d870cb0942a23ad3173ac1ef to your computer and use it in GitHub Desktop.
Save CraigMorton/4277ad04d870cb0942a23ad3173ac1ef to your computer and use it in GitHub Desktop.

JS Constructor Lab

The task is to test drive the beginnings of an adventure game.

Tasks:

A.

  • Create a constructor to create a Hero character.
    • A Hero has a name
    • A Hero has health
    • A Hero has a favourite food
    • A Hero can talk saying their name

B.

  • Create a food constructor.
    • Food should have a name
    • Food should have a replenishment value

C.

  • A hero should be able to eat food, and health should go up by the replenishment value
  • If the food is their favourite food, their health should go up by 1.5 * value.

Further. D.

  • Create a Rat constructor
  • Rats should be able to touch food, if they do the food becomes poisonous.
  • Heroes that eat poisonous food should lose health.

E. Be creative. Extend the game! Give the hero super powers. Bring a baddy into it who takes over the world.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment