-
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
492 changed files
with
518 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
class Ball extends GraphicObject { | ||
|
||
int radius = 10; | ||
|
||
|
||
Ball (int _x, int _y) { | ||
location = new PVector(_x, _y); | ||
|
||
} | ||
|
||
|
||
void update(int delta) { | ||
|
||
} | ||
|
||
void display() | ||
{ | ||
pushMatrix(); | ||
translate(location.x, location.y); | ||
fill(fillColor); | ||
ellipse(0, 0, radius, radius); | ||
popMatrix(); | ||
} | ||
|
||
float top() { | ||
return location.y - radius; | ||
} | ||
|
||
float bottom() { | ||
return location.y + radius; | ||
} | ||
|
||
float left() { | ||
return location.x - radius; | ||
} | ||
|
||
float right() { | ||
return location.x + radius; | ||
} | ||
|
||
|
||
} |
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,32 @@ | ||
class Block extends Rectangle { | ||
int w = 50; | ||
int h = 10; | ||
ICollidable collidable; | ||
|
||
Block() { | ||
location = new PVector(width / 2, height / 2); | ||
fillColor = color(0, 200, 0); | ||
|
||
} | ||
|
||
void addCollidable(ICollidable other) { | ||
collidable = other; | ||
} | ||
|
||
|
||
|
||
void update (int deltaTime) { | ||
|
||
} | ||
|
||
|
||
void display () { | ||
pushMatrix(); | ||
translate(location.x, location.y); | ||
fill(fillColor); | ||
rect(0, 0, w, h); | ||
popMatrix(); | ||
} | ||
|
||
|
||
} |
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,59 @@ | ||
class Destroyer extends Ball implements ICollidable { | ||
float vitesse = 5.0; | ||
ArrayList<ICollidable> collidables; | ||
|
||
Destroyer (int _x, int _y) { | ||
super(_x, _y); | ||
initValues(); | ||
} | ||
|
||
void initValues() { | ||
collidables = new ArrayList<ICollidable>(); | ||
velocity = new PVector(); | ||
velocity.x = round(random(0, 1)) == 1? 1 : -1; | ||
velocity.y = -1; | ||
velocity.normalize(); | ||
velocity.mult(vitesse); | ||
} | ||
|
||
void update(int delta) { | ||
checkEdges(); | ||
|
||
for (ICollidable other : collidables) { | ||
if (hasCollision(other)) { | ||
|
||
} | ||
} | ||
|
||
location.add(velocity); | ||
|
||
super.update(delta); | ||
} | ||
|
||
void checkEdges() { | ||
if (right() > width || left() < 0) { | ||
velocity.x *= -1; | ||
} | ||
|
||
if (top() < 0 || bottom() > height) { | ||
velocity.y *= -1; | ||
} | ||
} | ||
|
||
boolean hasCollision(ICollidable other) { | ||
if (other == null) return false; | ||
|
||
return other.bottom() > top() && other.top() < bottom() | ||
&& other.left() < right() && other.right() > left(); | ||
} | ||
|
||
void setCollision(boolean xColl, boolean yColl) { | ||
if (xColl) { | ||
velocity.x *= -1; | ||
} | ||
|
||
if (yColl) { | ||
velocity.y *= -1; | ||
} | ||
} | ||
} |
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,14 @@ | ||
abstract class GraphicObject { | ||
public PVector location; | ||
public PVector velocity; | ||
public PVector acceleration; | ||
|
||
color fillColor = color (255); | ||
color strokeColor = color (255); | ||
float strokeWeight = 1; | ||
|
||
abstract void update(int deltaTime); | ||
|
||
abstract void display(); | ||
|
||
} |
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,7 @@ | ||
interface ICollidable { | ||
boolean hasCollision(ICollidable other); | ||
float top(); | ||
float bottom(); | ||
float left(); | ||
float right(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
int currentTime; | ||
int previousTime; | ||
int deltaTime; | ||
|
||
boolean saveVideo = false; | ||
|
||
Destroyer b; | ||
Block blk; | ||
|
||
void setup () { | ||
size (800, 600); | ||
currentTime = millis(); | ||
previousTime = millis(); | ||
b = new Destroyer(width / 2, height / 2); | ||
blk = new Block(); | ||
blk.addCollidable(b); | ||
} | ||
|
||
void draw () { | ||
currentTime = millis(); | ||
deltaTime = currentTime - previousTime; | ||
previousTime = currentTime; | ||
|
||
|
||
update(deltaTime); | ||
display(); | ||
|
||
savingFrames(5, deltaTime); | ||
} | ||
|
||
/*** | ||
The calculations should go here | ||
*/ | ||
void update(int delta) { | ||
blk.update(delta); | ||
b.update(delta); | ||
} | ||
|
||
/*** | ||
The rendering should go here | ||
*/ | ||
void display () { | ||
background(0); | ||
blk.display(); | ||
b.display(); | ||
} | ||
|
||
//Saving frames for video | ||
//Put saveVideo to true; | ||
int savingAcc = 0; | ||
int nbFrames = 0; | ||
|
||
void savingFrames(int forMS, int deltaTime) { | ||
|
||
if (!saveVideo) return; | ||
|
||
savingAcc += deltaTime; | ||
|
||
if (savingAcc < forMS) { | ||
saveFrame("frames/####.tiff"); | ||
nbFrames++; | ||
} else { | ||
println("Saving frames done! " + nbFrames + " saved"); | ||
saveVideo = false; | ||
} | ||
} |
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,50 @@ | ||
// Rename ShapeTemplate to whatever needed | ||
class ShapeTemplate extends GraphicObject { | ||
|
||
|
||
ShapeTemplate () { | ||
instanciate(); | ||
} | ||
|
||
ShapeTemplate (float x, float y) { | ||
instanciate(); | ||
location.x = x; | ||
location.y = y; | ||
|
||
} | ||
|
||
|
||
|
||
void instanciate() { | ||
location = new PVector(); | ||
velocity = new PVector(); | ||
acceleration = new PVector(); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
void update(int deltaTime) { | ||
velocity.add(acceleration); | ||
location.add (velocity); | ||
|
||
acceleration.mult(0); | ||
} | ||
|
||
void display() { | ||
pushMatrix(); | ||
translate(location.x, location.y); | ||
|
||
// Code diplay stuff here | ||
|
||
fill(fillColor); | ||
|
||
|
||
|
||
popMatrix(); | ||
|
||
} | ||
|
||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Oops, something went wrong.