Browse Source

Version 20.11

master
David Moeckel 1 month ago
parent
commit
c6f1afc206
4 changed files with 69 additions and 86 deletions
  1. 6
    35
      .idea/workspace.xml
  2. 33
    0
      src/main/java/ArduinoCommunicator.java
  3. 0
    40
      src/main/java/GameLogic.java
  4. 30
    11
      src/main/java/Player.java

+ 6
- 35
.idea/workspace.xml View File

@@ -4,14 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="4d75e996-cee4-4ec6-b802-5b56d0c0eac4" name="Changes" comment="Grundstrukur">
<change afterPath="$PROJECT_DIR$/src/main/java/GameLoop.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/GameLogic.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/GameLogic.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/Player.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Player.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/Tracker.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Tracker.java" afterDir="false" />
</list>
<list default="true" id="4d75e996-cee4-4ec6-b802-5b56d0c0eac4" name="Changes" comment="First Commit Test" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -38,10 +31,6 @@
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Downloaded.Files.Path.Enabled": "false",
"Repository.Attach.Annotations": "false",
"Repository.Attach.JavaDocs": "false",
"Repository.Attach.Sources": "false",
"RunOnceActivity.ShowReadmeOnStart": "true",
"com.codeium.enabled": "true",
"git-widget-placeholder": "master",
@@ -51,9 +40,9 @@
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Libraries",
"project.structure.last.edited": "Project",
"project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.41724136",
"project.structure.side.proportion": "0.0",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
@@ -73,7 +62,7 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1732108904989</updated>
<workItem from="1732108906083" duration="3420000" />
<workItem from="1732108906083" duration="758000" />
</task>
<task id="LOCAL-00001" summary="First Commit Test">
<option name="closed" value="true" />
@@ -83,23 +72,7 @@
<option name="project" value="LOCAL" />
<updated>1732109548353</updated>
</task>
<task id="LOCAL-00002" summary="Second Commit Test">
<option name="closed" value="true" />
<created>1732109721570</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1732109721570</updated>
</task>
<task id="LOCAL-00003" summary="Grundstrukur">
<option name="closed" value="true" />
<created>1732109899753</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1732109899753</updated>
</task>
<option name="localTasksCounter" value="4" />
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -118,8 +91,6 @@
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="First Commit Test" />
<MESSAGE value="Second Commit Test" />
<MESSAGE value="Grundstrukur" />
<option name="LAST_COMMIT_MESSAGE" value="Grundstrukur" />
<option name="LAST_COMMIT_MESSAGE" value="First Commit Test" />
</component>
</project>

+ 33
- 0
src/main/java/ArduinoCommunicator.java View File

@@ -1,2 +1,35 @@
import com.illposed.osc.OSCMessage;
import com.illposed.osc.transport.OSCPortOut;

import java.net.InetAddress;
import java.util.Arrays;

public class ArduinoCommunicator {
private InetAddress address;
private int port;
private OSCPortOut oscPortOut;

public ArduinoCommunicator(String ipAdress, int portNr) {
try{
address = InetAddress.getByName(ipAdress);
port = portNr;
oscPortOut = new OSCPortOut(address, port);
}
catch (Exception e){
e.printStackTrace();
}
}

public void sendMessage(double speed, double steer, boolean light){
String oscAddress = "/arduino/command"; // OSC-Adresse für die Nachricht
OSCMessage message = new OSCMessage(oscAddress, Arrays.asList(speed, steer, light));

try {
oscPortOut.send(message);
}
catch (Exception e){
e.printStackTrace();
}
System.out.println("OSC Nachricht gesendet: " + message);
}
}

+ 0
- 40
src/main/java/GameLogic.java View File

@@ -1,40 +0,0 @@
pu
Player
objekte
private Player player1 = new Player(0, 0);
private Player player2 = new Player(0, 0);

setUp()
// Playerobjekte
private Player player1 = new Player(0, 0);
private Player player2 = new Player(0, 0);

d set
{}()pU
iov etavirpleLogic gl = newmaG tatic void main(String[
{}sgra ])ic class GameLogic g
publ.run;
{
private void run(){
}
private void trackPlayer1(){
}
private void drawGrafics(){

}

private void trackPlayer2(){

}
private void checkPlayerCollission(){
}

}

+ 30
- 11
src/main/java/Player.java View File

@@ -3,34 +3,53 @@ import java.util.Queue;

public class Player {
// Attribute für die x- und y-Koordinaten
private int id;
private int trailLength = 30;
private final int ID;
private int x;
private int y;
Queue<int[]> trail = new LinkedList<>();

// Konstruktor zur Initialisierung der Koordinaten
public Player(int id) {
this.id = id;
ArduinoCommunicator arduinoCommunicator;



private final int TRAIL_LENGTH = 30;

// Konstruktor
public Player(int id, String finalIpAddress, int finalPortNr) {
this.ID = id;
arduinoCommunicator = new ArduinoCommunicator(finalIpAddress, finalPortNr);
}


//fügt 2 Koordinaten zum Trail hinzu und verhindert, dass dieser zulang wird
public void addToTrail(int x, int y){
//fügt 2 Koordinaten zum Trail hinzu nd verhindert, dass dieser zulang wird
public void setKoords(int x, int y){
addToTrail(x,y);
this.x = x;
this.y = y;


}

private void addToTrail(int x, int y) {
this.trail.add(new int[]{x, y});

if(trail.size() > trailLength){
if(trail.size() > TRAIL_LENGTH){
trail.poll();
}

}
public Queue<int[]> getTrail(){
return trail;
}

public void sendToCar(double speed, double steer, boolean light){
arduinoCommunicator.sendMessage(speed, steer, light);
}


//gibt aktuelle Position aus
public void printPosition() {
System.out.println("Player Position: (" + x + ", " + y + ")");
System.out.println(trail);
}
}


Loading…
Cancel
Save