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
Forward& Back
By pactz, with no replies.
Can anyone make this actor move automatically forward 60px and back 60px like super mario Heres the code: import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class GoldenBall here. * * @author (your name) * @version (a version number or a date) */ public class Lobster extends Actor { /** * Act - do whatever the GoldenBall wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { checkGoldenBall(); } public boolean canMove(int x, int y) { Actor sand; sand=getOneObjectAtOffset(x,y,sandroad.class); //the section below checks if there is a block you can move to // if there is it sets sand to a vlaue otherwise it says null // The errors are in this section boolean flag=false; if (sand !=null) { flag=true; } return flag; } /** * Check if Lobster eats the ball */ private void checkGoldenBall() { Actor GoldenBall= getOneIntersectingObject(GoldenBall.class); if (GoldenBall !=null ) { getWorld().removeObject(GoldenBall); } } }
HELP
By pactz, with 6 replies.
Last reply by pactz, almost 12 years ago:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Alligator here. * * @author (your name) * @version (a version number or a date) */ public class Alligator extends Actor { /** * Act - do whatever the Alligator wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { moveAround(); eat(); } public void moveAround() { move(60); if (Greenfoot.getRandomNumber
Perfect pixel collision
By xFabi, with 13 replies.
Last reply by danpost, almost 12 years ago:
xFabi wrote...
So back to my edge() method, can you tell me how to solve that problem?
Remove lines 35, 36 and 41 (from your last class posting) and change line 37 from 'if' to 'else if'.
Selecting A Class And Moving It: Can someone help me please
By TheLlama, with 3 replies.
Last reply by danpost, almost 12 years ago:
TheLlama wrote...
Thanks, but how would i keep the tank in the field?
Declare the field outside the method. That is, instead of a variable that is local to a method -- like this: <Code Omitted>You would do this:
adding radom numbers to the screen
By kylecompton31, with 4 replies.
Last reply by xFabi, almost 12 years ago:
x,c wasnt actually meant to be values, i just took them to show, that you have to input numbers there :D Edit: ah thats what you meant nvm, i thought you could also define a minimum
Delay?
By xFabi, with 16 replies.
Last reply by xFabi, almost 12 years ago:
So i got it solved by replacing while,followed by if, by an if and then else if method. Ty for your help
Generating Random Movement
By elementa, with 1 reply.
Replied to by danpost, almost 12 years ago:
What have you tried? or, how do you think this can be accomplished? can you come up with any ideas?
How to create an array list for questions
By elementa, with 7 replies.
Last reply by elementa, almost 12 years ago:
@davmac : Oh, whoops ! Well, I'm not quite sure if this is the correct solution but I simply removed "static" so it becomes just "public void main(string args)" and I was able to compile it without a problem!
Character Selection Game
By joanne_wm, with 52 replies.
Last reply by joanne_wm, almost 12 years ago:
THank you very very very much! NOw my game is complete!!!!
Trying to let a bullet fly in a correct angle
By UNDEAD_DC, with 16 replies.
Last reply by xFabi, almost 12 years ago:
Dan said you only want to set those values once If this is true, you can't put them into the method, because act() gets called forever, and so the values would be set over and over
Multi Touch
By jhadad, with 7 replies.
Last reply by danpost, almost 12 years ago:
Well, TouchEvent and TouchPoint are part of the javaFX library; however, all classes, regardless of library, have the Object class as their root. The EventListener class is part of the java.util library. As far as playing around with them, you will have to experiment on your own. You could look at what classes are used and how they are used with respect to the mouse and try to set it up similarly for your case.
Help with games memory/ performance
By Gish, with no replies.
So I spent a good amount of time on this (it's my first game), and was excited to find that you can run Greenfoot games on Android (with Droidfoot). However, my game does not seem to want to run on mobile devices. I receive heap-space memory errors after a few compilations on my PC, so I'm thinking it must be due to a memory issue in my game. Any pointers to help improve the games performance are greatly appreciated! http://www.greenfoot.org/scenarios/12530
Checking for the speed of an object when it comes in contact with another?
By DiplomatikCow, with 2 replies.
Last reply by xFabi, almost 12 years ago:
http://www.acsu.buffalo.edu/~gauravku/113/Assignments/8/Newtons-Lab-3/doc/SmoothMover.html Gonna get some sleep ._. , wait for Dan to reply if there's still questions Btw, are you hired by greenfoot Dan ^^?
Game over when hit 3 times
By Frost, with 4 replies.
Last reply by danpost, almost 12 years ago:
I do not think you are being consistent with the name of your field. I see 'healthPoint' as the name of the field; but I also see 'damagePoint' being used in the code. I think 'hitCount' might be a more appropriate name since hits are what it is counting.
Making a square hitbox
By Dillybar, with 8 replies.
Last reply by danpost, almost 12 years ago:
If you mean like taking an exaggeratedly large square transparent image and drawing Mario in the middle of it and then setting that image to a Mario object, then yes. All images are rectangular to begin with, regardless of where the actual color portions within that image are, however, and since normal collision detection uses the extent of the image, not the color portions within it, the hitbox is already rectangular. Most people have problems with the image itself being larger than the color portion within it and want the image size to be reduced without reducing the size of the color port
615
616
617
618
619
620
621
X