View on GitHub

idmd

Bush School Interactive Digital Media Design Course

Bush School IDMD Spring Semester 2021

Interactive Monster Project

Goals

This assignment will help you practice using if-statements, to allow your program to perform different operations without interference. You will be creating a custom monster, with a moving eye(s), and jumping interactions.

Specification

Tasks

  1. Create a own customized monster, it should have it’s very own function with parameters to control its position. It should have at least 1 leg and at least 1 eye, but everything else is up to you. Some inspiration is shown below, but remember this monster should be your very own and not a copy of someone else’s. You may want to sketch your ideas before you start to code and save those sketches and submit them with your portfolio link.

    Feel free to also explore the monster code to review functions, parameters, style, and commenting.

Example monsters: alt text alt text alt text

  1. Setup the if statements to control whether your program will display a monster with moving eyes, or a jumping monster. First start by creating a variable named page at the top of your code, you should set its starting value to 0. Then add the code below to draw.

     // call your monster function
     if (page == 0) {
         // add code here as you complete step 4
     } else {
         // add code here as you complete step 5
     }
    

    Notice, that your draw function should have a total of 1 call to your monster function.

  2. Add a mousePressed function that will switch between your two pages. If your monster is jumping and you user clicks then it should switch to the moving eye monster, if they click again it should switch back to the jumping monster .. and so on.

    To do this you will add page = 1 - page; into your mousePressed function.

    Run your code, you won’t see any changes yet because you haven’t written code to tell your monster to jump or move its eye but you should still see your monster and have no errors before moving on to the next step.

  3. Write code to move your eye(s). First add a variable at the top named eyeDirection and set its value to 0.

    Then find where your eye function is called from and add eyeDirection to your x value being passed into that eye function.

    Before proceeding, temporarily initialize eyeDirection to 10 and to -10, and notice that the eye should look right and then left; then set it back to 0. If its not moving then you have a bug, try and fix it and if you are stuck reach out for help.

    Add code to draw as indicated in step 2. This code should consist of conditional statements to determine if the eye should move left or right based on the mouse’s x-position (hint: you will use the p5.js built in variable named mouseX). Notice that you will probably want to increment your eyeDirection variable by 0.5 instead of 1 so it moves slowly.

    You may also consider using min/max to prevent your monster’s eye from leaving its face.

    Test your code. The eye should move when the mouse is on each side. You can decide whether the eyes should still move when the mouse is between them.

    If its working correctly, when you click it should stop you from moving the eyes, if you click again it should let you move the eyes again.

  4. Write code so that your monster jumps up and down. To start define two variables at the top: jumpValue, and jumpDir, you decide on the values for your monster.

    In draw, add an if statement to determine which way the monster should be jumping. When it hits the top it should come back down, and when it hits the bottom it should come back up. jumpValue is the value you are adding to the y position of your monster and jumpDir represents the speed and direction your monster is moving.

    If its working you should now be able to click to switch between your moving eyes and jumping monster.

Submit Code to Github and modify the index page

Extra Challenge