Skip to content

Commit 7b345fc

Browse files
committed
re-scaled UI
1 parent da993a2 commit 7b345fc

3 files changed

Lines changed: 83 additions & 15 deletions

File tree

UI/AbilitySlot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AbilitySlot extends UIElement
1313
if(this.ability!=null)
1414
{
1515
UIRenderer.drawGauge(ctx,
16-
this.hitbox.x+6,this.hitbox.y+6,24,this.hitbox.height-8,
16+
this.hitbox.x+10,this.hitbox.y+10,24,this.hitbox.height-16,
1717
Math.floor(this.ability.charge),this.ability.maxcharge,
1818
"0 255 50");
1919
}

UI/Renderer.js

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,95 @@ class UIRenderer
77

88
static drawGauge(ctx, x, y,w,h, filled, total, colour)
99
{
10-
let empy ="100 100 100";
11-
let outline = "120 40 0";
12-
let step = Math.floor(h/total);
13-
let spacing = 1;
10+
11+
let empy ="100 100 100";
12+
let empylight ="200 200 200";
13+
let outline = "120 40 0";
14+
let step = Math.floor(h/total);
15+
let shift = h % step;
16+
let spacing = 2;
17+
if(step>=8)
18+
{
1419
for(let i = 0; i<total;i++)
1520
{
1621
ctx.beginPath();
17-
ctx.roundRect(x+0.5,y+0.5+step*i, w-1,step-1-spacing,2);
18-
ctx.lineWidth=1;
22+
ctx.lineWidth=2;
1923
ctx.strokeStyle=this.rgb(outline);
2024
if(i<(total-filled))
21-
{
25+
{
26+
ctx.roundRect(x+0,y+0+shift+step*i, w-1,step-1-spacing,3);
27+
ctx.fillStyle=this.rgb(empylight);
28+
ctx.fill();
29+
ctx.beginPath();
30+
ctx.roundRect(x+0+1,y+0+1+shift+step*i, w-1-1,step-1-spacing-1,3);
2231
ctx.fillStyle=this.rgb(empy);
32+
ctx.fill();
2333
}
2434
else
25-
{
35+
{
36+
ctx.roundRect(x+0,y+0+shift+step*i, w-1,step-1-spacing,3);
2637
ctx.fillStyle=this.rgb(colour);
38+
ctx.fill();
2739
}
28-
ctx.fill();
40+
ctx.beginPath();
41+
ctx.roundRect(x+0,y+0+shift+step*i, w-1,step-1-spacing,3);
2942
ctx.stroke();
3043
}
44+
}
45+
else
46+
{
47+
const fillPercent = filled/total;
48+
const hempty=(1-fillPercent)*(h-1);
49+
const hfull=fillPercent*(h-1);
50+
ctx.fillStyle=this.rgb(colour);
51+
ctx.beginPath();
52+
ctx.roundRect(x+1,y+1,w-1,h-2,2);
53+
ctx.fill();
54+
ctx.fillStyle=this.rgb(empy);
55+
ctx.beginPath();
56+
ctx.roundRect(x+1, y+1,w-1,hempty,2);
57+
ctx.fill();
58+
ctx.beginPath();
59+
60+
61+
ctx.lineWidth=2;
62+
ctx.strokeStyle=this.rgb(outline);
63+
ctx.roundRect(x+0,y+0, w-1,h-1,2);
64+
ctx.stroke();
65+
66+
if(step>4)
67+
{
68+
for(let i = 1; i<total;i++)
69+
{
70+
ctx.beginPath();
71+
//ctx.roundRect(x+0.5,y+0.5+step*i, w-1,step-1-spacing,2);
72+
ctx.moveTo(x+0,y+0+step*i);
73+
ctx.lineTo(x+0+w-1,y+0+step*i);
74+
75+
ctx.lineWidth=2;
76+
ctx.strokeStyle=this.rgb(outline);
77+
78+
ctx.stroke();
79+
}
80+
81+
}
82+
else if(step>1)
83+
{
84+
for(let i = 1; i<total;i++)
85+
{
86+
ctx.beginPath();
87+
//ctx.roundRect(x+0.5,y+0.5+step*i, w-1,step-1-spacing,2);
88+
ctx.moveTo(x+0.5,y+0.5+step*i);
89+
ctx.lineTo(x+0.5+w-1,y+0.5+step*i);
90+
91+
ctx.lineWidth=1;
92+
ctx.strokeStyle=this.rgb(outline);
93+
94+
ctx.stroke();
95+
}
96+
97+
}
98+
}
3199

32100
}
33101

@@ -41,10 +109,10 @@ class UIRenderer
41109
ctx.fillStyle=this.rgb(main);
42110
ctx.fill();
43111
ctx.strokeStyle=this.rgb(outline);
44-
ctx.lineWidth=5;
112+
ctx.lineWidth=9;
45113
ctx.stroke();
46114
ctx.strokeStyle=this.rgb(outline2);
47-
ctx.lineWidth=3;
115+
ctx.lineWidth=5;
48116
ctx.stroke();
49117

50118
}
@@ -62,10 +130,10 @@ class UIRenderer
62130
ctx.fillStyle=this.rgb(bottom);
63131
ctx.fill();
64132
ctx.strokeStyle=this.rgb(outline);
65-
ctx.lineWidth=5;
133+
ctx.lineWidth=9;
66134
ctx.stroke();
67135
ctx.strokeStyle=this.rgb(outline2);
68-
ctx.lineWidth=3;
136+
ctx.lineWidth=5;
69137
ctx.stroke();
70138
ctx.beginPath();
71139
ctx.roundRect(x+2.5,y-2,w-5,h-3,5);

scenes/Dash.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class GameSceneDash extends GameScene
2828
lazor.base_recharge=1;
2929
lazor.apply=()=>this.player.doSkill();
3030
this.player.abilities.push(lazor);
31-
const bt = new AbilitySlot(new Rectangle(0,this.longSide-100,70,70),lazor);
31+
const bt = new AbilitySlot(new Rectangle(10,this.longSide-100,70,72),lazor);
3232
this.uimgr.components.push(bt);
3333
}
3434
addObject(obj)

0 commit comments

Comments
 (0)