Compare commits
No commits in common. "505b58e8e8939b2b9a075393553940439f8eb389" and "c5e0dec777a1c98ed4abd1d0b2f80a5ec25da60f" have entirely different histories.
505b58e8e8
...
c5e0dec777
@ -1,21 +0,0 @@
|
|||||||
import java.awt.*;
|
|
||||||
|
|
||||||
public class GameLogic {
|
|
||||||
|
|
||||||
private final int width;
|
|
||||||
private final int height;
|
|
||||||
|
|
||||||
private int[][] pitch;
|
|
||||||
|
|
||||||
public GameLogic(int width, int height){
|
|
||||||
this.width = width;
|
|
||||||
this.height = height;
|
|
||||||
pitch = new int[width][height];
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean checkPlayer(Point point, int id){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,89 +1,53 @@
|
|||||||
import processing.core.PApplet;
|
|
||||||
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class GameLoop {
|
public class GameLoop {
|
||||||
int activePlayer = 0;
|
int activePlayer = 0;
|
||||||
|
|
||||||
Tracker tracker;
|
|
||||||
|
|
||||||
GraphicsProgram graphics;
|
|
||||||
|
|
||||||
GameLogic gl;
|
|
||||||
|
|
||||||
Player player1;
|
Player player1;
|
||||||
Player player2;
|
Player player2;
|
||||||
|
|
||||||
|
boolean wasSmthTracked = false;
|
||||||
|
|
||||||
public GameLoop(){
|
public GameLoop(){
|
||||||
player1 = new Player(0, "ip", 9000);
|
player1 = new Player(0, "ip", 9000);
|
||||||
player2 = new Player(1, "ip", 9000);
|
player2 = new Player(1, "ip", 9000);
|
||||||
tracker = new Tracker();
|
|
||||||
graphics = new GraphicsProgram();
|
|
||||||
String[] args = {"GraphicsProgram"};
|
|
||||||
PApplet.runSketch(args, graphics);
|
|
||||||
gl = new GameLogic(1080,720);
|
|
||||||
run();
|
run();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(){
|
private void run(){
|
||||||
while(true){
|
while(true){
|
||||||
communicate();
|
communicate();
|
||||||
List<Point> positions = track();
|
if(!wasSmthTracked) {
|
||||||
if(checkP1(positions.get(0))){
|
track();
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if(checkP2(positions.get(1))){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
addPositions(positions);
|
|
||||||
draw();
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void communicate() {
|
private void communicate() {
|
||||||
//offen für Auto Kommunikation
|
if(wasSmthTracked){
|
||||||
}
|
//Beide sollen ausgehen
|
||||||
|
player1.sendToCar(0, 0.0, 0.0);
|
||||||
private boolean checkP1(Point point){
|
player2.sendToCar(0, 0.0, 0.0);
|
||||||
if(gl.checkPlayer(point, 0)){
|
activePlayer++;
|
||||||
return true;
|
} else {
|
||||||
|
//Schicke die Nachrichten fürs angehen
|
||||||
|
activePlayer = activePlayer%2;
|
||||||
|
if (activePlayer == 0){
|
||||||
|
player1.sendToCar(1, 0.0, 0.0);
|
||||||
|
player2.sendToCar(0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
player1.sendToCar(0, 0.0, 0.0);
|
||||||
|
player2.sendToCar(1, 0.0, 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkP2(Point point){
|
private void track(){
|
||||||
if(gl.checkPlayer(point, 0)){
|
//suche Lampe
|
||||||
return true;
|
//Wenn geklappt, setze wasSmthTracked auf true
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addPositions(List positions){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Point> track(){
|
|
||||||
Point p1 = tracker.getP1();
|
|
||||||
Point p2 = tracker.getP2();
|
|
||||||
|
|
||||||
player1.setKoords(p1.x, p1.y);
|
|
||||||
player2.setKoords(p2.x, p2.y);
|
|
||||||
|
|
||||||
List<Point> output = new ArrayList<>();
|
|
||||||
output.set(0, p1);
|
|
||||||
output.add(p2);
|
|
||||||
return output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void draw(){
|
private void draw(){
|
||||||
graphics.drawTrail(player1.getTrail(), 0);
|
//Schicke für active Player letzte Koordinaten
|
||||||
graphics.drawTrail(player2.getTrail(), 1);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ public class GraphicsProgram extends PApplet {
|
|||||||
imgRed = loadImage("TrailRed");
|
imgRed = loadImage("TrailRed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void drawTrail(Queue<int[]> trail, int playerID){
|
public void drawTrail(Queue<int[]> trail, int playerID){
|
||||||
|
|
||||||
int particleSize = 5;
|
int particleSize = 5;
|
||||||
@ -31,9 +30,9 @@ public class GraphicsProgram extends PApplet {
|
|||||||
int x = koordinates[0];
|
int x = koordinates[0];
|
||||||
int y = koordinates[1];
|
int y = koordinates[1];
|
||||||
|
|
||||||
if(playerID == 0){
|
if(playerID == 1){
|
||||||
image(imgBlue, x, y, particleSize, particleSize);
|
image(imgBlue, x, y, particleSize, particleSize);
|
||||||
} else if (playerID == 1) {
|
} else if (playerID == 2) {
|
||||||
image(imgRed, x, y, particleSize, particleSize);
|
image(imgRed, x, y, particleSize, particleSize);
|
||||||
}else{
|
}else{
|
||||||
fill(0, 255, 0);
|
fill(0, 255, 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user