danpost wrote...
I thought it might work. My last suggestion about Paint was not good. Paint does not have a resizing feature. Photoshop may, however. What did you use?
if (Greenfoot.mouseClicked(this)) {
Player.a=1;
Move_Counter.moves=Move_Counter.moves+1;
Game world = (Game)getWorld();
Move_Sideways horizontalRangeBox = world.horizontalRangeBox;
Move_Sideways verticalRangeBox = world.verticalRangeBox;
System.out.println("\nHorizontal range given: '"+horizontalRangeBox.getValue()+"'\nVertical range given: '"+verticalRangeBox.getValue()+"'");
// x and y and the value to change position of player.
Player.x=horizontalRangeBox.getValue();
Player.y=verticalRangeBox.getValue();
} for(a=a;a<=2;a++){
setLocation (getX()+25*x,getY()+25*y);
}private int visited;
if (visited >= 0 && isTouching(Player.class)) visited = -(++visited); if (visited < 0 && ! isTouching(Player.class)) visited = -visited; if (visited == 3) getWorld().removeObject(this);
private int visited;
if (visited >= 0 && isTouching(Player.class)) visited = -(++visited); if (visited < 0 && ! isTouching(Player.class)) visited = -visited; if (visited == 3) getWorld().removeObject(this);
Money_Counter.money= Money_Counter.money+10;
Integer.parseInt(horizontalRangeBox);
Integer.parseInt(verticalRangeBox);
Player.x=horizontalRangeBox.getValue();
Player.y=verticalRangeBox.getValue(); Integer.parseInt(horizontalRangeBox.getValue);
Integer.parseInt(verticalRangeBox.getValue); Integer.parseInt(horizontalRangeBox);
Integer.parseInt(verticalRangeBox);
Player.x=horizontalRangeBox.getValue();
Player.y=verticalRangeBox.getValue();String horizontalText = horizontalRangeBox.getValue(); Player.x = Integer.parseInt(horizontalText); // or just Player.x = Integer.parseInt(horizontalRangeBox.getValue());
import greenfoot.*;
/**
* Write a description of class Run_Button here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Run_Button extends Actor
{
/**
* Act - do whatever the Run_Button wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
if (Greenfoot.mouseClicked(this)) {
Player.a=1;
Move_Counter.moves=Move_Counter.moves+1;
Game world = (Game)getWorld();
Move_Sideways horizontalRangeBox = world.horizontalRangeBox;
Move_Sideways verticalRangeBox = world.verticalRangeBox;
System.out.println("\nHorizontal range given: '"+horizontalRangeBox.getValue()+"'\nVertical range given: '"+verticalRangeBox.getValue()+"'");
// x and y and the value to change position of player.
String horizontalText = horizontalRangeBox.getValue();
Player.x = Integer.parseInt(horizontalText);
String verticalText = verticalRangeBox.getValue();
Player.y = Integer.parseInt(verticalText);
}
}
}
stringValue.trim();
if (! "".equals(stringValue))
if (" +-123456789".indexOf(stringValue.charAt(0)) >= 0) for (char c : stringValue.substring(1))
{
if ("0123456789".indexOf(c) >= 0)...int horizontalValue = 0;
String horiz = ((Game).getWorld()).horizontalRangeBox.getValue().trim();
if (!"".equals(horiz) && " +-123456789".indexOf(horiz.charAt(0)) >= 0 && remainingCharsOkay(horiz)) horizontalValue = Integer.parseInt(horiz);
// with the following method
private boolean remainingCharsOkay(String value)
{
for (char c : value.substring(1)) if ("0123456789".indexOf(c) < 0) return false;
return true;
}if (visited >= 0 && isTouching(Player.class)) visited = -(++visited);
import greenfoot.*;
import java.awt.Color;
public class Move_Sideways extends Actor
{
private static final int MAX_INPUT_WIDTH = 20;
private static Move_Sideways focusOn;
private String text;
public Move_Sideways()
{
text = "";
updateImage();
}
private void updateImage()
{
GreenfootImage image = new GreenfootImage(5*MAX_INPUT_WIDTH, 30);
image.setColor(new Color(128, 0, 0));
image.fill();
image.setColor(Color.lightGray);
image.fillRect(3, 3, image.getWidth()-6, 24);
GreenfootImage textImage = new GreenfootImage(text, 24, null, null);
image.drawImage(textImage, (image.getWidth()-textImage.getWidth())/2, 15-textImage.getHeight()/2);
setImage(image);
}
public void act()
{
if (Greenfoot.mouseClicked(this))
{
while(Greenfoot.getKey() != null);
focusOn = this;
}
if (focusOn == this)
{
if (Greenfoot.mouseClicked(null) && !Greenfoot.mouseClicked(this))
{
focusOn = null;
return;
}
String key = Greenfoot.getKey();
if (key == null) return;
if ("enter".equals(key) && text.length() > 0) return;
if ("backspace".equals(key) && text.length() > 0) text = text.substring(0, text.length() - 1);
if ("escape".equals(key)) text = "";
if ("space".equals(key)) key = " ";
if (key.length() == 1 && text.length() < MAX_INPUT_WIDTH) text += key;
updateImage();
}
}
public String getValue()
{
return text;
}
}if (visited >= 0 && isTouching(Player.class)) visited = -(++visited);{
Money_Counter.money=Money_Counter.money+10;
}