Shoot!

Unlike my midterm project which was more mechanical, for my final Interactive Media project I decided to focus more on programing and to create a competitive game using processing. My game is called ‘Shoot!’  and is set in space. The user controls a spaceship and has to gain as many points as possible in the given time frame. This is done by destroying as many asteroids as possible and by collecting bonus point icons. The user earns points every time they hit an asteroid with a laser beam. However, this causes the game to become progressively harder because the asteroids split in half when hit, thus creating more objects that could potentially collide with the spaceship. The asteroids are completely destroyed after multiple hits.

Other important aspects of the game are creating a drifting effect for all objects, creating a warped effect that teleports objects to the opposite side of the screen when objects pass the boundary and creating laser bullet objects that glide from the ship and destroy the asteroids on contact.

My game has 4 main parts: the main page, instruction page, final score page and the game page. To facilitate this, the game makes use of a variable ‘stage’ which is initialized at 0 and is assigned a number based on where a user clicks (using the mouseClicked() function for detection.) The draw function is made up of if statements that create the correct page based on which stage is selected. All the stages are functions of the the Game class.

I used classes to organize the structure of the code. The main classes are: Begin, Game, Ship, Asteroid, Bullets and Item.

The Ship class is one of the most important classes. The ship’s initial position is set by the PVector function and when acceleration is applied it changes this PVector value. The ships rotation and other important details are set in the initializer. To display the ship the Ship class has a display function that uses the concepts of push and pop matrix we covered in class. First pushMatrix() is used to store the current then the ship is drawn, rotated and translated. Finally popMatrix() is called to return to the initial matrix, allowing for future movement to easily be implemented. Another important function in the Ship class is the collide function which uses the dist() method to determine the current distance between the ships coordinates and all surrounding asteroids. If the distance is ever touching the function will return the value true, which will be used later to end the game.

The Asteroid class is a general class that makes use of the random function to create multiple different asteroid objects when they are initialized in a loop. This allows many different looking asteroids to be placed randomly throughout the screen when the game is started. 

To create laser bullets that fire from the ship and destroy asteroids, the Bullets class was created. Thus bullets are objects that are initialized when a user decides to fire. This means that the bullets inherit functionality such as positioning, boundary checking and checking for collisions. Bullets (and also asteroids) are stored in an object array when they are created and the game iterates over these arrays and uses their display functions to individually display each object in every frame.

The Begin class uses for loops to iterate over the arrays that contain the asteroids, items and bullets and displays them all.

Video of gameplay:

Processing Code:

I was planning on having a controller with 4 buttons control the game but unfortunately was not able to complete it by the showing date. However, I did build the controller and bellow is the schematic and pictures of the working controller.

 

 

Final Project

My project is an interactive game similar to ‘Asteroids’ that will be programed on Processing. The user will be in control of a spaceship that has to shoot and destroy all asteroids while simultaneously avoiding them. The user will lose the game if the spaceship hits an asteroid. There will be a four button (move left, right, accelerate, shoot) physical controller using the Arduino to control the spaceship. The asteroids will be randomly placed on the screen at the start of the level and will move in all directions. Once an asteroid is shot it will spilt in half. The asteroids will be completely destroyed after a few hits. To give the game the feeling of being in space the spaceship will drift even after the accelerator is pressed and released. Another aspect of the game will be what to do when the spaceship or asteroids hit the end of the screen. To give the game an ‘open’ feel once the asteroids and spaceship reach the end of the screen they will be transported to the opposite side, thus creating a warped effect.

The project has 2 major components. The digital program and the physical controller, of which the program will be the more demanding task.

The five most challenging parts of the project are: creating a drifting effect for all objects, creating the ‘warped’ effect when objects hit the boundary, detecting when an asteroid hits the spaceship, creating shots that destroy the asteroids and having the asteroids spilt in half when hit.

Currently the asteroids are randomly created at the start of the game, the spaceship moves naturally while drifting slightly and the game has a ‘warped’ effect whereby the objects on the screen are transported to the other side when they reach the boundary. The code I have written thus far is posted below (it is written in python):

 

 

 

Below is a diagram of the controller:

Design meets disability

At first I thought the author was overplaying the importance of design in products related to aiding disabilities. However, the example of glasses really helped change my mind. In fact design has played such a major role in the acceptance of glasses that I didn’t even think it would be an example in a book about ‘disabilities’. Reading about how people who wore glasses in the 1930s were viewed as strange and comparing it to nowadays helped me to understand just how important design and fashion were in helping to change society’s perspective.

