Penulisan kali ini membahas tentang game processing yang diselesaikan berkelompok yang terdiri dari rahmat ardi prastyo, annisa tri handayani, dan citra dewi riska. kodingan dibawah sebagian dari keseluruhan kodingan :
void
mousePressed()
{
if (dist(mouseX, mouseY, xPos,
200)<=20)
{
score=score+speed;
speed=speed+1;
}
else
{
if (speed<1)
{
speed=speed-1;
}
lives=lives-1;
}
if (lost==true)
{
speed=1;
lives=5;
score=0;
xPos=height/2;
xDir=1;
lost=false;
loop();
}
}
keseluruhan kodingan :
int xPos; //Position of the ball
int yPos;
int speed=1; //How fast is it moving?
int xDir=1; //what direction is the ball going?
int score=0; //Inital score
int lives=5; //Number of lives you start with
boolean lost=false; //Have you lost yet?
void setup() //Runs once when program launches
{
size (400,400);
smooth();
xPos=height/2; //Centers our ball
fill(0,250,0); //Makes the ball and text
textSize(13); //Sets the size of our text
}
void draw() //Loops over and over again
{
background (#E75B90); // background
ellipse(xPos, height/2,40,40); //Draw the ball
xPos=xPos+(speed*xDir) ; //update the ball's position
if (xPos > width-20 || xPos<20) //Did the ball hit the side?
{
xDir=-xDir; //If it did reverse the direction
}
text("score = "+score,10,10); //Print the score on the screen
text("lives = "+lives,width-80,10);
if (lives<=0)
{
textSize(20);
text("Click to Restart", 125,100);
noLoop(); //Stop looping at the end of the draw function
lost=true;
textSize(13);
}
}
void mousePressed() //Runs whenever the mouse is pressed
{
if (dist(mouseX, mouseY, xPos, 200)<=20) //Did we hit the target?
{
score=score+speed; //Increase the speed
speed=speed+1; //Increase the Score
}
else //We missed
{
if (speed<1) //If speed is greater than 1 decrease the speed
{
speed=speed-1;
}
lives=lives-1; //Take away one life
}
if (lost==true) //If we lost the game, reset now and start over
{
speed=1; //Reset all variables to initial conditions
lives=5;
score=0;
xPos=height/2;
xDir=1;
lost=false;
loop(); //Begin looping draw function again
}
}
int yPos;
int speed=1; //How fast is it moving?
int xDir=1; //what direction is the ball going?
int score=0; //Inital score
int lives=5; //Number of lives you start with
boolean lost=false; //Have you lost yet?
void setup() //Runs once when program launches
{
size (400,400);
smooth();
xPos=height/2; //Centers our ball
fill(0,250,0); //Makes the ball and text
textSize(13); //Sets the size of our text
}
void draw() //Loops over and over again
{
background (#E75B90); // background
ellipse(xPos, height/2,40,40); //Draw the ball
xPos=xPos+(speed*xDir) ; //update the ball's position
if (xPos > width-20 || xPos<20) //Did the ball hit the side?
{
xDir=-xDir; //If it did reverse the direction
}
text("score = "+score,10,10); //Print the score on the screen
text("lives = "+lives,width-80,10);
if (lives<=0)
{
textSize(20);
text("Click to Restart", 125,100);
noLoop(); //Stop looping at the end of the draw function
lost=true;
textSize(13);
}
}
void mousePressed() //Runs whenever the mouse is pressed
{
if (dist(mouseX, mouseY, xPos, 200)<=20) //Did we hit the target?
{
score=score+speed; //Increase the speed
speed=speed+1; //Increase the Score
}
else //We missed
{
if (speed<1) //If speed is greater than 1 decrease the speed
{
speed=speed-1;
}
lives=lives-1; //Take away one life
}
if (lost==true) //If we lost the game, reset now and start over
{
speed=1; //Reset all variables to initial conditions
lives=5;
score=0;
xPos=height/2;
xDir=1;
lost=false;
loop(); //Begin looping draw function again
}
}
cara bermain game ini, mengklik bola yang bergerak. Semakin tinggi level maka semakin cepat bola bergerak. dalam permainan ini hanya terdapat 5 lives, jika berkurang maka game berakhir.
link video dari game ini :
http://www.youtube.com/watch?v=7us5ZeUqruo&feature=youtu.be