/* Balloon Fight (Processing edition and without the fighting ) Referenced the code found here http://www-acad.sheridanc.on.ca/PROG14998/2017/interactive-toy/michael_pereira_interactive_toy/index.html Based on the game programmed by Satoru Iwata, Balloon Fight (1984) http://nintendo.wikia.com/wiki/Balloon_Fight I wanted to program in music but couldn't so here's a youtube link to the Balloon Fight theme instead https://www.youtube.com/watch?v=YL5Q4GybKWc */ //The character being controlled float balloonManX; float balloonManY; //bm is an acronym for 'Balloon Man' float bmSpeed=4; //Whether or not the character is flying determines if //the flapping animation should play //green balloons and their initial position float greenPositionX=10; float greenPositionY=-400; float greenSpeed=8; float greenPosition2X=100; float greenPosition2Y=-450; float green2Speed=7; float greenPosition3X=200; float greenPosition3Y=-490; float green3Speed=5; //The starting position of the character int PositionX = 0; int PositionY = 1; // =1 makes the character fall if no buttons are pressed void setup () { background (#000000); size (400, 400); frameRate(30); } void draw () { background (#000000); noStroke(); stars(); drawgreenBalloon(); drawballoonMan(); balloonMovement(); boundaries(); } //Draws The stars void stars() { fill (#FFFFFF); rect (10, 380, 5, 5); rect (300, 50, 5, 5); rect (60, 100, 5, 5); rect (300, 350, 5, 5); rect (50, 50, 5, 5); rect (100, 20, 5, 5); rect (200, 200, 5, 5); rect (10, 270, 5, 5); rect (270, 150, 5, 5); rect (350, 200, 5, 5); rect (100, 300, 5, 5); noFill(); } //Draws the green balloons// void drawgreenBalloon() { //balloons 1 fill (#58F898); rect (greenPositionX+50, greenPositionY+250, 60, 80); rect (greenPositionX+60, greenPositionY+240, 40, 10); rect (greenPositionX+40, greenPositionY+260, 10, 60); rect (greenPositionX+30, greenPositionY+280, 10, 20); rect (greenPositionX+110, greenPositionY+260, 10, 60); rect (greenPositionX+120, greenPositionY+280, 10, 20); rect (greenPositionX+60, greenPositionY+330, 40, 10); noFill(); fill (#233BEF); rect (greenPositionX+80, greenPositionY+340, 10, 20); rect (greenPositionX+70, greenPositionY+360, 10, 20); noFill(); fill (#FFFFFF); rect (greenPositionX+80, greenPositionY+270, 10, 10); rect (greenPositionX+90, greenPositionY+280, 10, 20); noFill(); //balloons 2 fill (#58F898); rect (greenPosition2X+50, greenPosition2Y+250, 60, 80); rect (greenPosition2X+60, greenPosition2Y+240, 40, 10); rect (greenPosition2X+40, greenPosition2Y+260, 10, 60); rect (greenPosition2X+30, greenPosition2Y+280, 10, 20); rect (greenPosition2X+110, greenPosition2Y+260, 10, 60); rect (greenPosition2X+120, greenPosition2Y+280, 10, 20); rect (greenPosition2X+60, greenPosition2Y+330, 40, 10); noFill(); fill (#233BEF); rect (greenPosition2X+80, greenPosition2Y+340, 10, 20); rect (greenPosition2X+70, greenPosition2Y+360, 10, 20); noFill(); fill (#FFFFFF); rect (greenPosition2X+80, greenPosition2Y+270, 10, 10); rect (greenPosition2X+90, greenPosition2Y+280, 10, 20); noFill(); //balloons 3 fill (#58F898); rect (greenPosition3X+50, greenPosition3Y+250, 60, 80); rect (greenPosition3X+60, greenPosition3Y+240, 40, 10); rect (greenPosition3X+40, greenPosition3Y+260, 10, 60); rect (greenPosition3X+30, greenPosition3Y+280, 10, 20); rect (greenPosition3X+110, greenPosition3Y+260, 10, 60); rect (greenPosition3X+120, greenPosition3Y+280, 10, 20); rect (greenPosition3X+60, greenPosition3Y+330, 40, 10); noFill(); fill (#233BEF); rect (greenPosition3X+80, greenPosition3Y+340, 10, 20); rect (greenPosition3X+70, greenPosition3Y+360, 10, 20); noFill(); fill (#FFFFFF); rect (greenPosition3X+80, greenPosition3Y+270, 10, 10); rect (greenPosition3X+90, greenPosition3Y+280, 10, 20); noFill(); } //Draws the Balloon man// void drawballoonMan() { Position(); //balloons fill (#DB2B00); rect (balloonManX+160, balloonManY+30, 40, 10); rect (balloonManX+150, balloonManY+40, 60, 10); rect (balloonManX+140, balloonManY+50, 80, 10); rect (balloonManX+140, balloonManY+60, 50, 10); rect (balloonManX+200, balloonManY+60, 20, 10); rect (balloonManX+130, balloonManY+70, 70, 20); rect (balloonManX+140, balloonManY+90, 80, 20); rect (balloonManX+150, balloonManY+110, 60, 10); rect (balloonManX+160, balloonManY+120, 40, 10); rect (balloonManX+210, balloonManY+70, 20, 20); rect (balloonManX+220, balloonManY+30, 40, 10); rect (balloonManX+220, balloonManY+40, 50, 10); rect (balloonManX+230, balloonManY+50, 20, 10); rect (balloonManX+260, balloonManY+50, 20, 10); rect (balloonManX+230, balloonManY+60, 30, 10); rect (balloonManX+270, balloonManY+60, 10, 10); rect (balloonManX+240, balloonManY+70, 20, 10); rect (balloonManX+270, balloonManY+70, 20, 10); rect (balloonManX+240, balloonManY+80, 50, 10); rect (balloonManX+230, balloonManY+90, 50, 20); rect (balloonManX+220, balloonManY+110, 50, 10); rect (balloonManX+220, balloonManY+120, 40, 10); noFill(); fill (#FFDBAB); rect (balloonManX+190, balloonManY+60, 10, 10); rect (balloonManX+200, balloonManY+70, 10, 20); rect (balloonManX+180, balloonManY+130, 10, 10); rect (balloonManX+190, balloonManY+140, 10, 10); rect (balloonManX+220, balloonManY+140, 10, 10); rect (balloonManX+230, balloonManY+130, 10, 10); rect (balloonManX+250, balloonManY+50, 10, 10); rect (balloonManX+260, balloonManY+60, 10, 20); noFill(); fill (#233BEF); rect (balloonManX+210, balloonManY+110, 10, 10); rect (balloonManX+220, balloonManY+90, 10, 20); rect (balloonManX+230, balloonManY+70, 10, 20); rect (balloonManX+220, balloonManY+50, 10, 20); rect (balloonManX+210, balloonManY+40, 10, 10); noFill(); //balloonManBody fill (#233BEF); rect (balloonManX+180, balloonManY+150, 50, 10); rect (balloonManX+170, balloonManY+160, 40, 20); rect (balloonManX+220, balloonManY+160, 20, 10); rect (balloonManX+210, balloonManY+170, 30, 30); rect (balloonManX+200, balloonManY+180, 10, 10); rect (balloonManX+210, balloonManY+200, 20, 10); rect (balloonManX+180, balloonManY+240, 10, 10); rect (balloonManX+180, balloonManY+250, 30, 10); rect (balloonManX+190, balloonManY+260, 30, 10); noFill(); fill (#FFDBAB); rect (balloonManX+210, balloonManY+160, 10, 10); rect (balloonManX+170, balloonManY+180, 10, 10); rect (balloonManX+190, balloonManY+180, 10, 20); rect (balloonManX+160, balloonManY+190, 20, 20); rect (balloonManX+180, balloonManY+200, 20, 20); rect (balloonManX+200, balloonManY+210, 20, 10); rect (balloonManX+210, balloonManY+230, 10, 10); fill (#DB2B00); rect (balloonManX+180, balloonManY+180, 10, 20); rect (balloonManX+200, balloonManY+190, 10, 20); rect (balloonManX+190, balloonManY+220, 30, 10); rect (balloonManX+220, balloonManY+210, 10, 20); rect (balloonManX+230, balloonManY+200, 10, 30); rect (balloonManX+220, balloonManY+230, 30, 20); rect (balloonManX+240, balloonManY+220, 10, 10); rect (balloonManX+200, balloonManY+230, 10, 10); rect (balloonManX+200, balloonManY+240, 30, 10); rect (balloonManX+210, balloonManY+250, 30, 10); } //Arms //Armframe1 void arm1() { fill (#233BEF); rect (balloonManX+220, balloonManY+220, 20, 10); rect (balloonManX+230, balloonManY+210, 20, 10); rect (balloonManX+240, balloonManY+180, 20, 30); noFill(); fill(#FFDBAB); rect (balloonManX+250, balloonManY+160, 10, 20); rect (balloonManX+260, balloonManY+150, 10, 40); rect (balloonManX+270, balloonManY+180, 10, 10); } //Armframe2 void arm2() { fill (#233BEF); rect (balloonManX+220, balloonManY+220, 30, 10); rect (balloonManX+230, balloonManY+230, 30, 10); rect (balloonManX+240, balloonManY+240, 20, 10); fill (#FFDBAB); rect (balloonManX+240, balloonManY+250, 30, 10); rect (balloonManX+250, balloonManY+260, 30, 10); } //Setting up the Character's movement void keyPressed() { //Nothing moves until you press a key loop(); if (key=='w') { arm1(); PositionY=-1; } if (key=='a') { PositionX=-2; } if (key=='d') { PositionX=2; } } void keyReleased() { if (key=='w') { arm2(); PositionY=1; } else if (key=='a') { PositionX=0; } else if (key=='d') { PositionX=0; } } void Position () { balloonManX+=bmSpeed*PositionX; balloonManY+=bmSpeed*PositionY; } //The boundaries //To make sure the balloon man void boundaries() { if (balloonManX>width-100) { balloonManX=-250; } else if (balloonManX>width+100) { balloonManX=250; } } // Making the balloons move down and respawn at the top void balloonMovement() { //balloon1 greenPositionY+=greenSpeed; if (greenPositionY>height) { greenPositionY=-400; greenPositionX=random(50, 100); } //balloon2 greenPosition2Y+=green2Speed; if (greenPosition2Y>height) { greenPosition2Y=-400; greenPosition2X=random(20, 300); } //balloon3 greenPosition3Y+=green3Speed; if (greenPosition3Y>height) { greenPosition3Y=-400; greenPosition3X=random(10, 200); } }