-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/nbourre/0sw_processing_ex…
- Loading branch information
Showing
513 changed files
with
1,094 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Run Sketch", | ||
"type": "shell", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"command": "${config:processing.path}", | ||
"presentation": { | ||
"echo": true, | ||
"reveal": "always", | ||
"focus": false, | ||
"panel": "dedicated" | ||
}, | ||
"args": [ | ||
"--force", | ||
"--sketch=${workspaceFolder}/${relativeFileDirname}", | ||
"--output=${workspaceFolder}/out", | ||
"--run" | ||
], | ||
"windows": { | ||
"args": [ | ||
"--force", | ||
"--sketch=${workspaceFolder}\\${relativeFileDirname}", | ||
"--output=${workspaceFolder}\\out", | ||
"--run" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Classe avec forces | ||
## Code de base | ||
```java | ||
//... autre code ... | ||
|
||
// Code de base pour update | ||
// adapter pour la classe | ||
void update() { | ||
velocity.add(acceleration); | ||
velocity.limit(maxSpeed); // Si limite de vitesse | ||
location.add(velocity); | ||
|
||
acceleration.mult(0); // On remet l'accélération à 0 | ||
} | ||
|
||
// Fonction pour ajouter une force à l'accélération | ||
void applyForce(PVector force) { | ||
var f = PVector.div(force, mass); | ||
acceleration.add(f); | ||
} | ||
|
||
//... autre code ... | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
class Rectangle extends GraphicObject { | ||
int w, h; | ||
|
||
Rectangle () { | ||
instanciate(); | ||
} | ||
|
||
Rectangle (float x, float y, int _w, int _h) { | ||
instanciate(); | ||
|
||
location.x = x; | ||
location.y = y; | ||
w = _w; | ||
h = _h; | ||
} | ||
|
||
void instanciate() { | ||
location = new PVector(); | ||
velocity = new PVector(); | ||
acceleration = new PVector(); | ||
|
||
w = 100; | ||
h = 50; | ||
} | ||
|
||
void update(int deltaTime) { | ||
checkEdges(); | ||
|
||
velocity.add (acceleration); | ||
location.add (velocity); | ||
|
||
acceleration.mult(0); | ||
} | ||
|
||
void display() { | ||
pushMatrix(); | ||
translate (location.x, location.y); | ||
rect (0, 0, w, h); | ||
popMatrix(); | ||
} | ||
|
||
// Fonction facilitant la compréhension des conditions | ||
public int top() { return (int)location.y; } | ||
public int bottom() { return (int)location.y + h; } | ||
public int left() { return (int)location.x; } | ||
public int right() { return (int)location.x + w; } | ||
|
||
void checkEdges() { | ||
if (left() < 0 || right() > width) { | ||
velocity.x *= -1; | ||
} | ||
|
||
if (top() < 0 || bottom() > height) { | ||
velocity.y *= -1; | ||
} | ||
} | ||
|
||
public void checkCollisions(Rectangle other) { | ||
if (isBouncingX(other)) { | ||
velocity.x *= -1; | ||
} | ||
|
||
if (isBouncingY(other)) { | ||
velocity.y *= -1; | ||
} | ||
} | ||
|
||
// Retourne vrai s'il y a un contact en X | ||
public boolean isBouncingX(Rectangle other) { | ||
// Si je continue en X est-ce que je vais | ||
// avoir une collision avec l'autre | ||
boolean passLeft = right() + velocity.x > other.left(); | ||
boolean passRight = left() + velocity.x < other.right(); | ||
|
||
boolean checkTop = bottom() > other.top(); | ||
boolean checkBottom = top() < other.bottom(); | ||
|
||
return passLeft && passRight && checkBottom && checkTop; | ||
} | ||
|
||
// Retourne vrai s'il y a un contact en Y | ||
public boolean isBouncingY(Rectangle other) { | ||
|
||
boolean checkRight = right() > other.left(); | ||
boolean checkLeft = left() < other.right(); | ||
|
||
// Si je continue en Y est-ce que je vais | ||
// avoir une collision avec l'autre | ||
boolean passBottom = bottom() + velocity.y > other.top(); | ||
boolean passTop = top() + velocity.y < other.bottom(); | ||
|
||
return checkRight && checkLeft && passBottom && passTop; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
Classe simulant un fluide. Elle est représentée par un rectangle. | ||
*/ | ||
class Fluid { | ||
Rectangle r; | ||
float density; | ||
float coefficientFriction; | ||
|
||
private color c; | ||
|
||
Fluid () { | ||
float quarterHeight = height / 4; | ||
r = new Rectangle(0, height - quarterHeight, width, quarterHeight); | ||
density = 0.8; | ||
coefficientFriction = 0.1; | ||
|
||
this.c = color (127, 127); | ||
} | ||
|
||
Fluid (Rectangle _r, float _density, float _coefficientFriction) { | ||
r = _r; | ||
density = _density; | ||
coefficientFriction = _coefficientFriction; | ||
|
||
this.c = color (127, 127); | ||
} | ||
|
||
void setRectangle (Rectangle _r) { | ||
r = _r; | ||
} | ||
|
||
Rectangle getRectangle () { | ||
return r; | ||
} | ||
|
||
void display () { | ||
|
||
fill (c); | ||
r.display(); | ||
} | ||
|
||
/** | ||
Formule F = -0.5 * rho * ||v||^2 * area * friction * speed.normalise | ||
*/ | ||
PVector draggingForce(PVector speed, float area) { | ||
float speedMag = speed.mag(); | ||
float coeffRhoMag = density * coefficientFriction * speedMag * speedMag * 0.5; | ||
|
||
PVector result = speed.get(); | ||
result.mult(-1); | ||
result.normalize(); | ||
result.mult(area); | ||
result.mult(coeffRhoMag); | ||
|
||
return result; | ||
} | ||
|
||
void setColor (color c) { | ||
this.c = c; | ||
} | ||
|
||
void setLocation (int x, int y) { | ||
this.r.x = x; | ||
this.r.y = y; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class Forces { | ||
|
||
Forces () { | ||
} | ||
|
||
// Faux calcul qui prend une valeur scalaire pour la normale | ||
PVector friction (PVector vitesse, float coeffFriction, float normale) { | ||
PVector resultat = new PVector(); | ||
|
||
resultat = vitesse.get(); | ||
|
||
resultat.mult(-1); | ||
resultat.normalize(); // Réduire la direction en valeur unitaire | ||
|
||
|
||
resultat.mult(normale * coeffFriction); | ||
|
||
return resultat; | ||
} | ||
} |
Oops, something went wrong.