How to make a multiplier game like cookie clicker?
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class cookie here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class cookie extends Actor
{
/**
* Act - do whatever the cookie wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
int cookies = 0;
public void act()
{
if(Greenfoot.mouseClicked(this))
{
cookies ++;
}
// Add your action code here.
}
public int getScore(){
return cookies;
}
}import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class cookiespersec here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class cookiespersec extends Actor
{
/**
* Act - do whatever the cookiespersec 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.
}
}
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
import java.awt.Color;
import java.awt.Graphics;
/**
* Counter that displays a text and number.
*
* @author CWR
* @version 1 - based on MIK's asteroid counter
*/
public class cookies extends Actor
{
private static final Color TEXT_COLOR = new Color(250, 250, 250);
private static final Color TRANSPARENT_COLOR = new Color(0, 0, 0, 0);
private cookie cookie;
public cookies(cookie cookie)
{
this.cookie = cookie;
updateImage();
}
public void act() {
updateImage();
}
private void updateImage()
{
String text = "" + cookie.getScore();
GreenfootImage image = new GreenfootImage(text, 50, TEXT_COLOR, TRANSPARENT_COLOR);
setImage(image);
}
}