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

Variable Will Not Update (Inside If Statement)

Working on a school project where we're supposed to modify a game to become educational. I want to cycle through numbers 0, 1, and 2 through the variable moduleThree. But the variable will not update when I set it equal to something else than what I…
Jack Tapia
  • 33
  • 1
  • 1
  • 4
0
votes
1 answer

How do I auto generate an ID using arrays? And how do i create a freight status for each freight order?

So i have an assignment that requires me to program and create freight Id and update the status for every new order. Freight ID: This should be a unique number auto generated using the following simple algorithm. • Use the numbers '1939' as the…
0
votes
0 answers

Why is an input command being executed before a bunch of code that should come before it?

I'm currently coding the game Mastermind, the code-guessing game, and want to add in a feature that allows the user to undo their most recent guess. I ask the user whether they would like to undo their most recent guess (which requires user…
0
votes
1 answer

Arrow keys for multiplayer

The object is jerking around when using the turn keys instead of a smooth movement. I've tried moving around the two 4 and 6 keys (left and right) to else if and while statements inside and out of the main if statement. move(4); …
TravJ14
  • 27
  • 8
0
votes
0 answers

Method only returns value once (Greenfoot)

Having trouble with calling a method in my code (Is calling the right word? Hope so.) It will return the correct variable which is a number between 0 and 10, but after running it again in a loop it always returns the same number, even if the…
Game4Lols
  • 1
  • 1
0
votes
1 answer

Bullet won't remove itself

I'm currently trying to make a little game. The aim is to fly around shooting and collecting items. I've figured out how to shoot how i intend. However, my bullets dont get removed after they go out of bounds, giving me an…
Ryan W
  • 41
  • 1
  • 7
0
votes
0 answers

How to pass properties of one object to other class?

I'm currently trying to learn Java and the Greenfoot IDE. I've made a neat lil game, however, I'm struggling with the idea of passing variables from actor objects to world sub classes in order to keep track of the scoring system. Would anyone be…
Ryan W
  • 39
  • 6
0
votes
1 answer

Different value after setValue

i am new in java. I have one project for school - it's creating 2048 game. We have template which created by my lector and it's based on Greenfoot. EDIT: another thing I noticed: fields[x][y].setValue(10); …
0
votes
0 answers

Add() doesn't work in Java (Greenfoot)

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class MyWorld here. * * @author (your name) * @version (a version number or a date) */ public class MyWorld extends World { private…
M. Eng
  • 1
0
votes
1 answer

Volume control in Greenfoot

I am trying to create a simple mp3 player in green foot and use buttons to control the volume. I have some code that I think should be working but it isnt. Im not sure what the problem is. I am trying to increase the volume bu one when the up button…
tim_weaver
  • 21
  • 7
0
votes
2 answers

Null Pointer Exception with initialized variable

I am working on this asteroid game inside of greenfoot and my code keeps spiting out a java.lang.NullPointerException. The code is below. Error occurs on line 50: count = world.numberOfObjects();. I know there are several posts about…
tim_weaver
  • 21
  • 7
0
votes
0 answers

int currentMoney not updating(Greenfoot java)

I am trying to check whether or not a player has enough money to buy a path. I am casting to a method that returns the currentMoney variable. For whatever reason, when the int currentMoney updates in the money class, it does not update in the path…
0
votes
1 answer

Core dump when trying to start greenfoot

I am trying to start greenfoot on my machine with out much success. The OS is arch linux. I downloaded the Greenfoot-generic-310.jar and installed it with java -jar Greenfoot-generic-310.jar Java open-jdk-8 and java-openjfx-8.u172-1 are…
theDrifter
  • 1,631
  • 6
  • 24
  • 40
0
votes
1 answer

Greenfoot: Converting a double into an intenger; int cannot be dereferenced

I want to turn any double value into an intenger. I know that the part behind the comma will be lost. import java.lang.*; public int doubleToIntenger(double dbl){ int intenger; intenger = intenger.intValue(dbl); return intenger; } But…
1cedsoda
  • 623
  • 4
  • 16
0
votes
1 answer

I am having trouble to set color to my Greenfoot MyWorld class

I am new to programming and we have an assignment about making a Greenfoot game. now I am trying to set some colors to MyWorld but having some problems. My code in MyWorld file is public MyWorld() { // Create a new world with 600x400…
1 2 3
8 9