Skip to content

Commit

Permalink
Some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeldruck committed Jan 2, 2024
1 parent 70fc650 commit 3c850b4
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 7 deletions.
89 changes: 89 additions & 0 deletions scripts/Drawings/MapsDrawing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
export class MapDrawing extends DrawingUtils
{
constructor(Settings)
{
super(Settings);
}

interpolate(curr_map, lpX, lpY , t)
{
const hX = lpX;
const hY = -lpY;

curr_map.hX = this.lerp(curr_map.hX, hX, t);
curr_map.hY = this.lerp(curr_map.hY, hY, t);
}

Draw(ctx, curr_map)
{
//const point = this.transformPoint(curr_map.hX, curr_map.hY);

if (curr_map.id < 0)
return;

this.DrawImageMap(ctx, curr_map.hX*4, curr_map.hY*4, curr_map.id.toString(), 825*4);
}

DrawImageMap(ctx, x, y, drawTo, size)
{
if (drawTo === undefined || drawTo.toLowerCase().includes("undefined"))
return;

// Fill background => if no map image or corner not glitchy
ctx.fillStyle = '#1a1c23';
ctx.fillRect(0, 0, ctx.width, ctx.height);

if (!this.settings.settingShowMap) return;

const src = "/images/Maps/" + drawTo + ".png";

const preloadedImage = this.settings.GetPreloadedImage(src, "maps");


if (preloadedImage)
{
ctx.save();

/*
const angle = -0.7071;
let newX = x * angle - y * angle;
let newY = x * angle + y * angle;
newX *= 4;
newY *= 4;
newX += 250;
newY += 250;
return { x: newX, y: newY };
*/

/*ctx.translate(250, 250);
//ctx.translate(-newX, -newY);
//ctx.rotate(0.7071);
ctx.rotate(0.785398);
ctx.translate(-x, -y);
ctx.scale(1, -1);
ctx.drawImage(preloadedImage, -size/2, -size/2, size, size);
ctx.restore();*/

ctx.scale(1, -1);
ctx.translate(250, -250);

ctx.rotate(-0.785398);
ctx.translate(-x, y);
//ctx.translate(-x, -y);

ctx.drawImage(preloadedImage, -size/2, -size/2, size, size);
ctx.restore();
}
else
{
this.settings.preloadImageAndAddToList(src, "maps");
}
}
}
17 changes: 10 additions & 7 deletions scripts/Handlers/HarvestablesHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class HarvestablesHandler
const h = new Harvestable(id, type, tier, posX, posY, charges, size);
this.harvestableList.push(h);
//console.log("New Harvestable: " + h.toString());
} else
}
else // ???
{
this.harvestableList[index].setCharges(charges);
}
Expand All @@ -97,7 +98,9 @@ class HarvestablesHandler

}

newHarvestableObject(id, Parameters)
// Normally work with everything
// Good
newHarvestableObject(id, Parameters) // From dead monster harvestable
{
const type = Parameters[5];
const tier = Parameters[7];
Expand Down Expand Up @@ -134,14 +137,13 @@ class HarvestablesHandler
return bytes;
}

newSimpleHarvestableObject(Parameters)
// Normally work with everything
// Good
newSimpleHarvestableObject(Parameters) // Static harvestable objects
{
const a0 = Parameters[0];

if (a0.length === 0)
{
return;
}
if (a0.length === 0) return;

const a1 = Parameters[1]["data"];
const a2 = Parameters[2]["data"];
Expand Down Expand Up @@ -226,5 +228,6 @@ class HarvestablesHandler
{
return HarvestableType.Ore;
}
else return '';
}
}
12 changes: 12 additions & 0 deletions scripts/tailwind.output.css
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,18 @@ img, video {
border-color: #63b3ed
}

.space-x-1 > :not(template) ~ :not(template) {
--space-x-reverse: 0;
margin-right: calc(0.25rem*var(--space-x-reverse));
margin-left: calc(0.25rem*(1 - var(--space-x-reverse)))
}

.space-x-2 > :not(template) ~ :not(template) {
--space-x-reverse: 0;
margin-right: calc(0.50rem*var(--space-x-reverse));
margin-left: calc(0.50rem*(1 - var(--space-x-reverse)))
}

.space-y-2 > :not(template) ~ :not(template) {
--space-y-reverse: 0;
margin-top: calc(0.5rem*(1 - var(--space-y-reverse)));
Expand Down

0 comments on commit 3c850b4

Please sign in to comment.