1size 900 760
2background #0a0e1c
3timeline 24 120
4use "collision"
5var bx = 450
6var by = 560
7var vx = 4.4
8var vy = -5.2
9var px = 450
10var score = 0
11var lost = 0
12var started = 0
13var bricks = fill(32, 1)
14
15scene {
16 layer "Fond" {
17 path "M0 0L900 0L900 760L0 760Z" fill radial(0.5, 0.5, 0.5, 0:#16203c, 1:#070a16)
18 }
19 layer "Cadre" {
20 path "M8 8L892 8L892 752L8 752ZM20 20L880 20L880 740L20 740Z" fill #1a2440 opacity 0.6
21 }
22 layer "Briques" {
23 instance "Brique" as "Brique 0" at 86,105 pivot 0,0 tint #ff6b6b 0.85
24 instance "Brique" as "Brique 1" at 190,105 pivot 0,0 tint #ff9f45 0.85
25 instance "Brique" as "Brique 2" at 294,105 pivot 0,0 tint #ffd24d 0.85
26 instance "Brique" as "Brique 3" at 398,105 pivot 0,0 tint #7af0a0 0.85
27 instance "Brique" as "Brique 4" at 502,105 pivot 0,0 tint #5ad1ff 0.85
28 instance "Brique" as "Brique 5" at 606,105 pivot 0,0 tint #5b9dff 0.85
29 instance "Brique" as "Brique 6" at 710,105 pivot 0,0 tint #b388ff 0.85
30 instance "Brique" as "Brique 7" at 814,105 pivot 0,0 tint #ff7ab0 0.85
31 instance "Brique" as "Brique 8" at 86,143 pivot 0,0 tint #ff9f45 0.85
32 instance "Brique" as "Brique 9" at 190,143 pivot 0,0 tint #ffd24d 0.85
33 instance "Brique" as "Brique 10" at 294,143 pivot 0,0 tint #7af0a0 0.85
34 instance "Brique" as "Brique 11" at 398,143 pivot 0,0 tint #5ad1ff 0.85
35 instance "Brique" as "Brique 12" at 502,143 pivot 0,0 tint #5b9dff 0.85
36 instance "Brique" as "Brique 13" at 606,143 pivot 0,0 tint #b388ff 0.85
37 instance "Brique" as "Brique 14" at 710,143 pivot 0,0 tint #ff7ab0 0.85
38 instance "Brique" as "Brique 15" at 814,143 pivot 0,0 tint #ff6b6b 0.85
39 instance "Brique" as "Brique 16" at 86,181 pivot 0,0 tint #ffd24d 0.85
40 instance "Brique" as "Brique 17" at 190,181 pivot 0,0 tint #7af0a0 0.85
41 instance "Brique" as "Brique 18" at 294,181 pivot 0,0 tint #5ad1ff 0.85
42 instance "Brique" as "Brique 19" at 398,181 pivot 0,0 tint #5b9dff 0.85
43 instance "Brique" as "Brique 20" at 502,181 pivot 0,0 tint #b388ff 0.85
44 instance "Brique" as "Brique 21" at 606,181 pivot 0,0 tint #ff7ab0 0.85
45 instance "Brique" as "Brique 22" at 710,181 pivot 0,0 tint #ff6b6b 0.85
46 instance "Brique" as "Brique 23" at 814,181 pivot 0,0 tint #ff9f45 0.85
47 instance "Brique" as "Brique 24" at 86,219 pivot 0,0 tint #7af0a0 0.85
48 instance "Brique" as "Brique 25" at 190,219 pivot 0,0 tint #5ad1ff 0.85
49 instance "Brique" as "Brique 26" at 294,219 pivot 0,0 tint #5b9dff 0.85
50 instance "Brique" as "Brique 27" at 398,219 pivot 0,0 tint #b388ff 0.85
51 instance "Brique" as "Brique 28" at 502,219 pivot 0,0 tint #ff7ab0 0.85
52 instance "Brique" as "Brique 29" at 606,219 pivot 0,0 tint #ff6b6b 0.85
53 instance "Brique" as "Brique 30" at 710,219 pivot 0,0 tint #ff9f45 0.85
54 instance "Brique" as "Brique 31" at 814,219 pivot 0,0 tint #ffd24d 0.85
55 }
56 layer "Raquette" {
57 group "Raquette" at 450,690 pivot 0,0 filter glow 12 #ffd24d {
58 layer "c" {
59 path "M-75 -11L75 -11L75 11L-75 11Z" fill linear(90, 0:#fff0a8, 1:#ff9e26)
60 path "M-65 -9L65 -9L65 -3L-65 -3Z" fill #fff opacity 0.4
61 }
62 }
63 }
64 layer "Grain" {
65 group "Grain" at 450,560 pivot 0,0 filter glow 14 #ffd86a {
66 layer "c" {
67 path "M14 0L13.88 1.83L13.52 3.62L12.93 5.36L12.12 7L11.11 8.52L9.9 9.9L8.52 11.11L7 12.12L5.36 12.93L3.62 13.52L1.83 13.88L0 14L-1.83 13.88L-3.62 13.52L-5.36 12.93L-7 12.12L-8.52 11.11L-9.9 9.9L-11.11 8.52L-12.12 7L-12.93 5.36L-13.52 3.62L-13.88 1.83L-14 0L-13.88 -1.83L-13.52 -3.62L-12.93 -5.36L-12.12 -7L-11.11 -8.52L-9.9 -9.9L-8.52 -11.11L-7 -12.12L-5.36 -12.93L-3.62 -13.52L-1.83 -13.88L0 -14L1.83 -13.88L3.62 -13.52L5.36 -12.93L7 -12.12L8.52 -11.11L9.9 -9.9L11.11 -8.52L12.12 -7L12.93 -5.36L13.52 -3.62L13.88 -1.83Z" fill radial(0.5, 0.5, 0.5, 0:#ffffff, 0.6:#ffe6a0, 1:#ffba4a)
68 }
69 }
70 }
71 layer "Indice" {
72 group "Indice" at 450,410 pivot 0,0 {
73 layer "c" {
74 text "souris ou ← → pour bouger · clic ou espace pour (re)lancer" at -340,-16 font "Geist, system-ui, \"Segoe UI\", sans-serif" size 26 align center line 1.15 color #9fb0d8 bold box 680 31.2
75 }
76 }
77 }
78 layer "Score" {
79 text "POP-CORN BREAKER" at 230,36 font "Impact, \"Arial Black\", sans-serif" size 30 align center line 1.15 color #ffd86a bold box 440 36
80 }
81 layer "Rejouer" {
82 group "Rejouer" pivot 0,0 {
83 layer "c" {
84 path "M0 0L900 0L900 760L0 760Z" fill #05040c
85 }
86 }
87 }
88}
89
90fn launch() {
91 started = 1
92 lost = 0
93 bx = px
94 by = 560
95 vx = 4.4
96 vy = -5.2
97}
98
99each "Brique" as i {
100 scaleX = bricks[i] == 1 ? 1 : (1 + (1-bricks[i])*0.6)
101 scaleY = bricks[i]
102 opacity = bricks[i]
103}
104
105every frame {
106 if (started == 0 || lost == 1) && keys.Space {
107 launch()
108 }
109 px = clamp(px + (keys.ArrowLeft ? -16 : 0) + (keys.ArrowRight ? 16 : 0) + (mouse.dx != 0 ? (mouse.x - px) : 0), 75, 825)
110 if started == 1 && lost == 0 {
111 bx = bx + vx
112 by = by + vy
113 vx = bx < 28 ? abs(vx) : (bx > 872 ? -abs(vx) : vx)
114 vy = by < 28 ? abs(vy) : vy
115 if between(by, Raquette.y - 22, Raquette.y + 10) && abs(bx - px) < 89 {
116 vy = -abs(vy)
117 vx = vx + (bx - px)*0.05
118 }
119 if by > 754 {
120 lost = 1
121 }
122 repeat i from 0 to 31 {
123 cx = 86 + (i % 8) * 104
124 cy = 105 + floor(i / 8) * 38
125 if bricks[i] == 1 && collision.boxHit(bx, by, cx, cy, 62, 29) {
126 set bricks[i] = 0
127 vy = -vy
128 score = score + 1
129 }
130 }
131 }
132}
133
134object "Raquette" {
135 x = px
136}
137
138object "Grain" {
139 x = started == 1 && lost == 0 ? bx : Raquette.x
140 y = started == 1 && lost == 0 ? by : Raquette.y - 36
141}
142
143object "Indice" {
144 opacity = started == 0 || lost == 1 ? 1 : 0
145}
146
147object "Rejouer" {
148 when clicked {
149 if started == 0 || lost == 1 {
150 launch()
151 }
152 }
153
154 opacity = started == 0 ? 0.55 : (lost == 1 ? 0.5 : 0)
155}