This site requires JavaScript, please enable it in your browser!
Greenfoot back
HBMC
HBMC wrote ...

2014/6/6

How to make a multiplier game like cookie clicker?

HBMC HBMC

2014/6/6

#
How to make a multiplier game like cookie clicker?
danpost danpost

2014/6/6

#
Please elaborate. What part of coding it are you having problems with? Show attempted code.
HBMC HBMC

2014/6/7

#
Im just started now..... Cookie:
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;
    }   
}
Cookiespersec:
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.
    }    
}
Cookies:
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);
 }
} 
You need to login to post a reply.