Skip to content

Commit bef93bc

Browse files
committed
Create snake.js
1 parent 1c1cd2e commit bef93bc

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
class Example extends Phaser.Scene
2+
{
3+
constructor ()
4+
{
5+
super();
6+
}
7+
8+
create ()
9+
{
10+
// this.matter.world.setBounds().disableGravity();
11+
this.matter.world.disableGravity();
12+
13+
this.matter.add.mouseSpring();
14+
15+
let x = 100;
16+
let y = 300;
17+
let prevBody;
18+
19+
for (let i = 0; i < 8; i++)
20+
{
21+
const body = this.matter.add.circle(x, y, 24);
22+
23+
if (i > 0)
24+
{
25+
const s = this.matter.add.spring(body, prevBody, 48, 0.9, { damping: 0.9, angularStiffness: 0.9 });
26+
27+
console.log(s);
28+
}
29+
30+
prevBody = body;
31+
x += 64;
32+
}
33+
}
34+
35+
update ()
36+
{
37+
}
38+
}
39+
40+
const config = {
41+
type: Phaser.AUTO,
42+
width: 800,
43+
height: 600,
44+
backgroundColor: '#1b1464',
45+
parent: 'phaser-example',
46+
physics: {
47+
default: 'matter',
48+
matter: {
49+
enableSleeping: true,
50+
debug: {
51+
52+
showAxes: false,
53+
showAngleIndicator: true,
54+
angleColor: 0xe81153,
55+
56+
showBroadphase: false,
57+
broadphaseColor: 0xffb400,
58+
59+
showBounds: false,
60+
boundsColor: 0xffffff,
61+
62+
showVelocity: true,
63+
velocityColor: 0x00aeef,
64+
65+
showCollisions: true,
66+
collisionColor: 0xf5950c,
67+
68+
showSeparations: false,
69+
separationColor: 0xffa500,
70+
71+
showBody: true,
72+
showStaticBody: true,
73+
showInternalEdges: true,
74+
75+
renderFill: false,
76+
renderLine: true,
77+
78+
fillColor: 0x106909,
79+
fillOpacity: 1,
80+
lineColor: 0x28de19,
81+
lineOpacity: 1,
82+
lineThickness: 1,
83+
84+
staticFillColor: 0x0d177b,
85+
staticLineColor: 0x1327e4,
86+
87+
showSleeping: true,
88+
staticBodySleepOpacity: 1,
89+
sleepFillColor: 0x464646,
90+
sleepLineColor: 0x999a99,
91+
92+
showSensors: true,
93+
sensorFillColor: 0x0d177b,
94+
sensorLineColor: 0x1327e4,
95+
96+
showPositions: true,
97+
positionSize: 4,
98+
positionColor: 0xe042da,
99+
100+
showJoint: true,
101+
jointColor: 0xe0e042,
102+
jointLineOpacity: 1,
103+
jointLineThickness: 2,
104+
105+
pinSize: 4,
106+
pinColor: 0x42e0e0,
107+
108+
springColor: 0xe042e0,
109+
110+
anchorColor: 0xefefef,
111+
anchorSize: 4,
112+
113+
showConvexHulls: true,
114+
hullColor: 0xd703d0
115+
}
116+
}
117+
},
118+
scene: [ Example ]
119+
};
120+
121+
const game = new Phaser.Game(config);

0 commit comments

Comments
 (0)