The author pointed out that many who create these products aim for a degree of invisibility. However, just like the ‘invisible’ pink colored glasses of the 60s and 70s they do not help change the wearer’s and society’s view of that particular disability. On the other hand, some designers have gone too far in hopes of making a fashion statement by employing design features such as bright colors. However, this is unlikely to lead to mass acceptance and was not the path by glasses designers. I agree with the author suggestion that a middle ground should be found. One where designers don’t aim for invisibility or extreme designs.

Moving Robot

Processing:

Arduino:

 

 

Game + Controller

Avoid the sides:

My game is controlled with a potentiometer (moves a circle horizontally) and a light sensor (moves the circle vertically.) The objective of the game is to move along the black line from start to finish, without hitting the sides.

Arduino:

 

Processing:

 

 

 

Casey Reas. Response.

To me the talk by Casey Reas was about the potential beauty that can result from controlled chaos. Initially, I wasn’t completely certain of the notion of using contrasting concepts such as control and chaos together to create beautiful art. However, as the talk went on and I saw the results of his work I became more convinced of the idea. To achieve this concept of controlled chaos, randomness is added to the initial algorithms. By introducing uncertainty he is able to break away from traditional forms of art, in a similar fashion to artists in the early 20th century who created art by let pieces of paper fall randomly into place. Then by curating the computer generated art and by introducing qualities traditionally associated with beauty (such as symmetry) to the art, he is able to “control” the chaos. The end results are beautiful, unique pieces which stretch our imaginations.

Recreate: “Computer Graphics and Art”

 

 

The program creates 3 different patterns in each third of the display.

 

Midterm Project

For my midterm project I decided to make a catapult because I wanted to create something with a mechanical focus. The catapult was made using: 2 servo motors, 3 rectangular pieces of wood, a nut and bolt, a spring, 2 nails, 2 long pieces of acrylic, some washers, a bottle cap, which holds the object being fired; the Arduino and breadboard; a 10k ohm resistor; a push button and laser cut pieces of acrylic for the box.

 

To create the catapult, I first drilled a hole near the corner of all 3 pieces of wood. Next, I used a nut and bolt to hold the pieces together. I put some washers between the pieces of wood to keep the pieces spaced apart and to reduce friction. I placed 2 long pieces of acrylic under the 2 outer pieces of wood to ensure that the middle piece did not touch the bottom when it moved. I then stuck a nail, which attaches to the spring, to the middle piece of wood. A nail was also attached to one of the servo motors. These 2 nails were held together by a spring. To ensure maximum tension was applied to the spring I made sure that the motor was placed far enough from the piece of wood so that the spring was taut but not far enough to lift the piece of wood.

After all the components were set in place and the wiring was completed I put the acrylic boxes together. One box simply held the button and the other the catapult. The catapult box had a large slot cut through the middle so that the catapult could rise fully when launched and would be hidden when not in use.

 

 

The catapult works with 2 servo motors. One motor creates tension by pulling a spring that is attached to the middle piece of wood and the other motor keeps the piece of wood held down when the tension is applied. When the button is pressed the second motor moves, thereby releasing the middle piece of wood and launching the projectile held in the bottle cap.

Schematic:

Instrument

My project is a drum that uses the servo motor attached to a pencil to create a sound. It has 3 beats that a user can select by pressing one of the buttons on the board. Each beat is different and its tempo can be altered while the program is running. To do this a user must turn the potentiometer. This will increase or decrease the beats per minute (BPM) and will adjust the tempo of the beat. When the program starts a small melody is played by the speaker using the tone function, an array which stores the notes and a file which stores the a range of frequencies with the relevant notes. To make the instrument easy to use the buttons that change the beat do not have to be constantly held down. To do this I created 3 if statements with a variable called buttonPressed which holds the values 1-3 corresponding to each variable. When a button is pressed the variable records it. Then another set of if statements  checks which button number was pressed and calls the relevant beat. The beats are stored in function and I was able to make the beat loop by calling these functions in the loop section of the code. The beat functions for each button reference functions that play a short or long beat (quarter or eighth note.) For the project I used 3 buttons, 3 10k resistors, a servo motor, a pencil, tape and a breadboard. Below is a schematic:

 

 

 

Emotion and design.

The article states that products designed for more stressful situations should focus even more on human-centered design because stress can negatively impact cognition. In more relaxed settings more attention can be given to aesthetics as users will be more flexible to finding solutions when using the product. The article makes it clear that Norman believes in the equality of beauty and usability, not preferring one over the other. Thus, a useable product does not have to be unappealing aesthetically. Although he emphasizes usable design he stress the importance of the ability of aesthetics in creating emotional effects. This was illustrated by his preference for a colored screen computer even though it did not, in his opinion, add any functional benefit.