Escolar Documentos
Profissional Documentos
Cultura Documentos
Simulasi dan
Komunikasi C1
Digital
untuk
SMK/MAK Kelas X
prepare();
}
/**
* Called when game is up. Stop running and display
score.
*/
public void selesai()
{
addObject(new skor(counter.getValue()), getWidth()/2,
getHeight()/2); //menampilkan pesan ”Game Over dan skor terakhir
yang diperoleh”
}
/**
* Prepare the world for the start of the program. That
is: create the initial
* objects and add them to the world.
*/
private void prepare()
{
}
}
/**
* Write a description of class bg here.
*
* @author Andi Novianto@smkbisa2018
* @version trial
*/
public class ball extends Actor
{
int x=3;
int y=3;
/**
* Act - do whatever the ball wants to do. This method
is called whenever
* the ’Act’ or ’Run’ button gets pressed in the
environment.
*/
public void act()
{
// Add your action code here.
gerak();
kanan();
kiri();
atas();
pemain();
}
public void gerak()
{
setLocation(getX()+x,getY()+y);
}
public void kanan()
{
if(getX()>=getWorld().getWidth()-getImage().
getWidth()/2){
x=x-1;
}
}
public void kiri()
{
if(getX()<=getImage().getWidth()/2){
x=x+1;
}
}
/**
* Write a description of class bg here.
*
* @author Andi Novianto@smkbisa2018
* @version trial
*/
public class player extends Actor
{
/**
* Act - do whatever the player wants to do. This
method is called whenever
* the ’Act’ or ’Run’ button gets pressed in the
environment.
*/
/**
* Write a description of class bg here.
*
* @author Andi Novianto@smkbisa2018
* @version trial
*/
public class tembok extends Actor
{
/**
* Act - do whatever the tembok wants to do. This
method is called whenever
* the ’Act’ or ’Run’ button gets pressed in the
environment.
*/
/**
* Write a description of class bg here.
*
* @author Andi Novianto@smkbisa2018
* @version trial
*/
public class skor extends Actor
{
/**
* Act - do whatever the skor wants to do. This method
is called whenever
* the ’Act’ or ’Run’ button gets pressed in the
environment.
*/
public static final float FONT_SIZE = 48.0f;
public static final int WIDTH = 400;
public static final int HEIGHT = 300;
/**
* Create a score board with dummy result for testing.
*/
public skor(){
this(25);
}
/**
* Make the score board image.
*/
private void makeImage(String title, String prefix, int
score){
GreenfootImage image = new GreenfootImage(WIDTH,
HEIGHT);
public Counter()
{
this(“”);
}
updateImage();
}
/**
* Make the image
*/
private void updateImage()
{
GreenfootImage image = getImage();
image.clear();
image.drawString(text + value, 1, 18);
}
}