“Collisions groupe” by Samabibou
https://openprocessing.org/sketch/615280
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
A fork of Collisions 3 by Samabibou
CC Attribution ShareAlike
Collisions groupe
xxxxxxxxxx
var walls;
var boxes;
var player;
function setup() {
createCanvas(windowWidth, windowHeight);
walls = new Group(); // vu qu'on va avoir pleins de murs on les rentre dans la classe mur
boxes = new Group();
player = createSprite(100, 100, 40, 40);
player.shapeColor = color(255);
for (var i = 0; i < 5; i++) {
var w = createSprite(
random(125, width-125), (height/5)*i,
random(10, 100), random(10, 100));
w.shapeColor = color(0);
walls.add(w); // une fois que le mur "w" est entièrement défini, on peut l'ajouter au groupe "walls"
//si on avait envie de faire appel à un mur particulier , pour changer sa forme , sa taille ou autre
// on peut l'appeler individuellement avec walls[numéro du mur] ici le numéro ira de 0 à 9
}
for (var i = 0; i < 4; i++) { // ici on va créer 4 caisses
var b = createSprite(random(50, 100), random(100, height-100), 25, 25);
b.shapeColor = color(255, 0, 0);
boxes.add(b);
}
}
function draw() {
background(50);
player.velocity.x = (mouseX-player.position.x)*0.1;
// avec cette approche plus la souris est loin plus elle est attirante
player.velocity.y =
(mouseY-player.position.y)*0.1;
// on indique dans ce qui suit les actions potentielles entre les groupes de sprites
player.collide(walls);
player.displace(boxes);
boxes.collide(walls);
boxes.displace(boxes);
drawSprites();
}
See More Shortcuts