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
Flip a card one at a time and guess
By miko122, with 16 replies.
Last reply by rkzkIMP, about 14 years ago:
yanks101// come to the comp area you can (you kno where) i can definately help you with the practice 4.
HELP ASAp
By yanks101, with 1 reply.
Replied to by tylers, about 14 years ago:
what is it
Resetting the User's Info
By SPower, with 1 reply.
Replied to by SPower, about 14 years ago:
Nevermind: I've got it working.
play wav files in loop...
By Busch2207, with 4 replies.
Last reply by SPower, about 14 years ago:
I also thought there might be a bug doing this with the beta, but I thought that my code was wrong. Sorry for not reporting this :(, next time, I'll do.
How to make actor jump animatedly?JUMP not FLY like penguin tutorial.
By snow13, with no replies.
I need the code when the button is pressed the actor jump and then fall,not fly.
dot notation
By USBest, with 11 replies.
Last reply by davmac, about 14 years ago:
Yes. Furthermore, worrying about performance of different source constructs is, in general, pointless. In general you're not going to see a measurable performance difference without completely changing your algorithm.
Using Scanner class.
By Omniscience, with 10 replies.
Last reply by davmac, about 14 years ago:
Ah snap, forgot to reply! Well, the reason why the code wasn't running was to do with the control flow in the end. It was the rogue code button = player.next(). When I removed it, the code worked again and all the problem was solved.
Great that you've got it solved. I don't think the fix was just to remove 'button = player.next()' though, since if you remove that you're no longer reading anything from the scanner (unless you're doing that earlier).
And I realised, fortunately, that you can just add strings together!
My point about this was that you don't
Maze gen using a 2-D array
By RedPhoneBooth, with 13 replies.
Last reply by RedPhoneBooth, about 14 years ago:
Okay, I got this, lol sorry, I was having trouble understanding all your fancy computer talk :D lol jk, thanks a bunch tho
Equations
By thefutureisnow, with 6 replies.
Last reply by danpost, about 14 years ago:
Actually, you can use those commands anytime, without having to specify 'import java.lang.Math;', being it is part of the java.lang package.
Letter game flipping cards
By miko122, with no replies.
Hello I am trying to create a scenario where in the end a bunch of cards are in the world and when it starts one will flip and a user has to guess the first letter and if its right a message will appear and flip another card. If guess wrong the user has to keep guessing. So far this is what i have i am supposed to have 9 cards up. I only have one in the world now im trying to figure out how to flip it first and guess. I am completely lost and if anyone could help it would be much appreciated. thanks LetterGame class public class LetterGame extends World { private Selector selector; private Message message; private String imageNamesFirstRow = {"ambulance.png", "butterfly.png", "elephant.png"}; private String imageNamesSecondRow = {"frog.png", "house-03.png", "kangaroo.png"}; private String imageNamesThirdRow = {"pig.png", "tent.png", "spider.png"}; /** * Constructor for objects of class LetterGame. * */ public LetterGame() { // Create a new world with 500x500 cells with a cell size of 1x1 pixels. super(500, 500, 1); //This line creates the selector object - DO NOT remove or change this line. selector = new Selector(this); //Place your code for the constructor after this comment. addObject( new Message(), 250, 450); message = new Message(); //card = newCard(); for (int i=0;i<3;i++) { addObject( new Card(selector, imageNamesFirstRow
, imageNamesFirstRow
. charAt (0)), 40, 100); } //and before this comment } public void act() { selector.newCard(); } public void showGuessMessage() { message.showGuessImage(); } public void showCorrectMessage() { message.showCorrectAnswerImage(); } /** * Prepare the world for the start of the program. That is: create the initial * objects and add them to the world. */ } Card class public class Card extends Actor { private Selector selector; private GreenfootImage backgroundImage; private boolean faceUp; private GreenfootImage faceImage; private String letter; private String cardImage= {"ambulance","butterfly","elephant","frog","house", "kangaroo","pig","spider","tent"}; public Card(Selector sel, String cardImages, char let) { selector = sel; sel.addCard(this); createInitialImage(); faceImage= new GreenfootImage(cardImages); faceUp=false; letter= ""+ let; //Add your code for the constructor after this comment } /** * Act - do whatever the Card wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { } public void turnOver() { //setImage(faceImage); if (faceUp){ setImage(backgroundImage); faceUp=false; } else{ setImage(faceImage); faceUp= true;} } private void createInitialImage() { backgroundImage = new GreenfootImage(100, 100); backgroundImage.setColor(java.awt.Color.BLUE); backgroundImage.fillRect(0, 0, 100, 100); setImage(backgroundImage); } }
private void in class?
By PStigerID, with 2 replies.
Last reply by davmac, about 14 years ago:
Something wrong with your bracketing, as danpost says. If you indented your code correctly (ctrl+shift+I), you would be able to see this immediately.
How to update a project on greenfoot.org?
By erdelf, with 2 replies.
Last reply by erdelf, about 14 years ago:
Thx
How to detect an object in an Area?
By lgbrf, with 7 replies.
Last reply by danpost, about 14 years ago:
That is because you are using the class name instead of a reference to an object of that class. Add <Code Omitted>Then change all your 'Player.getX()'s to 'player.getX()'. If there is any chance that the Player class object is not in the world, you would have to check for an empty List before getting the first item from it. PLEASE NOTE: If this code is actually in your Player class, DO NOT add or change anything, but DO remove all occurances of 'Player.' from the code.
Attaching an Object
By al_griff, with 1 reply.
Replied to by danpost, about 14 years ago:
See
duplicated discussion thread
.
Attaching an Object
By al_griff, with 1 reply.
Replied to by danpost, about 14 years ago:
Try having the object the one attaches to control the location of the attached object. You may need to have a boolean variable in the attaching object to help reliquish control and a reference in the object attached to for the attaching object. Then, when detaching, you may need another boolean to help in the seperation process (worry about that then, if need be; but, work on the one object controlling the location of the other for now). As far as the getOneIntersectingObject method: you will use that in the object that is attached to; in its act method (or a method that the act method ca
983
984
985
986
987
988
989
X