This site requires JavaScript, please enable it in your browser!
Greenfoot back
crxs
crxs wrote ...

2017/4/18

Polygon World

crxs crxs

2017/4/18

#
Hi, guys. My question... How make a world not rectangular... I need create a world in format of irregular polygon, as a cross or airplane... I habe been worlds as rectangule, but, isn't what i want. Can you help me?
crxs crxs

2017/4/18

#
Nobody???
danpost danpost

2017/4/18

#
crxs wrote...
How make a world not rectangular... I need create a world in format of irregular polygon, as a cross or airplane... I habe been worlds as rectangule, but, isn't what i want.
I have a support superclass for a hexagonal world located here. Maybe you can review it to come up with something. Although, you did say 'irregular', which I have a feeling you did not really mean -- that is, I think you meant more like 'triangular', 'hexagonal' or something else that is a regular polygon (just not rectangular). I would think that a triangular world would not be much different than a rectangular one as the layout of cells is similar -- it is just the shape of the cells that would be different.
crxs crxs

2017/4/19

#
Well, in fact the background of my world will be a rectangle, but I need to limit the displacement of the characters to a polyhedral figure, that is, parts (neighborhoods) of a city, understood? Maybe I should do this limitation using a collision ... but then another problem arises ... how to make invisible the objects with which the characters will collide, and not exceed ... these objects will correspond to the perimeter of the neighborhood / bordering area of the game . Should I treat them in an image editing program and then insert them into the game? Or is there a method in the greenfoot that makes them invisible?
danpost danpost

2017/4/19

#
As invisible colliders, you can work it either way -- keeping the character on them or prevent the character from passing over them. I would think that keeping the character on them would be easier to manage. You only need set the transparency of the image of the actor to zero. A simple Path constructor might be as follows:
public Path(int wide, int high, int rotation)
{
    getImage().clear();
    getImage().scale(wide, high);
    setRotation(rotation);
}
Line 3 not only sets the transparency of all pixels to zero, but sets all color values to black; however, as a transparent image, the color is unimportant.
crxs crxs

2017/4/21

#
I understood ... I'll test. Thank you for now
You need to login to post a reply.