xxxxxxxxxx
// Go to line 100 and use the directoins above it to make your level
var level=0; //change this to 0 to test your level (arrow keys to move)
function Clear(){
boxs=[]
hits=[]
boosts=[]
doors=[]
spikes=[]
parts=[]
fins=[]
cirs=[]
Matter.World.clear(world, false)
World.add(world, box1)
//dont get rid of these
addHit(0,-450,50,2000,false)//left
addHit(1950,-450,50,2000,false)//right
addHit(1000, 600-40, 2000, 80) //ground
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~FUNCTIONS~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_________________________________addHit()-adds a solid platform____________________________________
addHit( (x location), (y location), (width), (height), (if the player can jump from it true/false) )
this is similar to rect() with rectMode(CENTER)
_________________________________addBox()-adds a moveable box______________________________________
addBox( (x location), (y location), (width), (height) )
this is similar to rect() with rectMode(CENTER)
________________________________addCir()-adds a circle______________________________________________
addCir( (x location), (y location), (diameter) )
this is similar to circle()
________________________________addSpike()-adds a spike______________________________________________
addSpike( (x location), (y location), (width), (height), (moveable true/false) )
this is similar to rect() with rectMode(CENTER)
________________________________addFin()-adds a finish to the level___________________________________
addFin( (x location), (y location) )
____________________addBoost()-adds a booster that boosts anything that touches it____________________
addBox( (x location), (y location), (width), (height), (direction 0-3), (speed) )
this is similar to rect() with rectMode(CENTER)
________________________________________addDoor()-adds a door__________________________________________
addDoor( (x of button), (y of button), (x of door), (y of door), (width of door), (height of door) )
_______________________________________________________________________________________________________
Make sure your level is challenging and fun. Dont put too many boxes or circles or it might get laggy!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~coordinates~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0,-1500
|
|
|
|
|
|
|
|
|
0,0
|
|
|
|
|______________________________-______________________________
0, 550 550,1000 550,2000
*/
if(level==0){
//make your level in here
addHit(550, 550, 200, 200, true);
addHit(750, 550, 200, 400, true);
addHit(950, 550, 200, 600, true);
addHit(950, 550, 300, 1000, true);
addBoost(950, 0, 300, 100, 3, 5);
addHit(1050, -500, 200, 100, true);
addHit(850, -750, 200, 100, true);
addBoost(850, -850, 200, 100, 3, 10);
for(var i = 0; i < 25; i++) {
addCir(random(0, 2020), random(-1500, 550), 100, 100);
addBox(random(0, 2020), random(-1500, 550), 100, 100);
}
addFin(950, -2000);
}
// other levels if you want to make multiple
if(level==1){
addHit(150, 250, 50, 50);
addHit(100, 200, 50, 50);
addHit(400, 50, 400, 100);
addHit(600, -100, 400, 100);
addHit(400, -350, 400, 100);
addHit(200, -500, 400, 100);
addHit(400, -750, 400, 100);
addHit(600, -900, 400, 100);
addHit(400, -1150, 400, 100);
addHit(200, -1300, 400, 100);
addBoost(75, -1400, 100, 100, 0, 5);
addSpike(1000, 500, 2000, 100, false);
addFin(1750, 400);
addBoost(-300, 800, 600, 50, 3, 12);
}
if(level==2){
addHit(1000, 500, 400, 100);
addHit(970, 200, 340, 100);
addHit(1030, -100, 340, 100);
addHit(970, -400, 340, 100);
addHit(1030, -700, 340, 100);
addSpike(550, -1000, 700, 100, true);
addHit(950, -1000, 100, 100);
addHit(1200, -1200, 340, 100);
addFin(1800, 330);
addDoor(950, -1100, 1700, 300, 50, 600);
addDoor(1200, -1300, 1850, 0, 300, 50);
addBoost(-300, 800, 600, 50, 3, 12);
addBox(1100, -1250, 50, 50);
}
if(level==3){
}
if(level==4){
}
if(level==5){
}
}
p5.disableFriendlyErrors = true;
var Engine,
Render,
World,
Bodies;
var trd=false
var doBox=true
var rrr=0;
var t2=0
var engine
var box1
var world
var ground
var xspeed=0
var yspeed=0
var x=0
var y=0
var oldR=0
var maxspeed=13
var yt=0
var re=0
var t=0
var o=false
var transX=0
var transY=0
var tr=255
var tt=0
var st=0
var clear=0
var fastMode=false
var r=0
var rr=0
var r3=40
var up
var trans=true
var door_colors=[60,120,250,24]
var st5=0
function setup() {
frameRate(30)
createCanvas(windowWidth, windowHeight);
background(20, 243, 255)
textAlign(CENTER)
Engine = Matter.Engine
Render = Matter.Render
World = Matter.World
Bodies = Matter.Bodies;
engine = Engine.create();
world=engine.world
// Engine.run(engine);
box1 = Matter.Bodies.rectangle(100, 100, 80, 80,{restitution:0,mass:15,chamfer:
{ radius: 7 }});
ground = Bodies.rectangle(width/2, height-40, width, 80,{ isStatic: true,
restitution:0});
World.add(world, box1);
//World.add(world, ground);
rectMode(CENTER)
Clear()
// print(hits)
box1.label="player"
// print(box1)
// engine.positionIterations=10
// engine.velocityIterations=7
// Matter.Runner.isFixed=true
// print(box1.bounds.min.x-box1.bounds.max.x)
pixelDensity(1)
}
var tmx=0
var tmy=0
var st6=0
function draw() {
if(level==-1){
background(255,255,255)
textSize(30)
text("Hello! I've been working on a game and I need YOUR help making levels for it.\n\nHow to submit:\n Go in the code and read the instructions.\nOnce you have made your level/levels make a fork of this sketch and I might use it in my game.\nI will give you credit on the level you make",width/2,150)
}else{
Engine.update(engine, 1000/30);
background(20, 243, 255)
// if(keyIsDown(77)){Matter.Engine.clear(engine)}
// if(keyIsDown(67)&&st6==0){level++;st6=1;Clear()}
// if(!keyIsDown(67)){st6=0}
// if(keyIsDown(82)){Clear()}
tt++
t++
if(fastMode){
if(clear){
Matter.Engine.clear(engine);ellipse(20,20,20,20)}}
// if(keyIsDown(32)){Matter.Engine.clear(engine)}
x+=xspeed
y+=yspeed
//yspeed++
Matter.Body.translate(ground,{x:transX,y:transY})
if(frameCount%50==0){st5=0}
if(trans){
if(hits[0].body.position.x>=0){transX=0;
if(box1.position.x>width/2){transX=-box1.position.x+width/2}}else{transX=-box1.position.x+width/2}
if(hits[1].body.position.x<=width){transX=0;
if(box1.position.x<width/2){transX=-box1.position.x+width/2}}
if(hits[2].body.position.y<=height){transY=0} else{transY=-box1.position.y+height/2}
if(box1.position.y<height/2){transY=-box1.position.y+height/2}
}
// transY=-box1.position.y+height/2
// transY=0
// if(xspeed>0){xspeed--}
// // if(xspeed<0){xspeed++}
// if(tt>=1.001){
// Matter.Engine.clear(engine);tt=0}
push()
Matter.Body.translate(box1,{x:transX,y:transY})
if(trd){
tr--
}
push()
// push()
translate(box1.position.x,box1.position.y)
rotate(box1.angle)
if(doBox){
fill(0, 98, 255);
stroke(8, 86, 209)
strokeWeight(3)
rect(0, 0, 80, 80, 7)
// pop()
// push()
fill(0)
strokeWeight(0)}
// translate(box1.position.x,box1.position.y)
// if(!o){r+=0.01} else{ r=box1.angle+r}
// rotate(r)
// pop()
pop()
if(frameCount%20==0){
dst=0}
push()
translate(box1.position.x,box1.position.y)
// if(oldR==round(box1.angle*20)/20){
// rrr+=rrr/70
// }else{if(box1.angle>rrr){rrr+=rrr/20}
// }
if(t2>=15){rr-=rr/5;rrr-=rr/5}
if(oldR==round(box1.angle*20)/20){t2++}else{t2=0;rr=box1.angle+rrr}
rotate(rr=box1.angle+rrr)
fill(0)
noStroke()
if(doBox){
ellipse (-17,-15,7,7)
ellipse (17,-15,7,7)}
push()
fill(0)
strokeWeight(3)
stroke(0)
if(t>4){t=0;if(oldR!==round(box1.angle*20)/20){o=true}else{o=false}}
if(o){push()
// rotate(-box1.angle)
noFill()
if(doBox){ellipse(0,15,20,20)}
pop()}else{
// rotate(-box1.angle)
if(doBox){
line (-10*2,5*2,-5*2,8*2)
line (10*2,5*2,5*2,8*2)
line (-5*2,8*2,4*2,8*2)}}
pop()
pop()
pop()
oldR=round(box1.angle*20)/20
push()
Matter.Events.on(engine, 'collisionActive', ({ pairs }) => {
pairs.forEach(({ bodyA, bodyB,i=0 }) => {
// if(bodyA.label=="player"&&bodyB.label=="box"&&keyIsDown(38)){Matter.
// Body.setVelocity( box1, {x: box1.velocity.x, y: -10})}
// if(bodyA.label=="box"&&bodyB.label=="player"&&keyIsDown(38)){Matter.
// Body.setVelocity( box1, {x: box1.velocity.x, y: -10})}
if(bodyA.label=="player"&&bodyB.label=="Rectangle Body"&&(keyIsDown(38)||keyIsDown(87))&&
bodyA.position.y<bodyB.position.y){st=0;Matter.Body.setVelocity( box1,
{x: box1.velocity.x, y: -25});}
if(bodyA.label=="player"&&bodyB.label=="spike"){die()}
if(bodyA.label=="player"&&bodyB.label=="fin"){if(st5==0){
transX=0
transY=0
tmx=0
tmy=0
level++
Matter.Body.setPosition(box1,{x:80,y:0});Matter.Body.setVelocity
( box1, {x:0,y:0});Clear();st5=1}}//else{st5=0}
if(bodyA.label=="spike"&&bodyB.label=="player"){die()}
if(bodyA.label=="player"&&bodyB.label=="boost0"){Matter.Body.setVelocity( box1,
{x:bodyB.speed*10, y:box1.velocity.y });}
if(bodyB.label=="Rectangle Body"&&bodyA.label=="boost0"){Matter.Body.setVelocity
( bodyB, {x:bodyA.speed*10, y:bodyB.velocity.y });}
// text(pairs.length,20,20)
if(bodyA.label=="player"&&bodyB.label=="boost1"){Matter.Body.setVelocity
( box1, {x:box1.velocity.x, y:bodyB.speed*10 });}
if(bodyB.label=="Rectangle Body"&&bodyA.label=="boost1"){Matter.Body.setVelocity
( bodyB, {x:bodyB.velocity.x, y:bodyA.speed*10 });}
if(bodyA.label=="player"&&bodyB.label=="boost2"){Matter.Body.setVelocity
( box1, {x:-bodyB.speed*10, y:box1.velocity.y });}
if(bodyB.label=="Rectangle Body"&&bodyA.label=="boost2"){Matter.Body.setVelocity
(bodyB, {x:-bodyA.speed*10, y:bodyB.velocity.y });}
if(bodyA.label=="player"&&bodyB.label=="boost3"){
Matter.Body.setVelocity( box1, {x:box1.velocity.x, y:-bodyB.speed*10 });}
if(bodyB.label=="Rectangle Body"&&bodyA.label=="boost3"){
Matter.Body.setVelocity( bodyB, {x:bodyB.velocity.x, y:-bodyA.speed*10 });}
});
});
// rect(0,0,80,80)
tmx+=transX
tmy+=transY
pop()
fill(23, 176, 0)
// rect(ground.position.x, ground.position.y, width, 80)
for (let i=0; i< fins.length;i++){
fins[i].move();}
for (let i=0; i< boxs.length;i++){
boxs[i].move();
if (boxs[i].d==1) {boxs.splice(i,1);i--}
}
for (let i=0; i< cirs.length;i++){
cirs[i].move();
if (cirs[i].d==1) {cirs.splice(i,1);i--}
}
for (let i=0; i< hits.length;i++){
hits[i].move();}
for (let i=0; i< boosts.length;i++){
boosts[i].move();}
for (let i=0; i< doors.length;i++){
doors[i].move();}
for (let i=0; i< spikes.length;i++){
spikes[i].move();}
for (let i=0; i< parts.length;i++){
parts[i].move();if (parts[i].d==1) {parts.splice(i,1);i--}}
//if (keyIsDown(38)&&box1.velocity.y==0){Matter.Body.setVel
// ocity( box1, {x: box1.velocity.x, y: -10})}
if (keyIsDown(37)&&abs(box1.velocity.x)<=maxspeed){Matter.Body.setVelocity
( box1, {x: box1.velocity.x-1, y: box1.velocity.y})}
if (keyIsDown(39)&&abs(box1.velocity.x)<=maxspeed){Matter.Body.setVelocity
( box1, {x: box1.velocity.x+1, y: box1.velocity.y})}
//boxs.push(new Box())
// text(round(frameRate()),50,20)
text("x: "+round(tmx)+", y: "+round(tmy)+" FPS: "+round(frameRate())+" level: "+level,130,20)
// text(round(frameRate()),20,20)
}
}
function mousePressed(){
}
function addCir(x,y,w){
cirs.push(new Cir(x,y,w,w))
}
function addSpike(x,y,w,h,s){
spikes.push(new Spike(x,y,w,h,s))
}
function addBox(x,y,w,h){
boxs.push(new Box(x,y,w,h))
}
function addFin(x,y,w,h){
fins.push(new Fin(x,y,w,h))
}
function addBoost(x,y,w,h,d,s){
boosts.push(new boost(x,y,w,h,d,s))
}
function addDoor(x,y,x2,y2,w,h){
doors.push(new Door(x,y,x2,y2,w,h))
}
var boxs=[]
var hits=[]
var boosts=[]
var doors=[]
var spikes=[]
var parts=[]
var fins=[]
var cirs=[]
function Box (xx,yy,ww,hh) {
this.x=xx
this.y=yy
this.w=ww
this.h=hh
this.d=0
this.r=random(15,-45)
this.lr=round(random(1))
this.body=Bodies.rectangle(xx, yy, ww, hh,{restitution:0.3,friction:0.05,chamfer: { radius: 4 }});
World.add(world, this.body);
// this.body.label="box"
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
// if(keyIsDown(32)){World.remove(world, this.body);this.d=1}
var pos=this.body.position
var angle=this.body.angle
push()
translate(pos.x,pos.y)
rotate(angle)
fill(217+this.r, 188+this.r, 22+this.r)
stroke(173+this.r, 146+this.r, 38+this.r)
strokeWeight(3)
rect(0,0,this.w,this.h,4)
if(this.lr==1){
line(-ww/2+2,-hh/2+2,ww/2-2,hh/2-2)}else{
line(ww/2-2,-hh/2+2,-ww/2+2,hh/2-2)}
pop()
}}
function Cir (xx,yy,ww,hh) {
this.x=xx
this.y=yy
this.w=ww
this.h=ww
this.d=0
this.r=random(15,-45)
this.lr=round(random(1))
this.body=Bodies.circle(xx, yy, ww/2,{restitution:0.3,friction:0.1,mass:3});
World.add(world, this.body);
this.body.label="Rectangle Body"
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
// if(keyIsDown(32)){World.remove(world, this.body);this.d=1}
push()
translate(this.body.position.x,this.body.position.y)
rotate(this.body.angle)
fill(217+this.r, 188+this.r, 22+this.r)
stroke(173+this.r, 146+this.r, 38+this.r)
strokeWeight(3)
ellipse(0,0,this.w,this.w)
if(this.lr==1){
line(-ww/2+(ww/6),-hh/2+(ww/6),ww/2-(ww/6),hh/2-(ww/6))}else{
line(ww/2-(ww/6),-hh/2+(ww/6),-ww/2+(ww/6),hh/2-(ww/6))}
pop()
}}
function Fin (xx,yy,ww,hh) {
this.x=xx
this.y=yy
this.w=ww
this.h=hh
this.d=0
this.r=random(15,-45)
this.body=Bodies.circle(xx, yy, 50,{restitution:0.3,friction:0.05,isStatic: true,isSensor:true});
World.add(world, this.body);
this.body.label="fin"
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
// if(keyIsDown(32)){World.remove(world, this.body);this.d=1}
var pos=this.body.position
var angle=this.body.angle
push()
translate(pos.x,pos.y)
rotate(angle)
fill(251, 255, 33)
stroke(251, 255, 33,100)
strokeWeight(3)
ellipse(0,0,100)
pop()
}}
var dst=0
function Part (xx,yy) {
this.x=xx
this.y=yy
this.d=0
this.fade=255
this.fspeed=0
this.r=random(15,-45)
this.lr=round(random(1))
this.body=Bodies.rectangle(xx, yy, 20, 20,{restitution:0.3,friction:0.05});
World.add(world, this.body);
// this.body.label="box"
Matter.Body.setVelocity( this.body, {x:random(-25,25),y:random(-25,25)})
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
var pos=this.body.position
var angle=this.body.angle
if(this.fade<=0){
this.d=1;World.remove(world, this.body);
if(re==0){transX=0;transY=0;tmx=0;tmy=0;World.add(world, box1);re=1;
doBox=true;Matter.Body.setPosition
(box1,{x:80,y:0})
Matter.Body.setVelocity(box1,{x:0,y:0})
}
}
push()
translate(pos.x,pos.y)
this.fade-=this.fspeed
this.fspeed+=0.2
rotate(angle)
fill(0, 98, 255,this.fade)
noStroke()
rect(0,0,20,20)
pop()
}}
function Spike (xx,yy,ww,hh,ss) {
this.x=xx
this.y=yy
this.w=ww
this.h=hh
// this.r=random(15,-15)
this.body=Bodies.rectangle(this.x, this.y, this.w, this.h,{restitution:0.3,
friction:0.05,chamfer: { radius: 4 },isStatic: ss});
World.add(world, this.body);
this.body.label="spike"
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
push()
translate(this.body.position.x,this.body.position.y)
rotate(this.body.angle)
fill(255, 0, 0)
noStroke()
rect(0,0,this.w,this.h,4)
pop()
}
}
function Hit (xx,yy,ww,hh,hit) {
this.x=xx
this.y=yy
this.w=ww
this.h=hh
this.body=Bodies.rectangle(xx, yy, ww, hh,{ isStatic: true ,restitution:1,chamfer: { radius: 4 }});
World.add(world, this.body);
//this.body.label="ground"
this.move=function(){
if(hit==false){this.body.label=" "}
Matter.Body.translate(this.body,{x:transX,y:transY})
var pos=this.body.position
var angle=this.body.angle
push()
translate(pos.x,pos.y)
rotate(angle)
fill(23, 176, 0)
strokeWeight(3)
stroke(31, 148, 13)
rect(0,0,this.w,this.h,4)
pop()
}}
function Door (x2,y2,xx,yy,ww,hh) {
this.x=xx
this.y=yy
this.w=ww
this.h=hh
this.st=0
this.re=true
this.id=random(10000)
this.r=random(door_colors)
this.body=Bodies.rectangle(xx, yy, ww, hh,{ isStatic: true ,restitution:0,chamfer: { radius: 4 }});
this.body2=Bodies.rectangle(x2, y2, 40, 40,{ isStatic: true, isSensor:true ,restitution:0,chamfer: { radius: 4 }});
this.body.label="doorB"
this.body2.label="doorA"+this.id
World.add(world, this.body);
World.add(world, this.body2);
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
Matter.Body.translate(this.body2,{x:transX,y:transY})
var pos=this.body.position
var angle=this.body.angle
push()
colorMode(HSB,400)
translate(pos.x,pos.y)
rotate(angle)
if(this.re){fill(this.r,999,999)}else{fill(this.r,999,999,250)}
if(this.re){stroke(this.r,350,350)}else{stroke(this.r,350,350,250)}
strokeWeight(3)
rect(0,0,this.w,this.h,4)
pop()
push()
colorMode(HSB,400)
translate(this.body2.position.x,this.body2.position.y)
rotate(this.body.angle)
strokeWeight(3)
stroke(this.r,350,350)
fill(this.r,999,999)
if(this.re){rect(0,0,40,40,4)}else
{rect(0,5,40,30,4)}
pop()
// this.r+=2
Matter.Events.on(engine, 'collisionEnd', ({ pairs }) => {
pairs.forEach(({ bodyA, bodyB }) => {
if(this.st==0){this.st=1
if(bodyA.label=="player"&&bodyB.label=="doorA"+this.id||bodyA.label=="doorA"+this.id&&bodyB.label=="Rectangle Body")
{World.add(world, this.body);this.re=true}
}
});
});
Matter.Events.on(engine, 'collisionActive', ({ pairs }) => {
pairs.forEach(({ bodyA, bodyB }) => {
if(bodyA.label=="player"&&bodyB.label=="doorA"+this.id||bodyA.label=="doorA"+this.id&&bodyB.label=="Rectangle Body")
{World.remove(world, this.body);this.re=false}
this.st=0
});
});
}}
var stt=0
var op={ isStatic: true ,restitution:0,isSensor:true}
function boost (xx,yy,ww,hh,dd,ss) {
this.x=xx
this.y=yy
this.w=ww
this.h=hh
this.body=Bodies.rectangle(xx, yy, ww, hh,op);
this.xm=20
this.ww=ww-20
this.hh=hh-20
this.body.speed=ss
World.add(world, this.body);
this.body.label="boost"+dd
this.move=function(){
Matter.Body.translate(this.body,{x:transX,y:transY})
var pos=this.body.position
var angle=this.body.angle
push()
translate(pos.x,pos.y)
rotate(angle)
text(this.ss,0,0)
fill(0, 0, 255,100)
noStroke()
rect(0,0,this.w,this.h)
pop()
push()
fill(0,0,255,100)
pop()
push()
// angleMode(DEGREES)
this.xm+=ss
// if(this.xm>ww){this.xm=20}
translate(this.body.position.x-ww/2,pos.y)
// if(dd==1){
// rotate(PI/2)}
// if(dd==2){
// rotate(PI)}
// if(dd==3){
// rotate(-PI/2)}
if(dd==0){
for(let i=0;i<(ww/20)-1;i++){
stroke(255, 221, 0)
strokeWeight(5)
line(-20+((this.xm+(i*20))%this.ww)+20,-hh/2,0+((this.xm+(i*20))%this.ww)+20,0)
line(0+((this.xm+(i*20))%this.ww)+20,0,-20+((this.xm+(i*20))%this.ww)+20,hh/2)}
// ellipse(0,0,20,20)
} if(dd==2){
for(let i=0;i<(ww/20)-1;i++){
stroke(255, 221, 0)
strokeWeight(5)
line(0-((this.xm+(i*20))%this.ww)+ww,-hh/2,-20-((this.xm+(i*20))%this.ww)+ww,0)
line(-20-((this.xm+(i*20))%this.ww)+ww,0,0-((this.xm+(i*20))%this.ww)+ww,hh/2)}
// ellipse(0,0,20,20)
}
if(dd==1){
for(let i=0;i<(hh/20)-1;i++){
stroke(255, 221, 0)
strokeWeight(5)
line(0,((this.xm+(i*20))%this.hh)-hh/2,ww/2,((this.xm+(i*20))%this.hh)+20-hh/2)
line(ww/2,(((this.xm+(i*20))%this.hh)+20)-hh/2,ww,(((this.xm+(i*20))%this.hh))-hh/2)
// ellipse(0,0,20,20)
}}
if(dd==3){
for(let i=0;i<(hh/20)-1;i++){
stroke(255, 221, 0)
strokeWeight(5)
line(0,-((this.xm+(i*20))%this.hh)+hh/2,ww/2,-((this.xm+(i*20))%this.hh)+hh/2-20)
line(ww/2,-(((this.xm+(i*20))%this.hh))+hh/2-20,ww,-(((this.xm+(i*20))%this.hh))+hh/2)
// ellipse(0,0,20,20)
}}
pop()
}}
var td=0
function die(){
World.remove(world, box1);doBox=false
if(dst==0){dst=1
for(let x=0;x<80;x+=20){
for(let y=0;y<80;y+=20){
parts.push(new Part((box1.position.x-40)+x,(box1.position.y-40)+y))
re=0
}}
}
}
function addHit(x,y,w,h,s){
hits.push(new Hit(x, y, w, h,s))
}