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

2011/6/19

Steps to Time?

manster2008 manster2008

2011/6/19

#
I am making a game where an animation occurs. First of all, if you have any clue how I can make my own video with pictures I have drawn myself and then display it on Greenfoot, that would be way better and easier. But if you don't, I would like to know how many steps are in one second at speed 50, if that is possible. Thank you... if you would like to see my code for my class, here it is...
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class Stickman here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Stickman  extends Actor
{
    public int i;
    GreenfootImage img;
    public boolean water;
    public boolean green;
    public boolean lava;
    public int j;
    /**
     * Act - do whatever the Stickman wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        
        if (i == 0) {
            Space s = (Space) getWorld();
            if(s.animation == 1) {
                img = new GreenfootImage("magma1.jpg");
                lava = true;
            }
            else if(s.animation == 2) {
                img = new GreenfootImage("fallingparachute1.jpg");
                green = true;
            }
            else {
                img = new GreenfootImage("surfing1.jpg");
                water = true;
            }
            i = 1;
            img.scale(100, 100);
            setImage(img);
        }
        animation1();
        animation2();
        animation3();
    }
    public void animation1() {
        if(lava) {
            for(int b = 0; b < 100; b++) {
                
            }
        }
    }
    public void animation2() {
        if(green) {
            for(int c = 0; c < 100; c++) {
                
            }
        }
    }
    public void animation3() {
        
    }    
}
manster2008 manster2008

2011/6/19

#
Another thing, the variable animation is because the stickman can do three different things (skydive, surf over lava, jump over waterfall) Thanks
davmac davmac

2011/6/22

#
You can measure the speed yourself using System.currentTimeMillis() - it returns (as a "long") the number of milliseconds since 1 January 1970. You can simply print it to the terminal each act() and then calculate the difference by hand.
You need to login to post a reply.