Skip to content
Snippets Groups Projects
Commit 76f61580 authored by Louis MALTERRE's avatar Louis MALTERRE
Browse files

physique opérationnelle (encore qq légers bugs mais apres on est sur de la perf) LM

parent 284c88b1
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 94 deletions
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/acl-project.iml" filepath="$PROJECT_DIR$/.idea/acl-project.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="MAVENProject" />
</profile>
</annotationProcessing>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="17" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -16,7 +16,7 @@ public interface Game {
* @param userCmd
* commande utilisateur
*/
public void evolve(ArrayList userCmd);
public void evolve(ArrayList<Boolean> userCmd);
/**
* @return true si et seulement si le jeu est fini
......
......@@ -17,6 +17,6 @@ public interface GameController extends KeyListener {
*
* @return commande faite par le joueur
*/
public ArrayList getCommand();
public ArrayList<Boolean> getCommand();
}
......@@ -61,7 +61,7 @@ public class GameEngineGraphical {
// boucle de game
while (!this.game.isFinished()) {
// demande controle utilisateur
ArrayList a = this.gameController.getCommand(); //
ArrayList<Boolean> a = this.gameController.getCommand(); //
// fait evoluer le game
this.game.evolve(a);
// affiche le game
......
......@@ -26,7 +26,9 @@ public class Character extends Entity{
newX = -m/Physique.lambda*(vitesseActuX - commandX/Physique.lambda)*Math.exp(-Physique.lambda*delta/m) + commandX*delta + this.getCoord().getX();
}
else newX = this.getCoord().getX();
newZ = ((1-alpha)*Physique.g - commandZ/m)/2*delta*delta + vitesseActuZ*delta + this.getCoord().getZ();
if ((commandZ == 0) && (this.getCoord().getZ() >= 80))newZ = this.getCoord().getZ();
else newZ = ((1-alpha)*Physique.g - commandZ/m)/2*delta*delta + vitesseActuZ*delta + this.getCoord().getZ();
System.out.println("écart de hauteur: "+(this.getCoord().getZ()-newZ));
this.setCoord(new Coordonnees(newX, newZ)); // repere ou la hauteur augmente vers le bas, a revoir
......@@ -36,6 +38,7 @@ public class Character extends Entity{
vitesseActuX += commandX/Physique.lambda;
}
else vitesseActuX = 0;
if ((commandZ == 0) && (this.getCoord().getZ() >= 80)) vitesseActuZ = 0;
vitesseActuZ = vitesseActuZ + ((1-alpha)*Physique.g - commandZ/m)*delta;
System.out.println("vitesse z: "+vitesseActuZ);
//vitesseActuZ = -vitesseActuZ;
......
package environnement;
public class Physique {
public static final double g = 10000; // pesanteur
public static final double g = 3000; // pesanteur
public static final double lambda = 0.05; // coefficient de frottements
}
......@@ -20,11 +20,11 @@ public class Controller implements GameController{
isRightPressed = false; isLeftPressed = false; isSpacePressed = false;
}
/**
* getCommand retourne une list de booleans sous la forme [isRightPressed, isLeftPressed, isSpacePressed]
* getCommand retourne une liste de booleans sous la forme [isRightPressed, isLeftPressed, isSpacePressed]
*/
@Override
public ArrayList getCommand() {
ArrayList a = new ArrayList<Boolean>();
public ArrayList<Boolean> getCommand() {
ArrayList<Boolean> a = new ArrayList<Boolean>();
a.add(isRightPressed);
a.add(isLeftPressed);
a.add(isSpacePressed);
......
package jeu;
import engine.Game;
import engine.GameEngineGraphical;
import environnement.Physique;
import java.io.BufferedReader;
......@@ -32,33 +33,38 @@ public class Jeu implements Game{
}
@Override
public void evolve(ArrayList command) { // command est sous la forme list de Boolean qui représente les touches préssées. Voir Controller pour la compositions de cet list.
public void evolve(ArrayList<Boolean> command) { // command est sous la forme list de Boolean qui représente les touches préssées. Voir Controller pour la compositions de cet list.
System.out.println("Execute "+command);
System.out.println(charac.getCoord().getX());
System.out.println(charac.getCoord().getZ());
double comX,comZ;
int a = 1;
int n = 0; //tentative de faire une commande selon z qui décroit au cours du temps
comX = 0;
comZ = 0;
boolean Right = (boolean) command.get(0);
boolean Left = (boolean) command.get(0);
boolean Jump = (boolean) command.get(0);
boolean Right = command.get(1); //gauche et droite sont inverses je sais pas pk
boolean Left = command.get(0);
boolean Jump = command.get(2);
if (Right) {
comX = -charac.getVitesseMax()*Physique.lambda;
}
if (Left) {
else if (Left) {
comX = charac.getVitesseMax() * Physique.lambda;
}
if (Jump) {
if (charac.getCoord().getZ() < 80) a = 0;
else comZ = 30000 * charac.getVitesseMax() * charac.getM();
if (charac.getCoord().getZ() < 80){a = 0;}
else comZ = 300000 * charac.getVitesseMax() * charac.getM()*Math.exp(-n*GameEngineGraphical.getDeltaT()*Math.pow(10, -3));
}
else {
if (charac.getCoord().getZ() >= 80) { //a retoucher, j'ai besoin d'autres choses pour avancer
if (charac.getCoord().getZ() < 80) { //a retoucher, j'ai besoin d'autres choses pour avancer
a = 0;
}
else{
a = 1;
n = 0;
}
/*else{
......
File deleted
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment