Files
SMIMS_2026_2/SMIMS-Game/Score.java
T

30 lines
691 B
Java

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class UI here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Score extends Actor
{
int timer;
/**
* Act - do whatever the UI wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
timer++;
draw_score();
}
public void draw_score(){
setImage(new GreenfootImage("Score:" + calculate_score(), 24, Color.WHITE, Color.BLACK));
}
public int calculate_score(){
return timer/60;
}
}