This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
Discussions
You need to login to take part
Current Discussions
Kinect server not working
By lvv1227, with 3 replies.
Last reply by nccb, almost 14 years ago:
Ok, thanks for letting me know. I'll rework the software for the next release so that it doesn't do that again in future.
Making things happed when in a specific world
By tallyaka, with 13 replies.
Last reply by tallyaka, almost 14 years ago:
Nevermind! I got it to work! Thanks so much for all your help! I really appreciate it!
Online game work on LAN (WLAN) but not internet?
By qnanqing, with 6 replies.
Last reply by qnanqing, almost 14 years ago:
Oh it working now! the program works fine with other computer!!!!!!!
Not working, but why????
By TheNightStrider, with 9 replies.
Last reply by davmac, almost 14 years ago:
doing while(!Greenfoot.isKeyDown("enter")){Greenfoot.delay(1)} does the same thing right?
Yep!
What difference would replacing Greenfoot.delay(...) with repaint() make?
It would let the world repaint, but it would still be an unbounded tight loop. See my comment above.
Inventory
By DMCGames, with 1 reply.
Replied to by DonaldDuck, almost 14 years ago:
I would create an object inventory (an actor, but remove the extends Actor to make it an "other class") and inside of it make a static array called inv. You can make the array as large as you want inventory slots. Everything in this class must be static and can be called from another class by saying inventory.something or you can write inventory i = new inventory; i.something and not need to have statics. The advantage to the second method is that the variables will be reset with the program instead of having to write a reset method for it.
start/restart button
By tylers, with 1 reply.
Replied to by Duta, almost 14 years ago:
Not unless you're going to re-code the actual Greenfoot source-code
embed a webpage onto a scenario
By tylers, with 2 replies.
Last reply by tylers, almost 14 years ago:
ok thanks i will give it a miss then :)
for loop working on menu
By programmer22, with 1 reply.
Replied to by danpost, almost 14 years ago:
To have code execute only at the initial
start
of the scenario, create a method called 'public void started()' (a method of this name will over-ride the empty super-class method with the same name that is called when the 'Run' button is pressed. The only problem to deal with is, what happens when to scenario is paused and then re-started (it
will
run again). That being said, you need a boolean instance variable in the world class to track the initial start. <Code Omitted>Then, start your new method with
strange?
By programmer22, with 2 replies.
Last reply by programmer22, almost 14 years ago:
its ok i figured it out i just borrowed some pics
Sound Problem? Help!
By TheNightStrider, with 2 replies.
Last reply by TheNightStrider, almost 14 years ago:
It had no tags on anyway - i have converted them in wavs anyway now - this was really irritating me!
"Life is too short..." Using getObjectsInRange()
By Omniscience, with 7 replies.
Last reply by Omniscience, almost 14 years ago:
Thanks! Works great... plus I understood the logic behind it! I'm gonna try and create a Game Over dialogue Box, which will appear when the Car.class no longer exists in the world. Will post feedback! Thanks again
danpost
!
Random and not repeating
By Gazzzah, with 1 reply.
Replied to by Gazzzah, almost 14 years ago:
I could do this with 4 booleans I guess, but I figure there might be an easier way. It's kind of messy to have a massive "while" statement consisting of "(position == 1 && used1) || (position == 2 && used2) || etc...
Random # and chance problems
By Tomc84, with no replies.
I am suppose to pick a # between 1-4 for my vertical speed at random with a 50% chance to go up or down. Same with my left and right and I have no clue what I'm doing wrong... PLZ I need help :( import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Ball here. * * @author (your name) * @version (a version number or a date) */ public class Ball extends Actor { private int ySpeed; private int xSpeed; private int wait; private int random; public Ball() { ySpeed = 3; //do not really need constructor call xSpeed = 3; wait = 80; random = Greenfoot.getRandomNumber(3)+1; } /** * Act - do whatever the Ball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { //ballMove(); //bounceOffPaddle(); bouncOffWalls(); if (wait == 0) { ballMove(); } else { wait --; } } // public void ballMove() // { // setLocation(getX() +xSpeed, getY() +ySpeed); // } /** * Move the ball */ public void ballMove() // NEW MOVE METHOD { if (getY() == 0 || getY() == 500-1) { ((PongWorld)getWorld()).updateScore(this); setLocation( 350, 250 ); } else { //setLocation (getX(Greenfoot.getRandomNumber(3)+1), getY(Greenfoot.getRandomNumber(3)+1)); //Greenfoot.getRandomNumber(random)<2); RandomMove(); setLocation(getX()+xSpeed,getY()+ySpeed); //movement bounceOffPaddle(); // new call for bounceOffPaddle } } public void RandomMove() { if (Greenfoot.getRandomNumber(random)<2); { setRotation(Greenfoot.getRandomNumber(360)); } } public void bounceOffPaddle() { Paddle paddle = (Paddle) (getOneObjectAtOffset(0, 0, Paddle.class)); // tells ball paddle is here if (paddle != null) { ySpeed = ySpeed * (-1); } } public void bouncOffWalls() { if(getX() == 0 || getX() == 700-1) // use of logic or to condense two if statements { xSpeed = xSpeed * (-1); } // else ...........WHY NOT USE AN ELSE???? // { // xSpeed = xSpeed * (-1); // } } // public void bouncOffWalls() CAN BE CONDENSED A SINGLE IF STATEMENT...... HOW THOUGH?????? // { // if(getX() == 0) // { // xSpeed = xSpeed +1; // } // if (getX() == 700-1) // { // xSpeed = xSpeed * (-1); // } // } }
I am having trouble
By Clueless, with 10 replies.
Last reply by darkmist255, almost 14 years ago:
@clueless If you're still unsure I would say download the jdk-7u3-windows-i586.exe, since even if you have 64-bit system it will still run. @Builderboy2005 I'm same as Duta, I definitely think that if he's interested he should take a shot at coding! I wish him the best of luck with it, I'm just skeptical :D. Once again, if he is able to get started, I hope that he will make really good progress and will learn to be a great coder! PS: My motivational skills suck, so anything I say will probably be demotivating in some way :D.
HTML (not to do with Greenfoot)
By Duta, with 2 replies.
Last reply by Duta, almost 14 years ago:
Incase anyone's interested, I got it working with the following code: <html> <title>HTML Page 1</title> <script type = "text/javascript"> <!-- function popup() { newwindow2=window.open('','name','height=200,width=150'); var title = document.forms.value; var text = document.forms.value; var tmp = newwindow2.document; tmp.write('<html><head><title>' + title + '</title>'); tmp.write('<link rel="stylesheet" href="js.css">'); tmp.write('</head><body><p>' + text + '</p>'); tmp.write('<p><a href="javascript:self.close()">Close</a> this popup.</p>'); tm
1006
1007
1008
1009
1010
1011
1012
X