When I resize my world, I want it so everything within "MyWorld" will shrink as well.
Don't give me a direct answer, just some hints guiding me on what I should do.
Here is my code:
and here is my code for my actor receiving all this information:
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * A Minecraft Landscape built through various amounts of rectangles * * ----- * * (2020 - 02 - 11) */ public class MyWorld extends World { private GreenfootImage myImage; /** * Constructor for objects of class MyWorld. * */ public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(600, 400, 1); myImage = new GreenfootImage(600,400); //--------------------------------------------------------------------------------- /* * BACKGROUND * Creating a blue sky by making a rectangle that occupies the whole canvas */ background(0,0,600,400); //--------------------------------------------------------------------------------- /* * CLOUDS * Creating an outline of each cloud with different values * Colouring each cloud white */ // Colouring each cloud (White) creatingClouds(40,75,100,45); creatingClouds(150,20,125,35); creatingClouds(360,50,115,40); // Outline of each cloud creatingClouds(40,75,100,45); creatingClouds(150,20,125,35); creatingClouds(360,50,115,40); //--------------------------------------------------------------------------------- /* * ZOMBIE * Creating an outline of the zombie * Zombie is made through several rectangles creating a zombie figure * Colouring each rectangle making up the zombie * Some rectangles contain different RGB values */ // Colouring zombie (Dark Green, RGB: 64, 128, 64) colouringMobsRGB(442,210,50,50,64,128,64); colouringMobsRGB(505,270,15,15,64,128,64); colouringMobsRGB(450,335,32,14,64,128,64); colouringMobsRGB(482,270,23,15,64,128,64); // Colouring zombie torso (Faded Light Blue, RGB: 112, 146, 190) colouringMobsRGB(451,261,31,59,112,146,190); colouringMobsRGB(482,270,23,15,112,146,190); // Colouring zombie pants (Dark Blue, RGB: 63, 72, 204) colouringMobsRGB(450,320,32,15,63,72,204); // Colouring zombie eye and mouth (White) colouringMobsGeneric(482,250,10,10, Color.WHITE); colouringMobsGeneric(470,225,15,7, Color.WHITE); // Outline of each zombie body part drawingMobs(442,210,50,50); drawingMobs(450,260,32,60); drawingMobs(482,270,23,15); drawingMobs(505,270,15,15); drawingMobs(442,210,50,50); drawingMobs(450,335,32,14); drawingMobs(470,225,15,7); drawingMobs(482,250,10,10); drawingMobs(450,320,32,15); //--------------------------------------------------------------------------------- /* * CREEPER * Creating an outline of creeper * Creeper is made of several rectangles creating it's figure * Colouring each rectangle making up the creeper */ // Colouring creeper skin (Semi - Dark Green, RGB: 34, 177, 76) colouringMobsRGB(81,201,49,48,34,177,76); colouringMobsRGB(92,251,27,79,34,177,76); colouringMobsRGB(75,331,24,18,34,177,76); colouringMobsRGB(111,331,24,18,34,177,76); // Colouring the creeper's eye and mouth (White) colouringMobsGeneric(111,216,14,7, Color.WHITE); colouringMobsGeneric(119,241,11,9, Color.WHITE); // Outlining each creeper body part drawingMobs(80,200,50,50); drawingMobs(91,250,28,80); drawingMobs(74,330,25,19); drawingMobs(110,330,25,19); drawingMobs(110,215,15,8); drawingMobs(118,240,12,10); //--------------------------------------------------------------------------------- /* * SUN * Creating an outline of the sun * Colouring the rectangle the makes the sun */ // Colouring the sun createSun(500,30,80,80); // Outlining the sun createSun(500,30,80,80); //--------------------------------------------------------------------------------- /* * TREE * Creating an outline of the tree trunk + the leaves of the tree * Tree trunk is made of rectangle while the leaves are made of a polygon * Colouring the rectangle and polygon that make up the tree trunk and leaves */ // Colouring and outlining the rectangle making up the tree trunk createTreeTrunk(280,200,50,149); // Colouring and outlining the polygon making up the leaves of the tree createTree(200,200); //--------------------------------------------------------------------------------- /* * GRASS * Creating an outline of a rectangle making up the grass / ground * Colouring in the rectangle green to make up grass */ // Colouring the rectangle making up the grass createGrass(0,350,600,50); // Outlining the rectangle making up the grass createGrass(0,350,600,50); //--------------------------------------------------------------------------------- /* * TEXT * Writing text * X, Y values determing it's position * Font used is "Garmant" */ // Writing "Hello World" writeText("Hello World!", 255, 385); // Writing "Creeper" writeText("Creeper?", 150, 235); // Writing "Awww mannn" writeText("Awww mannn", 155, 275); //--------------------------------------------------------------------------------- Picture minecraftLandscape = new Picture(myImage); addObject(minecraftLandscape, 300, 200); } public void createGrass(int x, int y, int width, int height) { myImage.setColor(new Color(89,197,121)); myImage.fillRect(x, y, width, height); myImage.setColor(Color.BLACK); myImage.drawRect(x, y, width, height); } public void background(int x, int y, int width, int height) { myImage.setColor(new Color(0,162,232)); myImage.fillRect(x, y, width, height); } public void writeText(String message, int x, int y) { myImage.setColor(Color.YELLOW); Font myFont = new Font("Garmant", true, true, 18); myImage.setFont(myFont); myImage.drawString(message,x ,y); } public void creatingClouds(int x, int y, int width, int height) { myImage.setColor(Color.WHITE); myImage.fillRect(x, y, width, height); myImage.setColor(Color.BLACK); myImage.drawRect(x, y, width, height); } public void drawingMobs(int x, int y, int width, int height) { myImage.setColor(Color.BLACK); myImage.drawRect(x, y, width, height); } public void colouringMobsRGB(int x, int y, int width, int height, int r, int g, int b) { myImage.setColor(new Color(r,g,b)); myImage.fillRect(x, y, width, height); } public void colouringMobsGeneric(int x, int y, int width, int height, Color c) { myImage.setColor(c); myImage.fillRect(x, y, width, height); } public void createSun(int x, int y, int width, int height) { myImage.setColor(Color.YELLOW); myImage.fillRect(x, y, width, height); myImage.setColor(Color.BLACK); myImage.drawRect(x, y, width, height); } public void createTree(int bottomLeftX, int bottomLeftY) { int change = 80; int change1 = 28; int change3 = 5; int change4 = 35; int change5 = 30; int change6 = 50; int[] xValues = {bottomLeftX, bottomLeftX, bottomLeftX + change, bottomLeftX + change, bottomLeftX + change*2 - change1, bottomLeftX + change*2 - change1, bottomLeftX + change*3 - change5, bottomLeftX + change*3 - change5}; int[] yValues = {bottomLeftY, bottomLeftY - change - change3, bottomLeftY - change - change3, bottomLeftY - change - change6, bottomLeftY - change - change6, bottomLeftY - change - change3, bottomLeftY - change - change3, bottomLeftY}; int points = 8; myImage.setColor(new Color(34,177,76)); myImage.fillPolygon(xValues,yValues,points); myImage.setColor(Color.BLACK); myImage.drawPolygon(xValues,yValues,points); } public void createTreeTrunk(int x, int y, int width, int height) { myImage.setColor(new Color(185,122,87)); myImage.fillRect(x, y, width, height); myImage.setColor(Color.BLACK); myImage.drawRect(x, y, width, height); } public void changingSize(int width, int height) { } }
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Picture here. * * @author (your name) * @version (a version number or a date) */ public class Picture extends Actor { public Picture(GreenfootImage myImage) { setImage(myImage);// Add your action code here. } }