-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReloadButton.java
41 lines (40 loc) · 1.14 KB
/
ReloadButton.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class ReloadButton here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class ReloadButton extends Robot
{
boolean Press1 = false;
boolean Press2 = false;
/**
* Act - do whatever the ReloadButton 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)){
reload();
getWorld().removeObject(getWorld().getObjects(FlippyBoi.class).get(0));
getWorld().addObject(new FlippyBoi(),500,50);
}
if(Greenfoot.isKeyDown("1")){
if(!Press1){
Press1 = true;
reload(Blocks.TAN);
}
}else{
Press1 = false;
}
if(Greenfoot.isKeyDown("2")){
if(!Press2){
Press2 = true;
reload(Blocks.GREY);
}
}else{
Press2 = false;
}
}
}