Browse Source

V2.2 des Gameloop und Logic

11.12.24 16:45
master
Paul-1108 1 week ago
parent
commit
739a7e129c
3 changed files with 37 additions and 29 deletions
  1. 23
    1
      .idea/workspace.xml
  2. 6
    21
      src/main/java/GameLogic.java
  3. 8
    7
      src/main/java/GameLoop.java

+ 23
- 1
.idea/workspace.xml View File

</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="4d75e996-cee4-4ec6-b802-5b56d0c0eac4" name="Changes" comment="Version 27.11 (&quot;fertiger&quot; Tracker)"> <list default="true" id="4d75e996-cee4-4ec6-b802-5b56d0c0eac4" name="Changes" comment="Version 27.11 (&quot;fertiger&quot; Tracker)">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.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/GameLoop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/GameLoop.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/GameLoop.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/GameLoop.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/GraphicsProgram.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/GraphicsProgram.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/Tracker.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Tracker.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>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
</component> </component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
</component> </component>
<component name="ProjectColorInfo">{ <component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 8 &quot;associatedIndex&quot;: 8
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent"><![CDATA[{
"keyToString": { "keyToString": {
"Application.GTCar.executor": "Run", "Application.GTCar.executor": "Run",
"Application.GameLogic.executor": "Run",
"Application.GraphicsProgram.executor": "Run", "Application.GraphicsProgram.executor": "Run",
"Application.Main.executor": "Run", "Application.Main.executor": "Run",
"Application.Tracker.executor": "Run", "Application.Tracker.executor": "Run",
<option name="Make" enabled="true" /> <option name="Make" enabled="true" />
</method> </method>
</configuration> </configuration>
<configuration name="GameLogic" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="GameLogic" />
<module name="GTCar_V2_maven" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> <configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" /> <option name="MAIN_CLASS_NAME" value="Main" />
<module name="GTCar_V2_maven" /> <module name="GTCar_V2_maven" />
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Application.Main" /> <item itemvalue="Application.Main" />
<item itemvalue="Application.GameLogic" />
</list> </list>
</recent_temporary> </recent_temporary>
</component> </component>
<MESSAGE value="Version 27.11 (&quot;fertiger&quot; Tracker)" /> <MESSAGE value="Version 27.11 (&quot;fertiger&quot; Tracker)" />
<option name="LAST_COMMIT_MESSAGE" value="Version 27.11 (&quot;fertiger&quot; Tracker)" /> <option name="LAST_COMMIT_MESSAGE" value="Version 27.11 (&quot;fertiger&quot; Tracker)" />
</component> </component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" type="java-exception">
<properties class="java.lang.NullPointerException" package="java.lang" />
<option name="timeStamp" value="1" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project> </project>

+ 6
- 21
src/main/java/GameLogic.java View File

PApplet.main("GameLogic"); PApplet.main("GameLogic");
} }


/* public boolean checkForPlayerCollision(Point point){
int c = get(point.x, point.y);
if (c==0){
return true; //Kollision erkannt
} else {
return false;
}
}

public void drawCheckTrail(Queue<int[]> trail){
int particleSize = trail.size()+5;
background(255);

for (int[] koordinates : new LinkedList<>(trail)) {
int x = koordinates[0];
int y = koordinates[1];
fill(0,0,0);
rect(x, y, particleSize, particleSize);
}
public void settings() {
size(800, 600);
noLoop();
} }
*/


public boolean doCheck(Queue<int[]> trail, Point point){ public boolean doCheck(Queue<int[]> trail, Point point){

int particleSize = trail.size()+5; int particleSize = trail.size()+5;
background(255);

background(255, 255, 255);


for (int[] koordinates : new LinkedList<>(trail)) { for (int[] koordinates : new LinkedList<>(trail)) {
int x = koordinates[0]; int x = koordinates[0];

+ 8
- 7
src/main/java/GameLoop.java View File

Player player2; Player player2;


public GameLoop(){ public GameLoop(){
player1 = new Player(0, "ip", 9000);
player2 = new Player(1, "ip", 9000);
player1 = new Player(0, "192.168.1.1", 9000);
player2 = new Player(1, "192.168.1.2", 9000);
tracker = new Tracker(); tracker = new Tracker();

graphics = new GraphicsProgram(); graphics = new GraphicsProgram();
String[] args = {"GraphicsProgram"}; String[] args = {"GraphicsProgram"};
PApplet.runSketch(args, graphics); PApplet.runSketch(args, graphics);

gl = new GameLogic(); gl = new GameLogic();
String[] args_ = {"GameLogic"};
PApplet.runSketch(args_, gl);
run(); run();
} }




List<Point> positions = track(); List<Point> positions = track();


addPositions(positions);

if(gl.doCheck(player2.getTrail(), positions.get(0))){ //Check Position von P1 mit Spur von P2 if(gl.doCheck(player2.getTrail(), positions.get(0))){ //Check Position von P1 mit Spur von P2
System.out.println("Spieler 1 hat verloren"); System.out.println("Spieler 1 hat verloren");
break; break;
player2.setKoords(p2.x, p2.y); player2.setKoords(p2.x, p2.y);


List<Point> output = new ArrayList<>(); List<Point> output = new ArrayList<>();
output.set(0, p1);
output.set(1, p2);
output.add(0, p1);
output.add(1, p2);
return output; return output;
} }


private void draw(){ private void draw(){
graphics.drawTrail(player1.getTrail(), 0); graphics.drawTrail(player1.getTrail(), 0);
graphics.drawTrail(player2.getTrail(), 1); graphics.drawTrail(player2.getTrail(), 1);

} }
} }

Loading…
Cancel
Save