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
Timer/Clock for a game
By ortizme93, with 8 replies.
Last reply by danpost, almost 11 years ago:
I found a couple of mistakes in my previous post. (1) line 4 for the button example should be: <Code Omitted>(2) at the end, I had referred to the first 7 lines of the button class -- well that would more correctly be 7 of the first 8 lines (all but line 7).
Help with assign a specific name
By SilentPenguin, with 3 replies.
Last reply by danpost, almost 11 years ago:
First off, you would not use the type when referring to a variable that is already declared. So this: <Code Omitted>would not have 'String' in it and you would need round brackets around the condition. So it would be this: <Code Omitted>However, there is no 'isalnum' method in the String class (or any method to check the general type of data stored within the string). All strings could be considered as being alpha-numeric strings; so the question itself is almost not worth asking. What might be important is wheth
How to make an actor move relative to the result of a dice
By SilentPenguin, with 3 replies.
Last reply by danpost, almost 11 years ago:
Line 15 in the roll method above will set the 'randNumber' variable to a number between 1 and 4 and line 17 sends that same value back to the calling statement (which is the last line of actual code within that post -- line 8 of the world class code, where it is saved in a variable called 'rollValue'). At that point you can use 'move(rollValue)' on the player to move. But you will need an array for the players in the game and an int field to track which one has the turn. For example:
Please Help Me. I don't really know what to do. -_-
By Anne2403, with 8 replies.
Last reply by Anne2403, almost 11 years ago:
@davmac hehe. I'm sorry about it. and thank you I will do what you said. I will take your advice. Sorry for the disturbance and also with @danpost aand @Erdrag1. Thank you and sorry again brothers.
Need help with Color detection and Offsets.
By Zwadouggie, with 3 replies.
Last reply by danpost, almost 11 years ago:
Zwadouggie wrote...
How does the declaring list work if you mind showing me an example.
It would be much easier to have the barriers set their own transparency dependent on a static field in your World subclass. If you would prefer to use a list to set the transparencies of all walls of a specific color, it would be a two part process. The steps would include: * get and iterate through a list of all Wall objects in the world while iterating through the list * if wall is color and wall transparency is zero, set wall transparency to 255 * if wall is not color and wall transparency i
Actor interacts with the edge of the world
By jnlrsl, with 2 replies.
Last reply by danpost, almost 11 years ago:
Change what you said to present tense, at the exact instant in time that is in question. That is, instead of saying, "When my character reaches the right edge, I want to switch worlds!" -- say "If my character is at the right edge, switch worlds (to whatever world).". Or, more specifically, "If the x-location of my character is equal to the right-most x-coordinate in the world, set the active world to a new world." This reads almost the way you would write the code.
Actor stops halfway at the edge of the world
By akshay1188, with 3 replies.
Last reply by akshay1188, almost 11 years ago:
Beautiful! Thank you Jonas. Dan, I will make sure to keep a check on all my actors that go off the edge of the world. Thank you so much.
Randomly drop crate code isn't working?
By Fuzzion, with 4 replies.
Last reply by danpost, almost 11 years ago:
It appears there are a couple of things that were not made clear by JimStewart in the comments. First, nowhere does he suggest that you add the MoveRandomly object into the world (however, later in the class he does say to uncomment some code to actual see the actor). The class indeed does extends Actor; however, in truth, it really is not an actor in itself and should probably not extend Actor. The other thing is that it is not stated that the MoveRandomly object that your actor creates should be held in an instance field. This is made evident, however, in the section where the method 'mo
Actor inside actor?
By akshay1188, with 2 replies.
Last reply by akshay1188, almost 11 years ago:
Thank you!
List add object exception?
By Dalvengyr, with 5 replies.
Last reply by Dalvengyr, almost 11 years ago:
Thanks guys for your help, it works correctly now :)
how to move in the facing direction
By nmichael221, with 3 replies.
Last reply by danpost, almost 11 years ago:
nmichael221 wrote...
yes, he turns left and he faces left. But after I stop pressing the left key he is facing left and moving right.
That did not answer my question. Nowhere was there an option to answer that he 'turns'. I ask whether the rotation of the actor changes or does the image of the actor change when it changes the direction it faces. Also, you should post the code you currently have for the actor. Use the 'code' link below the reply box to insert code into you posts.
Do i understand it right?
By Erdrag1, with 7 replies.
Last reply by danpost, almost 11 years ago:
I thought you wanted to add lettuce if no lettuce as left in the world. However, if you only have one lettuce in the world then at the time it is eaten, there will be none. So, either way, still. That is, in the "extends Actor", you can either call the method to add lettuce in the 'ifcansee' method OR you can still use separate from the 'ifcansee' method 'if (getWorld().getObjects(Lettuce.class).isEmpty())' to qualify when to call the 'createNewLettuce' method.
Kinect Greenfoot Integration
By judemartin, with 5 replies.
Last reply by davmac, almost 11 years ago:
Danpost: I didn't write those instructions but I believe step 5 means you should download the Greenfoot kinect examples (the link is provided just below the instructions), as these example scenarios contain classes which communicate with the Greenfoot Kinect server (from step 4). judemartin: I believe you could use the example scenarios as a starting point. There's no real need to write code to communicate with the Kinect server using a socket as you can use the code in the example scenarios which does that for you. It sounds like you have this code and are essentially trying to re-create
SpaceInvaders
By crazyfox1999, with 1 reply.
Replied to by danpost, almost 11 years ago:
Please show the code you have for the actor that is shooting (it is the main actor, correct? -- the one that stays in view at all times). Use the 'code' link below the reply box to insert code into your posts.
Control Interface Bug fix in a city Game please Help!
By Prish950, with 1 reply.
Replied to by danpost, almost 11 years ago:
The code given will only place the building at the point of mouse-click to begin with. You need more code to maintain to building at the location of the moving mouse. Line 10 is a bit of a no-brainer. The act method is never called on 'null' objects The keyword 'this', used in any non-static method, will always refer to an object -- the object the method is being executed for or on. If the object the method was being called on was 'null', a 'NullPointerException would be thrown before the method was ever reached. Lines 12 and 13 call the 'getX' and 'getY' methods on 'Greenfoot.getMou
630
631
632
633
634
635
636
X