I'm trying to create an "if statement" saying:
"If the world's super values are increased (dimensions and cell size increased), then run this code"
How would I do this exactly?
import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot)
/**
* A piano that can be played with the computer keyboard.
*
* @author:
* @version: 0.1
*/
public class Piano extends World
{
int change = 0;
/**
* Make the piano.
*/
public Piano()
{
super(815, 340, 1);
// Keys on the home row act as the notes of the white keys on the piano
whiteKeyPlacement("a","2c.wav");
whiteKeyPlacement("s", "2d.wav");
whiteKeyPlacement("d", "2e.wav");
whiteKeyPlacement("f", "2f.wav");
whiteKeyPlacement("g", "2g.wav");
whiteKeyPlacement("h", "2a.wav");
whiteKeyPlacement("j", "2b.wav");
whiteKeyPlacement("k", "3c.wav");
whiteKeyPlacement("l", "3d.wav");
whiteKeyPlacement(";", "3e.wav");
whiteKeyPlacement("'", "3f.wav");
whiteKeyPlacement("enter", "3g.wav");
// Keys above the home row act as the notes of the black keys on the piano
blackKeyPlacement("w", "2c#.wav", -700);
blackKeyPlacement("e", "2d#.wav", -700);
blackKeyPlacement("t", "2f#.wav", -700 + 65);
blackKeyPlacement("y", "2g#.wav", -700 + 65);
blackKeyPlacement("u", "2a#.wav", -700 + 65);
blackKeyPlacement("o", "3c#.wav", -700 + 65*2);
blackKeyPlacement("p", "3d#.wav", -700 + 65*2);
blackKeyPlacement("]", "3f#.wav", -700 + 65*3);
}
// Adds a white key image requiring some values in order for the method to be called
public void whiteKeyPlacement(String note, String file)
{
whiteKey key = new whiteKey(note,file);
addObject(key, 50 + change, getHeight()/3);
change = change + 65;
}
// Adds a black key image requiring some values in order for the method to be called
public void blackKeyPlacement(String note, String file, int width)
{
blackKey key = new blackKey(note,file);
addObject(key, width + change, getHeight()/4);
change = change + 65;
}
public void keyPlacer()
{
}
}