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
3 answers

Looking for a random direction loop for an object

In CS class we made a simple game using a program called greenfoot. This game was much like the game "Frogger" if you are familiar. I am now practicing on my own, and want to make a game similar. My new game is going to be somewhat close to PacMan.…
New2.java
  • 29
  • 6
-1
votes
3 answers

Get nth digit after decimal point

What would be the most efficient way to grab the, say, 207th decimal place of a number? Would it just be x * Math.pow(10,207) % 10?
jashymko
  • 1
  • 2
-1
votes
1 answer

Timer in Greenfoot

I'm making a game right now and want to add a timer to count down to my end game screen, I can get the text to show up on my game screen but the numbers won't go down. Any feedback would help!
-1
votes
2 answers

Pause in Java + end method

I wanted to say for a school project in Greenfoot, that if a rover encounters a system error, it should output this and then wait a short time and then terminate the current method. However, the pause is marked with the following error code:…
Tim E
  • 11
  • 2
-1
votes
2 answers

Cannot find symbol in Java, GreenFoot

Before I start, I'd like to mention that I'm new to programming and I'm really bad. If you can think of ANY reason as to what may be causing my issue, it's probably worth checking. I'm making a game where the user controls a shark and has to move…
-1
votes
1 answer

Greenfoot (Java) adding two Objects

I'm Coding for School in Greenfoot on a plugin with which I can program a rover moving over a field... I want to add two objects with "addObject" on the same. Mark mark = new Mark(); Rover rover = new Rover(); addObject(mark && rover, 0,…
-1
votes
1 answer

Why is it adding more than 1 to my speed control?

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class Turtle extends Actor { /** * Act - do whatever the Turtle wants to do. This method is called whenever * the 'Act' or 'Run' button gets…
Schamph
  • 13
  • 3
-1
votes
1 answer

Force Java to use double instead of int

I have the following code: public void keyboard() { int sealX; double sealY; if (Greenfoot.isKeyDown("up")) { sealX = getX(); sealY = getY(); setLocation(sealX, (sealY - 1.25)); } if…
InterLinked
  • 1,247
  • 2
  • 18
  • 50
-1
votes
1 answer

How do I make my font bold with the GreenFoot API?

I have this font constructor written to make the font I want BOLD, however whenever I try to compile, it tells me the error Cannot find symbol - variable BOLD. Font font = new Font("Arial",font.BOLD, 40); These are the classes I'm importing: import…
Sdickie
  • 5
  • 3
-1
votes
1 answer

Java: Getting coordinates of a character, read out of a file

Good evening, for hours I've been searching for a solution for this problem without success so I figured I'd ask a question here! I have a question regarding reading characters / lines out of a textfile. I have been able to implement a function,…
-1
votes
2 answers

Java list! How do I get an object to determine if there is another object

// test for rock List rocks = getWorld().getObjectsAt(x , y, Rock.class); /* Look up the List class (java.util.List) in the Java API * and determine what method to use with the 'rocks' List * to determine if there…
-1
votes
1 answer

Greenfoot Application - Movement

Hello guys I am new to GreenFoot Java, however with ActionScript 3 I'm okay. Now I hear that AS3 and Java are very similar. In Green Foot application can I use public void act() { if (e.keycode == 39) {this.x +=4}; } Or does this…
Moynzy
  • 28
  • 6
-1
votes
4 answers

Why cannot find symbol - variable gameState

Structure of greenfoot https://www.dropbox.com/s/t4pau2mk3mh9npu/structure.JPG I did initiate the var gameState public class MineBoard extends GWorld { int gameState = 0; and when i try to access it from a sub class call "Block" under Actor…
Louis Tsai
  • 1,587
  • 3
  • 20
  • 33
-1
votes
1 answer

Greenfoot error at setLocation(mouse.getX(), mouse.getY());

I am making a game where you shoot down birds. I've made an actor that acts as a Crosshair, following the mouse around. This is the code which is generating the error (setLocation is line 18): MouseInfo mouse =…
Patrick Reck
  • 11,246
  • 11
  • 53
  • 86
-2
votes
1 answer

NullPointerException for Seemingly no reason

I've been trying to learn Java using Greenfoot, yet this code always seems to throw a NullPointerException no matter what I try. I've tried using a pointer, not using a pointer, and even changing the scope, and nothing works. The code looks like…
1 2 3
8
9