Show joystick direction on screen
This commit is contained in:
+17
-3
@@ -9,19 +9,23 @@ import java.awt.event.ActionListener;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
import main.Window;
|
||||||
import control.LedHandler;
|
import control.LedHandler;
|
||||||
|
|
||||||
public class GameView extends JPanel implements ActionListener{
|
public class GameView extends JPanel implements ActionListener{
|
||||||
|
|
||||||
Timer t;
|
Timer t;
|
||||||
Color c;
|
Color c;
|
||||||
|
String str;
|
||||||
LedHandler led;
|
LedHandler led;
|
||||||
|
|
||||||
public GameView(LedHandler led)
|
public GameView(LedHandler led)
|
||||||
{
|
{
|
||||||
this.led=led;
|
this.led=led;
|
||||||
t = new Timer(1000/30, this);
|
t = new Timer(1000/30, this);
|
||||||
t.start();
|
t.start();
|
||||||
c = new Color(100,100,100);
|
c = new Color(100,100,100);
|
||||||
|
str = "CENTER";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
@@ -36,14 +40,24 @@ public class GameView extends JPanel implements ActionListener{
|
|||||||
|
|
||||||
g2d.setPaint(c);
|
g2d.setPaint(c);
|
||||||
g2d.fillRect(0, 0, getWidth(), getHeight());
|
g2d.fillRect(0, 0, getWidth(), getHeight());
|
||||||
|
|
||||||
|
g2d.setPaint(Color.WHITE);
|
||||||
|
g2d.drawString(str, 100, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color c)
|
public void setColor(Color c)
|
||||||
{
|
{
|
||||||
this.c = c;
|
this.c = c;
|
||||||
for(int i =6; i < 55; i++){
|
if(Window.ON_RASP)
|
||||||
led.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
{
|
||||||
|
for(int i =6; i < 55; i++){
|
||||||
|
led.setLed(i, c.getRed(), c.getGreen(), c.getBlue());
|
||||||
|
}
|
||||||
|
led.show();
|
||||||
}
|
}
|
||||||
led.show();
|
}
|
||||||
|
|
||||||
|
public void setString(String str) {
|
||||||
|
this.str = str;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user