06MA4010991AP
Computer Game Design
Week 1
Overview of module
Weighting
Coursework 100%
Description |
Weight |
Due Dates |
Assignment 1 - Motion / Sound interactive game |
30% |
2 Feb |
Assignment 2 - Final project proposal |
20% |
9 Mar |
Assignment 3 - Final project |
40% |
13 Apr |
Assignment 4 - Self reflection statement |
10% |
20 Apr |
| Basic elements of computer game |
| Input |
| Feedback |
| Rules |
| Interface |
| Concept |
Input (Game Controller) Keyboard / Mouse |
Feedback Image |
Rules What players can / cannot do in the game |
Interface Visually display information |
Concept Entertainment |
Warm up exercise
Mario Game (version 1)
Source

| PImage marioImage; //mario.png PImage mushroomImage; //mushroom.png float mushroomX; //mushroom position float mushroomY; //mushroom position float marioSize; //mario size float mushroomSize; //mushroom size void setup() { size(800,600); //set canvas size mushroomX = random(0,width); //random mushroom position mushroomY = random(0,height); //random mushroom position marioSize = 16; //default mario size mushroomSize = 16; //default mushroom size mushroomImage = loadImage("mushroom.png"); //load in mushroom image marioImage = loadImage("mario.png"); //load in mario image } void draw() { background(0); //clear background (fill with black) //draw mushroom image at mushroom position with mushroom size image(mushroomImage,mushroomX,mushroomY,mushroomSize,mushroomSize); //draw mario image at mouse position with mario size image(marioImage,mouseX,mouseY,marioSize,marioSize); //hit test of mouse position to mushroom if(mouseX>mushroomX && mouseX<mushroomX+mushroomSize && mouseY>mushroomY && mouseY<mushroomY+mushroomSize) { mushroomX = random(0,width); //get new mushroom position mushroomY = random(0,height); //get new mushroom position marioSize *= 1.5; //increase mario size } } |
Version 2
Source
Center the mario and mushroom graphics
Using higher resolution image

PImage marioImage; PImage mushroomImage; float mushroomX; float mushroomY; float marioSize; float mushroomSize; void setup() { size(800,600); mushroomX = random(0,width); mushroomY = random(0,height); marioSize = 16; mushroomSize = 16; //CHANGES mushroomImage = loadImage("mushroomBig.png"); //load image with another file marioImage = loadImage("marioBig.png"); //load image with another file } void draw() { background(0); //CHANGES //place the image in mushroom position with center anchor point image(mushroomImage,mushroomX-mushroomSize/2,mushroomY-mushroomSize/2,mushroomSize,mushroomSize); //place the image in mouse position with center anchor point image(marioImage,mouseX-marioSize/2,mouseY-marioSize/2 ,marioSize,marioSize); if(mouseX>mushroomX && mouseX<mushroomX+mushroomSize && mouseY>mushroomY && mouseY<mushroomY+mushroomSize) { mushroomX = random(0,width); mushroomY = random(0,height); marioSize *= 1.5; } } |
Version 3
Source
Growing animation of mario
New algorithm of hit test

PImage marioImage; PImage mushroomImage; float mushroomX; float mushroomY; float marioSize; float mushroomSize; //CHANGES int hitFrameCount; //the frame count when hit void setup() { size(800,600); mushroomX = random(0,width); mushroomY = random(0,height); marioSize = 16; mushroomSize = 16; mushroomImage = loadImage("mushroomBig.png"); marioImage = loadImage("marioBig.png"); //CHANGES hitFrameCount = 0; //initialize hit frame count } void draw() { background(0); //CHANGES noTint(); //set to no tint to mushroom image(mushroomImage,mushroomX-mushroomSize/2,mushroomY-mushroomSize/2,mushroomSize,mushroomSize); if(frameCount - hitFrameCount < 25) //this runs at the 25 frames after a hit happened { tint(255 * sin(hitFrameCount-frameCount)); //tint the color to mario } else noTint(); //else no tint to mario image(marioImage,mouseX-marioSize/2,mouseY-marioSize/2 ,marioSize,marioSize); //CHANGES //change hit detetcion method if(abs(mouseX - mushroomX) < mushroomSize + marioSize && abs(mouseY - mushroomY) < mushroomSize + marioSize) { mushroomX = random(0,width); mushroomY = random(0,height); marioSize *= 1.5; //CHANGES //update hit frame count upon a hit hitFrameCount = frameCount; } } |
Version 4
Source
Sound Effects
Game finish condition
Finish time
Remove cursor in applet
Fix mushroom spawning position

//CHANGES import krister.Ess.*; //import sound library (Ess) PImage marioImage; PImage mushroomImage; PImage finishImage; float mushroomX; float mushroomY; float marioSize; float mushroomSize; int hitFrameCount; //CHANGES AudioChannel growSound; //grow sound AudioChannel finishSound; //finish sound boolean win; //game state (finished or not) int finishFrameCount; //finish frame count (game time) PFont font; //text font void setup() { size(800,600); //size(screen.width,screen.height); //CHANGES Ess.start(this); //initialize Ess noCursor(); //no cursor showing mushroomX = random(0,width); mushroomY = random(0,height); marioSize = 16; mushroomSize = 16; mushroomImage = loadImage("mushroomBig.png"); marioImage = loadImage("marioBig.png"); hitFrameCount = 0; //CHANGES finishImage = loadImage("finish.png"); //load finish image growSound = new AudioChannel("sfx.aif"); //load grow sound finishSound = new AudioChannel("finish.aif"); //load finish sound win = false; //set to not yet win font = loadFont("font.vlw"); //load font textFont(font); //use font textAlign(CENTER); //set text align to center } void draw() { background(0); //CHANGES if(win == true) //game finished { String outputText = "YOUR FINISH TIME IS "+finishFrameCount+"!"; //display content float textX = width*0.5; //display content position float textY = height*0.333; //display content position noTint(); //set to no tint image(finishImage,0,0,width,height); //paste finish image as background fill(100); //draw grey text (shadow) text(outputText,textX,textY); fill(255); //draw white text text(outputText,textX-3,textY-3); } else //game not yet finish { noTint(); image(mushroomImage,mushroomX-mushroomSize/2,mushroomY-mushroomSize/2,mushroomSize,mushroomSize); if(frameCount - hitFrameCount < 25) { tint(255 * sin(hitFrameCount-frameCount)); } else noTint(); image(marioImage,mouseX-marioSize/2,mouseY-marioSize/2 ,marioSize,marioSize); //hit test to mouse if(abs(mouseX - mushroomX) < (mushroomSize + marioSize)/2 && abs(mouseY - mushroomY) < (mushroomSize + marioSize)/2) { //CHANGES mushroomX = random(mushroomSize/2,width-mushroomSize/2); mushroomY = random(mushroomSize/2,height-mushroomSize/2); hitFrameCount = frameCount; marioSize *= 1.5; //CHANGES if(marioSize > 1000) //game finish condition { win = true; //set game finished finishSound.play(); //play finish sound finishFrameCount = frameCount; //set game finish frame count } else growSound.play(); //play grow sound } } } |
