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
1 answer

Logic Error in Player Controls in Greenfoot

Recently, I've been using Greenfoot, and I wanted to make a simple top-down/bullet-hell shooter. Everything was going smoothly until I tried some of the movement. It's simple enough with good old "arrow keys to move, space to shoot", but the…
0
votes
1 answer

Error on greenfoot, "illegal start of expression"

Whenever I hit compile it says illegal start of expression wherever private is located. Here is the code: /** * Act - do whatever the PlatformJumper wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed…
0
votes
1 answer

How do i use abstraction to modify this class so it shows both colors of keys?

So Currently, our Key class can only produce white keys. This is because I have hard-coded the file names of the key images ("white-key.png" and "white-key-down.png"). How do I use abstraction to modify the Key class so that it can show either…
0
votes
3 answers

Press [enter] to start the game, no error

I am trying to get a function where, when you press enter, you start the game, but it isn't working. There is no error. I have followed a tutorial. here is my code: import greenfoot.*; /** * Write a description of class Menu here. * * @author…
0
votes
1 answer

Greenfoot: Jfilechooser crashes program

So I am writing a program for a high school project in Java using Greenfoot. In my program, I use a JFileChooser to let the user choose an image to edit it and etc. Anyways, it seems that the JFileChooser always crashes my JVM when I run it a second…
TT1103
  • 1
0
votes
1 answer

Greenfoot loop not working

This is my code import greenfoot.*; import javax.swing.JOptionPane; public class tableTester extends Actor { String userInput; int level; public void act() { input(); if(level == 1) { …
meadwho
  • 19
  • 1
  • 5
0
votes
0 answers

How to make balls bounce off the edges in Greenfoot

I am learning programming on Greenfoot. I'm creating a scenario that has 5 balls which will follow these properties: The balls must bounce off the edges of the world in such a way that the angle of incidence equals the angle of reflection. Each…
Lesedi
  • 1
  • 2
0
votes
1 answer

Why can't I generate this GUI?

So I'm trying to create a GUI for a ball that is controlled by buttons to run through a maze. But just to begin with I want to create a frame with a few directional buttons and whenever I try to run this in eclipse it comes up with an error that is…
user4847292
0
votes
2 answers

Testing if random number equals a specific number

I know this might already have been answered, but all the places where i found it, it wouldn't work properly. I'm making a game in Greenfoot and I'm having an issue. So I'm generating a random number every time a counter reaches 600, and then…
0
votes
1 answer

Abstraction with variables

So I'm taking a highschool online Java class and well my teacher doesn't help... so we are learning about abstraction and I had already done this with my "alien" class that moves, he will face one way going forward and another going backward by…
power5000
  • 25
  • 1
  • 9
0
votes
1 answer

Printing a score counter in greenfoot. Outputting zero

I am trying to output a score in the greenfoot IDE and all is working fine (the score is increasing) until I try to print it. When I try to print it it changes to zero for some reason. Crab Class: public class Crab extends Animal { int health =…
Matt
  • 75
  • 1
  • 16
0
votes
2 answers

Get object to follow mouse in Java/Greenfoot

I have just started using greenfoot for school and I would like to create a game like this one: http://www.scirra.com/arcade/action/455/squared but I am having trouble getting the actor/object to follow my mouse. Like the black square does in the…
Matt
  • 75
  • 1
  • 16
0
votes
1 answer

nullPointerException error greenfoot

I'm working on a project for an intro to programming class, and I've run into a slight problem. We're making a side scroller, and I'm working on the score counter right now. My issue is that when I try to create a reference to the counter class in…
0
votes
1 answer

Moving the ball

I've been playing around with my code trying to make the ball in my program move though to be specific the scenario is a ball maze game where I have to make it so the ball moves 1 square at a time until I reach the goal block at the end however the…
0
votes
1 answer

Struggling with Greenfoot

In the assignment I was given for my Uni module titled problem solving & programming. I was given a scenario with errors in it and from reading the assignment the code listed below is where the errors are. So far I found that in the public void key…
1 2 3
8 9