Browse Source

Version 20.11

master
David Moeckel 1 month ago
parent
commit
c6f1afc206

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

<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <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="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
"Downloaded.Files.Path.Enabled": "false",
"Repository.Attach.Annotations": "false",
"Repository.Attach.JavaDocs": "false",
"Repository.Attach.Sources": "false",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"com.codeium.enabled": "true", "com.codeium.enabled": "true",
"git-widget-placeholder": "master", "git-widget-placeholder": "master",
"node.js.selected.package.eslint": "(autodetect)", "node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)", "node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm", "nodejs_package_manager_path": "npm",
"project.structure.last.edited": "Libraries",
"project.structure.last.edited": "Project",
"project.structure.proportion": "0.15", "project.structure.proportion": "0.15",
"project.structure.side.proportion": "0.41724136",
"project.structure.side.proportion": "0.0",
"vue.rearranger.settings.migration": "true" "vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1732108904989</updated> <updated>1732108904989</updated>
<workItem from="1732108906083" duration="3420000" />
<workItem from="1732108906083" duration="758000" />
</task> </task>
<task id="LOCAL-00001" summary="First Commit Test"> <task id="LOCAL-00001" summary="First Commit Test">
<option name="closed" value="true" /> <option name="closed" value="true" />
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1732109548353</updated> <updated>1732109548353</updated>
</task> </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 /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value="First Commit Test" /> <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> </component>
</project> </project>

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

import com.illposed.osc.OSCMessage;
import com.illposed.osc.transport.OSCPortOut;

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

public class ArduinoCommunicator { 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

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



public class Player { public class Player {
// Attribute für die x- und y-Koordinaten // 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<>(); 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}); this.trail.add(new int[]{x, y});


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

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


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



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



Loading…
Cancel
Save