Questions tagged [greenfoot]

Greenfoot is an environment that makes it very easy to create 2D animations and games using Java.

Greenfoot is designed for beginners and makes it easy for people who have never programmed before to create games and animations without worrying about dealing with any complexities such as threading, double buffering or swing.

After scenarios have been created they can easily be shared by using the Greenfoot Gallery.

Links:

Main site (download Greenfoot here)

Greenfoot Gallery (users scenarios are published here)

Greenroom (only open to teachers)

128 questions
0
votes
2 answers

Creating matrices Java

I have trouble creating a matrice for a game map design. void prepareMatrix(int width, int height) { room = new int[height][width]; for(int i = 0; i < height; i++) { for(int j = 0; j < width; j++) { if(i <…
0
votes
1 answer

Greenfoot: Move two cars using different keys

I am new to java and Greenfoot. I would like to move two cars differently one using "up", "down", "left", "right" for the car1 and "w", "s", "a", "d" respectively. I would like to make something like Car.car1.isKeyDown("up") and…
dice
  • 7
  • 3
0
votes
1 answer

Iterate through the same methods inside objects of the same class

I am using greenfoot and am trying to iterate something so it is more clean. The cardsPile list is the current cards in the discard pile. I am trying to be more object oriented and am struggling with how to add multiple to the ArrayList. I am also…
0
votes
1 answer

My Greenfoot Program works as a greenfoot file but not a jar file

I am making a little arcade full of Vocabulary Games for school. When I run the program in the greenfoot window, it runs perfectly. But when I make a jar file of it, it stops when it is Prompted with Greenfoot.ask(). Here's the code: import…
Kyle Henry
  • 15
  • 1
  • 7
0
votes
1 answer

Greenfoot - isKeyDown() seems to hold its value

This is a sprinting function for a game, if the player has greater then 0% spring left then he can sprint, if it is at 0% the player cannot sprint. If the player is not sprinting then the sprint % will start to regenerate. The problem: When the…
Max Mcgregor
  • 101
  • 9
0
votes
1 answer

Exporting Java to Greenfoot

Rather than using Greenfoot, I've just imported the Greenfoot library into IntelliJ so I can code there externally. If I wanted to import that Java code from IntelliJ back into Greenfoot to test, it would require the construction of a…
user7514069
0
votes
1 answer

Greenfoot incompatible type error

Made some simple game at work and used the fallowing code: Player player = getOneIntersectingObject(player.class); Which compiles and executes just fine, at work. Home, however, it won't compile it says that incopatible types: Greenfoot.Actor…
0
votes
1 answer

Inheritance related query regarding Greenfoot

For all of those who aren't familiar with Greenfoot, below is the context:- Greenfoot is a java learning tool using some animation. In this tool, there is a predefined class called 'Actor' with some predefined methods. We can add objects by creating…
amsquareb
  • 148
  • 10
0
votes
1 answer

Displaying the same contents onto a different Greenfoot world

For a Greenfoot final class project, I decided to make a game called "Doggie the Super Catcher". What this game basically does is that the actor, Doggie, will try his best to catch the clovers and special treats that seems to be falling from the…
Melody Li
  • 3
  • 3
0
votes
0 answers

Using a string to call an array by name in java (greenfoot)

I have a series of character arrays storing level data for a game named LEVEL_1, LEVEL_2 etc. I have to make the program advance to the next level when complete, and so I made a string levelString = ("LEVEL_" + nextLevelNumber) When I try to then…
M. Finch
  • 1
  • 1
0
votes
1 answer

Project Help - Greenfoot/javascript

I have a "life bar" defined by one subclass, and call it in another, but for some reason my teacher nor i could get it to update... any reason why that is? Here is the "life bar" method, named score: import greenfoot.*; // (World, Actor,…
0
votes
1 answer

Why am I getting java.lang.ArithmeticException: / by zero?

I am a beginner in java and my code to generate a random sums throws a strange exception... public void randomRekensom(int n) { switch(n) { case 1: this.max = 100; break; case 2: this.max = 150; …
iSidle
  • 121
  • 10
0
votes
1 answer

Why won't my rocket lives decrease upon collision?

Ok, so in my game design class we are using GreenFoot to create a game. She asked us to make the hardest Asteroid game that we could while making it fair. So I decided to add a set amount of rocket lives. i got it all set up and it works, it just…
Jon Cole
  • 3
  • 1
0
votes
1 answer

JAVA Greenfoot Game Over / Win check on yCoordinate

I'm having this issue with my 2 checks for a frogger-style game. So the Gameover check is a simple collision check on the frog object. The next check does a getY coord check for checking if the frog object has hit the roof of the world ergo has…
R.m
  • 19
  • 6
0
votes
2 answers

Static methods in greenfoot

So for my class I have to use the Greenfoot IDE. And my goal is to: “the pig eats all the mushrooms currently in the barrel” The pig will have to call the barrel’s getMushroom() method to find out how many mushrooms the barrel currently stores.…
1 2 3
8 9