Hi
This may seem a little noobie, but i started with programming just a few weeks ago in school. Now I'm at our open day to present the subject itself to younger students which are interested to come to our school. I thought of programming a simple game in which the player is a camel and needs to collect all trees in 5 seconds (for testing purpose i put it to 60).
My problem ist that the console won't give me the text it should ones collected all trees.
Heres the code:
In advance: Thanks for helping!
Kai
public class Camel extends Actor { private long startTime; public Camel(){ startTime = getCurrentTimeMillis(); } public void act() { move(5); if(Greenfoot.isKeyDown("left")) { turn(-3); } if(Greenfoot.isKeyDown("right")) { turn(3); } int coordX = getX(); int coordY = getY(); if(coordX >= 580 || coordX <= 20 || coordY >= 380 || coordY <= 20) { this.setRotation(this.getRotation()+180); } int Trees = 0; if(getElapsedTimeInSeconds() >= 60) { System.out.println("Zeit vorbei - Ende"); Greenfoot.stop(); } if(isTouching(Tree.class)) { removeTouching(Tree.class); Trees++; } if(Trees >= 5) { System.out.println("Gewonnen!"); Greenfoot.stop(); } } private long getCurrentTimeMillis(){ return System.currentTimeMillis(); } public long getElapsedTimeInSeconds(){ return (getCurrentTimeMillis() - startTime)/1000; } }