I have an actor which uses hover function as a form of input. I need a way of determining which actor has the most point in a way that greenfoot will display a text box stating who has won?
I currently have
This is relatively the same for the the other 6 classes with the accepting of the class name. If someone could offer code it would be muchg appreciated (P.s If you could also prepare for a scenario where a draw occurs...id love you for life
public class TAM3Home extends Actor
{ private boolean HasHit = false; // This is making a boolean for "HasHit" to say when the text has been entered.
public void act()
{
MouseInfo mouse = Greenfoot.getMouseInfo(); // This is making a varaible for the mouse pointer (where the mouse is in the program).
World myWorld = getWorld(); // This is suggesting a variable for "World" or "getWorld"
BackGroundBoard space = (BackGroundBoard) getWorld();// This is declaring the world "BackGroundBoard".
FinalScore overall = space.getCounter();
// If the mouse doesn't equal the object specified in this case "this"
if(mouse != null)
{
// This is listing the "getWorld" function and turning it into a shortened varaible
List objects = getWorld().getObjectsAt(mouse.getX(), mouse.getY(), TAM3Home.class);
for(Object object : objects)
{
// This is listing the object function.
if(object == this)
{
// "if(object == this)" is seeing if the object is equal to the object "this".
// This line of code is testing if the Key "0" is being pressed.
if(Greenfoot.isKeyDown("0"))
{
setImage(new GreenfootImage("0", 28, Color.BLACK, Color.WHITE));
// "0" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true; // This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(0); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "1" is being pressed.
if(Greenfoot.isKeyDown("1"))
{
setImage(new GreenfootImage("1", 28, Color.BLACK, Color.WHITE));
// "1" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(1); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "2" is being pressed.
if(Greenfoot.isKeyDown("2"))
{
setImage(new GreenfootImage("2", 28, Color.BLACK, Color.WHITE));
// "2" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(2); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "3" is being pressed.
if(Greenfoot.isKeyDown("3"))
{
setImage(new GreenfootImage("3", 28, Color.BLACK, Color.WHITE));
// "3" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(3); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "4" is being pressed.
if(Greenfoot.isKeyDown("4"))
{
setImage(new GreenfootImage("4", 28, Color.BLACK, Color.WHITE));
// "4" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(4); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "5" is being pressed.
if(Greenfoot.isKeyDown("5"))
{
setImage(new GreenfootImage("5", 28, Color.BLACK, Color.WHITE));
// "5" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(5); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "6" is being pressed.
if(Greenfoot.isKeyDown("6"))
{
setImage(new GreenfootImage("6", 28, Color.BLACK, Color.WHITE));
// "6" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(6); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "7" is being pressed.
if(Greenfoot.isKeyDown("7"))
{
setImage(new GreenfootImage("7", 28, Color.BLACK, Color.WHITE));
// "7" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(7); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "8" is being pressed.
if(Greenfoot.isKeyDown("8"))
{
setImage(new GreenfootImage("8", 28, Color.BLACK, Color.WHITE));
// "8" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(8); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "9" is being pressed.
if(Greenfoot.isKeyDown("9"))
{
setImage(new GreenfootImage("9", 28, Color.BLACK, Color.WHITE));
// "9" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
HasHit = true;// This is changing the "HasHit" boolean from "false" to "true".
overall.SetTeamA3(9); // This code is calling the void in the "OverallScore" class but I've created a varaible for that which is "counter".
}
// This line of code is testing if the Key "backspace" is being pressed.
if(Greenfoot.isKeyDown("backspace"))
{
setImage(new GreenfootImage("???", 28, Color.BLACK, Color.WHITE));
// "???" (this is the text that has been entered), 21 (This is the font size), Color.BLACK (This is the text, Color.WHITE));
// This is showing the text is undecided then showing HasHit is equal to false
HasHit = false;// This is changing the "HasHit" boolean from "true" to "false".
}
}
}
}
}
}

