ICM Week 3 - Documentation

23 Sep 2015
courses, documentation, icm

For whatever reason, after reading this week's assignment I knew that I should try to make a game like Asteroids, perhaps something that could be a multi-week project.

Part of our assignment this week was to program in pairs. I worked with Danielle, we started by going to the Saturday afternoon ICM Halp Session. Moon led the session and it was helpful to go over some of the things we learned in class and walk through some new example and functions.

To start on the Asteroid game, I wanted to use the constrain function so the ship would only be able to move so far on the screen. (The more I think about it, the game I have in mind is less Asteroids and more Phoenix, a similar game for the TI-83 calculator).

I wanted to shoot a line across the screen when the user pressed the space bar, but it doesn't look like p5 has a function that would trigger an event when just the space bar is pressed (keyCode is close, it triggers actions for some of your more fancy keys like shift, tab, and the arrow keys, but the space bar isn't included in the set). So instead I used the keyPressed function, which will trigger the event when any key is pressed. I'm assuming that people's natural inclination will be to hit the space bar to fire and they won't even notice they've been duped.

After getting that set up, I was having trouble getting the line (the line of fire, that is) to appear after you hit the space bar. I tried everything I could think of to change and it still didn't work - and then I remembered I could ask for help! I sent my query to the ICM list and received a super helpful response in an hour, from Shanghai at that! Technology wow!

One of my problems was I was coloring the line with fill. I learned that lines can only be filled with stroke (as a shape with a width of 1 pixel, there's nothing to fill in). Second, I needed to create separate variables for the laser location and for the ship location. Once I had those changes, I was able to shoot lasers. Pew! Pew!

There are a couple things I'd still like to work on

  • You can only shoot 1 laser at a time. I would like to be able to fire to my heart's content
  • We need to add some shit to blow up and then figure out how to blow it up
  • Maybe a score keeper thing
  • Email: coblezc@gmail.com
    Twitter: @coblezc
  • CC-BY