Skip to content

Commit 7265113

Browse files
authored
Add files via upload
1 parent 73e0280 commit 7265113

File tree

6 files changed

+1845
-0
lines changed

6 files changed

+1845
-0
lines changed

Ballistic-Chickens/code/achieve.js

+203
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
scene('achievements', () => {
2+
const Z = {
3+
bg: 0,
4+
main: 100,
5+
top: 200,
6+
black: 300,
7+
};
8+
9+
var mainScroll = 0;
10+
11+
const black = add([
12+
rect(width(), height()),
13+
pos(0,0),
14+
z(Z.black),
15+
opacity(1),
16+
color(BLACK),
17+
fixed(),
18+
]);
19+
20+
for (let f = 0; f < 20; f++) {
21+
setTimeout(() => {
22+
black.opacity -= 0.05;
23+
}, f*15);
24+
};
25+
26+
let fadingOut = false;
27+
function fadeOut() {
28+
if (!fadingOut) {
29+
fadingOut = true;
30+
for (let f = 0; f < 20; f++) {
31+
setTimeout(() => {
32+
black.opacity += 0.05;
33+
}, f * FADE_TIME / 15);
34+
};
35+
};
36+
};
37+
38+
for (let j = 0; j < 2; j++) {
39+
for (let i = 0; i < [1,6][j]; i++) {
40+
let border = SCALE*0.01;
41+
let xOff = Math.sin( (Math.PI * i) /2 ) *border;
42+
let yOff = Math.cos( (Math.PI * i) /2 ) *border;
43+
if (i == 0) { xOff = 0; yOff = 0; };
44+
45+
add([
46+
text('ACHIEVEMENTS', {
47+
size: SCALE*0.87,
48+
align: 'center',
49+
font: 'burned',
50+
letterSpacing: SCALE*0.04,
51+
}),
52+
pos(width()/2 +xOff, SCALE*0.37 +yOff),
53+
origin('top'),
54+
z(Z.top +1),
55+
color(BLACK),
56+
rotate(-1.5),
57+
]);
58+
};
59+
};
60+
61+
add([
62+
rect(width(), SCALE*1.6),
63+
pos(0,0),
64+
color(rgb(240,240,240)),
65+
z(Z.top),
66+
]);
67+
68+
for (let i = 0; i < 2; i++) {
69+
add([
70+
rect(width(), SCALE*0.1),
71+
pos(0, SCALE*(1.6 + (i*0.1))),
72+
color(BLACK),
73+
opacity((2-i)*0.1),
74+
z(Z.top),
75+
]);
76+
};
77+
78+
for (let i = 0; i < 2; i++) {
79+
add([
80+
rect(width(), SCALE/15),
81+
pos(0, SCALE*(0.7*(i+1) -0.3)),
82+
color(rgb(140,170,245)),
83+
z(Z.top),
84+
])
85+
};
86+
87+
for (let i = 0; i < 4; i++) {
88+
for (let j = 0; j < 2; j++) {
89+
add([
90+
sprite('cork'),
91+
pos(center().add(0, j*SCALE*10)),
92+
scale(TILE*5),
93+
origin(['topleft', 'botleft', 'topright', 'botright'][i]),
94+
z(Z.bg),
95+
"scrollable",
96+
{
97+
startY: center().y + j*SCALE*10,
98+
}
99+
]);
100+
};
101+
};
102+
103+
add([
104+
sprite('markerHouse'),
105+
scale(TILE * 2/3),
106+
pos(SCALE/10, SCALE/10),
107+
z(Z.top),
108+
area(),
109+
rotate(3),
110+
"menu",
111+
"navButton",
112+
]);
113+
114+
115+
/*
116+
EEEEEE
117+
EEEEEEEEEEE
118+
119+
Main Content
120+
(grammar mode enabled)
121+
122+
EEEEEEEEEEE
123+
EEEEEE
124+
*/
125+
126+
let achKeys = Object.keys(ACHIEVEMENTS);
127+
let achLength = achKeys.length;
128+
129+
for (let i = 0; i < achLength; i++) {
130+
let rowMod = 8;
131+
let sy = SCALE*(2.7 + 1.1*Math.floor(i / rowMod));
132+
if (STUFF.achievements.includes(achKeys[i])) {
133+
for (let l = 0; l < 2; l++) {
134+
if (!(ACHIEVEMENTS[achKeys[i]].icon[1] == -1 && l == 0)) {
135+
add([
136+
sprite(['banner', 'achievements'][l], { frame: (ACHIEVEMENTS[achKeys[i]].icon[1-l]) }),
137+
pos(SCALE*(1.15 + 1.1*(i % rowMod)), sy),
138+
origin('center'),
139+
scale(TILE*0.8),
140+
z(Z.main + l),
141+
"scrollable",
142+
{
143+
startY: sy,
144+
}
145+
]);
146+
};
147+
};
148+
} else {
149+
add([
150+
circle(SCALE*0.2),
151+
pos(SCALE*(1.15 + 1.1*(i % rowMod)), sy),
152+
origin('center'),
153+
color(BLACK),
154+
opacity(0.15),
155+
z(Z.main),
156+
"scrollable",
157+
{
158+
startY: sy,
159+
}
160+
]);
161+
};
162+
};
163+
164+
165+
166+
167+
168+
169+
onClick('menu', (m) => {
170+
fadeOut();
171+
setTimeout(() => { go('menu'); }, FADE_TIME);
172+
});
173+
174+
let startHold = 0;
175+
let startScroll = 0;
176+
let scrollDiff = 0;
177+
let holdWait = true;
178+
179+
onUpdate(() => {
180+
if (isMouseDown()) {
181+
if (holdWait) {
182+
holdWait = false;
183+
startHold = mousePos().y / SCALE;
184+
scrollDiff = 0;
185+
startScroll = mainScroll;
186+
};
187+
188+
scrollDiff = startHold - mousePos().y / SCALE;
189+
mainScroll = Math.max(0, Math.min(2, startScroll + scrollDiff));
190+
191+
} else {
192+
holdWait = true;
193+
};
194+
195+
every('navButton', (o) => {
196+
o.scale = o.isHovering() ? vec2(TILE*0.73) : vec2(TILE*2/3);
197+
});
198+
every('scrollable', (s) => {
199+
s.pos.y = s.startY - mainScroll*SCALE;
200+
});
201+
});
202+
203+
});

0 commit comments

Comments
 (0)