Skip to content

Commit

Permalink
Update starfield.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Rukario authored Sep 22, 2024
1 parent 10c53e5 commit c9b636e
Showing 1 changed file with 88 additions and 59 deletions.
147 changes: 88 additions & 59 deletions Uninteresting stuff/starfield.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
z-index: 3;
}

#qixsatescr, #qixmobscr {
#qixsatescr, #qixmobscr, #qixprojscr {
display: none;
}

Expand Down Expand Up @@ -409,6 +409,17 @@
#0f0 20px
);
}

&.bguncher {
position: absolute;
background: repeating-linear-gradient(
45deg,
#959,
#959 10px,
#c9d 10px,
#c9d 20px
);
}
}

#hint2 {
Expand Down Expand Up @@ -3176,6 +3187,7 @@
}

const FFdown = (e_) => {
imawake();
const tooies = [0];
if (isTouch) {
tooies.length = 0;
Expand Down Expand Up @@ -3526,6 +3538,7 @@
var qixdim, qixpos, qixscr, qix_tails, qixline;
var qixsates = [];
var qixmobs = [];
var qixprojs = [];
var glyphm = newCanvas();
var glyphc = newCanvas();
var glyph_chars = 46;
Expand Down Expand Up @@ -3661,82 +3674,71 @@
};
tailscr.style.display = 'none';

while (qixsatescr.firstChild) {
qixsatescr.lastChild.remove();
}
qixsatescr.style.display = 'block';
qixsates.length = 0;

for (const n of Array(2).keys()) {
const sate = document.createElement('DIV');
sate.classList = 'hint sate';
sate.style.display = 'block';
qixsatescr.appendChild(sate);

qixsates.push({
el: sate,
size: 20,
const new_mob = (type, scr, size, c) => {
const mob = document.createElement('DIV');
mob.classList = c;
mob.style.display = 'block';
scr.appendChild(mob);

const x = Math.round(Math.random());
const y = Math.round(Math.random());
const sx = Math.floor(Math.random() * 3);
type.push({
el: mob,
size: size,
pos: {
x: Math.floor((Math.random() * qixmask.width - 2) + 2),
y: Math.floor((Math.random() * qixmask.height - 2) + 2),
},
dir: {
n: 0,
e: 0,
s: 0,
w: 0,
n: x,
e: y,
s: Math.abs(x-1),
w: Math.abs(y-1),
},
speed: {
x: 0,
y: 0,
x: sx,
y: sx ? Math.floor(Math.random() * 3) : Math.ceil(Math.random() * 2),
},
});
}

while (qixsatescr.firstChild) {
qixsatescr.lastChild.remove();
}
qixsatescr.style.display = 'block';
qixsates.length = 0;

while (qixmobscr.firstChild) {
qixmobscr.lastChild.remove();
}
qixmobscr.style.display = 'block';
qixmobs.length = 0;

while (qixprojscr.firstChild) {
qixprojscr.lastChild.remove();
}
qixprojscr.style.display = 'block';
qixprojs.length = 0;

for (const n of Array(2).keys()) {
new_mob(qixsates, qixsatescr, 20, 'hint sate');
}

//for (const n of Array(8).keys()) {
// new_mob(qixprojs, qixprojscr, 6, 'hint bguncher');
//}

clearInterval(mobspawner);
mobspawner = setInterval(() => {
if (qixmobs.length < 6) {
const zombie = document.createElement('DIV');
let size = 26;
if (Math.round(Math.random())) {
zombie.classList = 'hint mob';
size = 14;
new_mob(qixmobs, qixmobscr, 14, 'hint mob');
} else {
zombie.classList = 'hint ammo';
new_mob(qixmobs, qixmobscr, 26, 'hint ammo');
}
zombie.style.display = 'block';
qixmobscr.appendChild(zombie);

const x = Math.round(Math.random());
const y = Math.round(Math.random());
const sx = Math.floor(Math.random() * 3);
qixmobs.push({
el: zombie,
size: size,
pos: {
x: Math.floor((Math.random() * qixmask.width - 2) + 2),
y: Math.floor((Math.random() * qixmask.height - 2) + 2),
},
dir: {
n: x,
e: y,
s: Math.abs(x-1),
w: Math.abs(y-1),
},
speed: {
x: sx,
y: sx ? Math.floor(Math.random() * 3) : Math.ceil(Math.random() * 2),
},
});

//console.log(qixmobs.length, 'zombies', qixmobscr.childNodes);

//echo(qixmobs.length + ' mobs ', false);
}
}, 2500);

Expand Down Expand Up @@ -3771,6 +3773,12 @@
clipPathTail.length = 0;
}

for (const proj of qixprojs) {
draw_diamond(proj);
proj.el.style.clipPath = 'polygon(' + clipPathTail.join(',') + ')';
clipPathTail.length = 0;
}

loadcards(repaint.qix);
}

Expand Down Expand Up @@ -4071,7 +4079,7 @@
}

function qixmobstep(mob) {
const r = mob.size / 1.5;
const r = mob.size / 4;
const pos = mob.pos;
const dir = mob.dir;
const speed = Keypress.CapsLock ? {x:0, y:0} : mob.speed;
Expand Down Expand Up @@ -4425,13 +4433,29 @@
clipPathTail.length = 0;
}

for (const zombie of qixmobs) {
if (qixmobstep(zombie)) {
for (const [n, proj] of qixprojs.entries()) {
sate = qixsates[n % qixsates.length];
proj.pos.x = sate.pos.x - 12 + 8*Math.floor(n/2);
//proj.pos.y = sate.pos.y + 5 + 4*Math.floor(n/2);
proj.pos.y = sate.pos.y;
proj.speed.x = 0;
proj.speed.y = 1;
if (qixmobstep(proj)) {
gameover();
return;
}
draw_diamond(zombie);
zombie.el.style.clipPath = 'polygon(' + clipPathTail.join(',') + ')';
draw_diamond(proj);
proj.el.style.clipPath = 'polygon(' + clipPathTail.join(',') + ')';
clipPathTail.length = 0;
}

for (const mob of qixmobs) {
if (qixmobstep(mob)) {
gameover();
return;
}
draw_diamond(mob);
mob.el.style.clipPath = 'polygon(' + clipPathTail.join(',') + ')';
clipPathTail.length = 0;
}

Expand Down Expand Up @@ -4616,6 +4640,7 @@
tailscr.style.display = 'none';
qixsatescr.style.display = 'none';
qixmobscr.style.display = 'none';
qixprojscr.style.display = 'none';

glyph = false;
glyphscr.style.display = 'none';
Expand Down Expand Up @@ -4650,6 +4675,7 @@
tailscr.style.display = 'none';
qixsatescr.style.display = 'none';
qixmobscr.style.display = 'none';
qixprojscr.style.display = 'none';

glyph = false;
glyphscr.style.display = 'none';
Expand Down Expand Up @@ -4728,6 +4754,7 @@
stopscr = true;
qixsatescr.style.display = 'none';
qixmobscr.style.display = 'none';
qixprojscr.style.display = 'none';
document.body.style.backgroundColor = '#dbe';

new_glyph(true);
Expand All @@ -4740,7 +4767,7 @@
poppy.append(unlock(['Glyph (', ')'], 5));
}

poppy.append(newmenu('Options', submenu, false, options));
poppy.append(newmenu('Manual', submenu, false, options));

listener = (e) => {
e.addEventListener(tc, () => {
Expand Down Expand Up @@ -4789,6 +4816,7 @@
tailscr.style.display = 'none';
qixsatescr.style.display = 'none';
qixmobscr.style.display = 'none';
qixprojscr.style.display = 'none';

glyph = false;
glyphscr.style.display = 'none';
Expand Down Expand Up @@ -5866,6 +5894,7 @@
<div class='hintscreen'><div class='hint tail' id='tailscr'></div></div>
<div class='hintscreen' id='qixsatescr'></div>
<div class='hintscreen' id='qixmobscr'></div>
<div class='hintscreen' id='qixprojscr'></div>
<div id='result'></div>
<div id='stdout'>Output:</div>
<div class='poppy' id='poppy'></div>
Expand Down

0 comments on commit c9b636e

Please # to comment.