Fixed buttons changing color
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package control.button;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.util.ArrayList;
|
||||
@@ -22,12 +23,17 @@ public class ButtonHandler implements KeyListener{
|
||||
buttons = new ArrayList<Button>();
|
||||
|
||||
buttons.add(new Button(0, -1, led));
|
||||
buttons.add(new Button(1, 5, led)); //TODO change to real ID's;
|
||||
buttons.add(new Button(1, 5, led));
|
||||
buttons.add(new Button(2, 4, led));
|
||||
buttons.add(new Button(3, 3, led));
|
||||
buttons.add(new Button(4, 2, led));
|
||||
buttons.add(new Button(5, 1, led));
|
||||
buttons.add(new Button(6, 0, led));
|
||||
|
||||
for(Button b : buttons)
|
||||
{
|
||||
b.setColor(new Color((int)(Math.random()*254+1),(int)(Math.random()*254+1),(int)(Math.random()*254+1)));
|
||||
}
|
||||
}
|
||||
|
||||
public void addButtonListener(ButtonListener toAdd) {
|
||||
|
||||
+8
-1
@@ -3,7 +3,14 @@ package main;
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Window();
|
||||
if(args.length != 1)
|
||||
{
|
||||
new Window(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
new Window(Boolean.getBoolean(args[0].toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,14 +14,16 @@ import control.joystick.JoystickHandler;
|
||||
|
||||
public class Window extends JFrame {
|
||||
|
||||
public static boolean ON_RASP = false;
|
||||
public static boolean ON_RASP;
|
||||
|
||||
public Window()
|
||||
public Window(boolean ON_RASP)
|
||||
{
|
||||
//Create window
|
||||
super("Arcade");
|
||||
setSize(1280, 1024);
|
||||
|
||||
this.ON_RASP = ON_RASP;
|
||||
|
||||
//Set window close listener
|
||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||
addWindowListener(new WindowAdapter(){
|
||||
|
||||
@@ -1,32 +1,14 @@
|
||||
package model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.Timer;
|
||||
|
||||
import view.GameView;
|
||||
import control.button.Button;
|
||||
import control.button.ButtonHandler;
|
||||
|
||||
public class GameModel implements ActionListener{
|
||||
public class GameModel{
|
||||
|
||||
GameView view;
|
||||
Timer t;
|
||||
|
||||
public GameModel(GameView view)
|
||||
{
|
||||
this.view = view;
|
||||
t = new Timer(2000, this);
|
||||
t.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
for(Button b : ButtonHandler.getButtons())
|
||||
{
|
||||
b.setColor(new Color((int)(Math.random()*254+1), (int)(Math.random()*254+1), (int)(Math.random()*254+1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user