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

Report as inappropriate.

danpost
danpost presents ...

2013/1/19

MapWorld SuperClass

A tool and a support class, all-in-one. It helps to create and map out multiple 'levels', and used as a super-class to run the levels (change maps).

Download the source and open the MapWorld class documentation to begin.

On site, clicking on the world will create a new world using the next map.

For the maze game, use arrow keys to guide mouse to cheese while avoiding the elephants.

4994 views / 18 in the last 7 days

8 votes | 0 in the last 7 days

Tags: simulation demo with-source levels danpost support superclass gridworld mapping

This scenario is a member of: Support Classes by danpost


open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Wed Jan 30 16:12:29 UTC 2013 Publishing source (forgot to include on last update).
danpostdanpost

2013/1/30

@Super_Hippo, yeah, I forgot last time. It is now published.
Super_HippoSuper_Hippo

2013/1/30

Thank you but I can't solve my problem with the scaling because the actor's look bad when they are scaled different. I did not notice it here because they are small enough :) Need to find another way and I will probably, like always, pick the most time consuming one.
danpostdanpost

2013/1/30

@Super_Hippo, if your images are stretching or having slices taken out of them, it is probably because you are re-scaling your images. Always start with an unscaled image and scale it immediately to the size you need. Let us say the image for one of your actors is in a file called "player.png". [code]// save a copy of original image in an instance object field private GreenfootImage image; // in the constructor of that object image = new GreenfootImage(getImage()); // when changing the scale of the image public void scaleImage(double zoom) { GreenfootImage img = new GreenfootImage(image); img.scale((int)(zoom*img.getWidth()), (int)(zoom*img.getHeight())); setImage(img); }[/code]If scaling the image once when the object is being created, just move the code from the scaleImage method to the constructor, supplying the absolute zoom value needed.
Super_HippoSuper_Hippo

2013/1/30

I have exactly this elephant in my game, but it looks bad when it is bigger. Oh and by the way, looks like I did not make that clear, sorry! "I can't solve my problem with the scaling" did not mean that I have a problem with the scaling. It actually meant that I have a problem and wanted to solve it with scaling the images of the actor to a square. But as I said, that did not look well. Then I saw the method drawImage(), so the next idea was, I give the actors an empty image (a square) and draw the other image above that. But that just did not work... Why do I want that square? With a square it would be easier to let the actor know if there is a wall or something right next to it. I have moving AI too, but i decided that one cell has 51 * 51 pixels and not just one. And it looks like that the method getOneObjectAtOffset(dx,dy,class) does not try to find the class from the middle of the picture + dx/dy, because if it would, every class should work with the same values, but they do not. But I think I am fine, I always have some problems that I can not solve. Then I try to find another way to do exactly the same with often 20 times as much source code. As long as it works then, it is good.
danpostdanpost

2013/1/30

@Super_Hippo, When setting an image for the class (by right clicking on the class in the class tree at the right of the scenario window and selecting 'Set image...', click on the image at the left and then at the bottom of the selection window click on the tool icon (gear), then select 'Create new image...' and select the size.
danpostdanpost

2013/1/30

@Super_Hippo, NVM my last post, it does not do what I thought it would.
danpostdanpost

2013/1/30

@Super_Hippo, I am moving this 'discussion' to a new Discussion thread and calling it 'On scaling problem'. Please refer to it.
A new version of this scenario was uploaded on Mon Jul 28 16:23:09 UTC 2014
A new version of this scenario was uploaded on 2017-10-17 13:06:51 UTC

See all comments

Want to leave a comment? You must first log in.

Who likes this?

data17 kristal birdy ronzhi askgriff davemib123 actinium moobe