d2jsp
Log InRegister
d2jsp Forums > Other Games > FPS & Battle Royale > Halo Series > Brandon / Cameron > Greenfoot?
Add Reply New Topic New Poll
Member
Posts: 18,513
Joined: Dec 17 2005
Gold: 53.50
Jan 26 2011 05:53pm
Do either of you know how to use Greenfoot?
Member
Posts: 7,778
Joined: Feb 11 2008
Gold: 77.77
Jan 26 2011 06:19pm
Never used it before, but I just read over the intro at their site and it looks like a pretty basic learning tool for object-oriented programming. Got a specific question?
Member
Posts: 18,513
Joined: Dec 17 2005
Gold: 53.50
Jan 26 2011 06:22pm
Quote (LoadstoneKnight @ Jan 27 2011 12:19am)
Never used it before, but I just read over the intro at their site and it looks like a pretty basic learning tool for object-oriented programming. Got a specific question?


Quote (LoadstoneKnight @ Jan 27 2011 12:19am)
Never used it before, but I just read over the intro at their site and it looks like a pretty basic learning tool for object-oriented programming. Got a specific question?


Yes, you remember that old asteroid game where you control a ship and with that ship you just blow up asteroids to keep yourself alive.

Well, as of now, I need to generate 2 rockets and 3 asteroids at random places. I don't know how to generate them at random locations and I'm trying to attempt to use what I learned from Wombats and Leaves, but it isn't working.
Member
Posts: 7,778
Joined: Feb 11 2008
Gold: 77.77
Jan 26 2011 06:26pm
Quote (RecenT @ Jan 26 2011 06:22pm)
Yes, you remember that old asteroid game where you control a ship and with that ship you just blow up asteroids to keep yourself alive.

Well, as of now, I need to generate 2 rockets and 3 asteroids at random places. I don't know how to generate them at random locations and I'm trying to attempt to use what I learned from Wombats and Leaves, but it isn't working.


I haven't used it and I'm not sure what API is given, but if you go into the constructors for your Rocket and Asteroid classes there may be an overridden constructor that takes start location as a parameter (probably as a (x,y) pair). If so, call that with a randomization function with the parameters being the width and height of the grid. If not, you may have to write that new constructor yourself, depends on how much they give you to start.
Member
Posts: 18,513
Joined: Dec 17 2005
Gold: 53.50
Jan 26 2011 06:33pm
public class Space extends World
{
public Space()
{
super(600, 400, 1);
GreenfootImage background = getBackground();
background.setColor(Color.BLACK);
background.fill();
createStars(300);
Explosion.initialiseImages();
}

private void createStars(int number)
{
GreenfootImage background = getBackground();
for(int i=0; i < number; i++) {
int x = Greenfoot.getRandomNumber( getWidth() );
int y = Greenfoot.getRandomNumber( getHeight() );
int color = 150 - Greenfoot.getRandomNumber(120);
background.setColorAt(x,y,new Color(color,color,color));
}
}
}

I was only given this for the world.
When I randomized the places that Wombats would spawn, I was told to do it within the world--Wombat World.

In this case, it would be the Space world since the background given to me is space and stars were created as I can see.
I attempted to use the same format and such for Asteroids and Rockets but failed.
Member
Posts: 18,513
Joined: Dec 17 2005
Gold: 53.50
Jan 26 2011 07:40pm
I got it. :)
Member
Posts: 9,430
Joined: Nov 21 2007
Gold: 4.84
Jan 27 2011 08:44am
Never used Greenfoot, but it looks pretty cool/simple. The interface and concept remind me, in a way, of Labview.
Member
Posts: 4,167
Joined: Feb 3 2006
Gold: 43.00
Jan 27 2011 12:53pm
It looks just like "stagecast" that thing was the shit when i didnt know how to code in an actual language.
Go Back To Halo Series Topic List
Add Reply New Topic New Poll