Results 1 to 3 of 3
Thread: Greenfoot help
- 05-17-2012, 03:28 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 12
- Rep Power
- 0
Greenfoot help
I am wanting to add a new actor in greenfoot at a random location
Java Code:long lastAdded = System.currentTimeMillis(); public void act() { long curTime = System.currentTimeMillis(); if (curTime >= lastAdded + 4000) //5000ms = 5s { MyWorld world; world = (MyWorld) getWorld(); int x = Greenfoot.getRandomNumber(600); //int y = Greenfoot.getRandomNumber(450 world.addObject(new WoundedPerson(), x, 450); lastAdded = curTime; }
- 05-17-2012, 03:34 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 28
Re: Greenfoot help
int y = 800-Greenfoot.getRandomNumber(450);
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
- 05-17-2012, 04:24 PM #3
Senior Member
- Join Date
- Feb 2012
- Posts
- 117
- Rep Power
- 0
Re: Greenfoot help
I need to set a limit on the y axis so that 450 is the highest from the bottom of the world which is 800.
world.addObject(new WoundedPerson(), x, 450);
Similar Threads
-
Scaling an object in Greenfoot
By Tayl0r in forum Java GamingReplies: 0Last Post: 12-03-2010, 11:05 PM -
Using Applets built in GreenFoot?
By sciguy77 in forum New To JavaReplies: 0Last Post: 01-19-2009, 09:43 PM -
Greenfoot exporting in .jar?
By sciguy77 in forum New To JavaReplies: 0Last Post: 01-18-2009, 08:06 PM -
Greenfoot 1.4.1
By JavaBean in forum Java SoftwareReplies: 0Last Post: 03-24-2008, 07:02 PM -
Greenfoot 1.2.1
By Jamie in forum Java SoftwareReplies: 0Last Post: 06-14-2007, 03:54 PM
Bookmarks