Skip to content

Commit c38683a

Browse files
committed
Refactor comet drawing and update difficulty multipliers
- Updated the comet drawing function to use a shared halo function for better visual consistency. - Changed difficulty multipliers to be defined in a table for easier adjustments. - Simplified the pause menu item update logic to improve readability. - Removed the controls UI file as it was no longer needed. - Adjusted HUD and menu positioning for better alignment and aesthetics. - Fixed shop display logic to ensure consistent pricing for shield upgrades. - Updated various UI elements for improved clarity and functionality.
1 parent 0ed07b2 commit c38683a

12 files changed

Lines changed: 77 additions & 135 deletions

File tree

build/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630

631631
}
632632
e.type = "application/javascript";
633-
e.src = "space_shooter.js";
633+
e.src = "space_8.js";
634634
e.id = "e_script";
635635

636636
document.body.appendChild(e); // load and run
Lines changed: 62 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

space_8.p8.png

-410 Bytes
Loading

space_shooter.p8.png

-174 Bytes
Loading

space_shooter.png

65 Bytes
Loading

src/entities/comet.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,8 @@ end
7878
function draw_comet()
7979
for c in all(comets) do
8080
if c.warning_t>0 then
81-
local cx,cy,ht=c.left and 4 or 123,c.y+4,10
82-
cy=max(cy,ht+4)
83-
local ba=(20-c.warning_t)*0.15
84-
for i=0,3 do
85-
local ang=ba+i*0.25
86-
pset(flr(cx+cos(ang)*3),flr(cy+sin(ang)*3),i%2==0 and c.c8 or c.c9)
87-
end
81+
local cx,cy=c.left and 4 or 123,max(c.y+4,14)
82+
h(cx,cy,(20-c.warning_t)*0.15,c.c8,c.c9)
8883
else
8984
local sid=c.sid
9085
if c.flash_t>0 then sid=c.use_angled and 35 or 51 end

src/game.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
game_state,prev_game_state="menu","menu"
22
-- shared small constants / helpers (token savings)
33
FT=1/30
4-
function dmul() return 0.6+0.1*df+0.1*mid(0,df-1,1) end -- difficulty cost multiplier
4+
dm=dm or split"0.7,0.8,0.9" -- difficulty multipliers (easy,normal,veteran)
5+
function dmul()return dm[df] end
56
function aabb(ax,ay,aw,ah,bx,by,bw,bh)
67
return ax<bx+bw and bx<ax+aw and ay<by+bh and by<ay+ah
78
end
@@ -57,8 +58,8 @@ function _update()
5758
update_starfield()
5859
if level_fanfare_timer>0 then level_fanfare_timer-=1 end
5960

60-
-- update pause menu item (shows current round)
61-
do local show=(game_state=="game" or game_state=="station" or game_state=="fanfare_depart") if show then menuitem(1,"round "..vr) else menuitem(1) end end
61+
-- pause menu item: show round when active
62+
if game_state=="game" or game_state=="station" or game_state=="fanfare_depart" then menuitem(1,"round "..vr) else menuitem(1) end
6263

6364
if game_state=="fanfare_depart"then
6465
if ship_departing then

src/particles.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
local p={}
33
Gp=p
44

5+
-- tiny shared halo (rotating 4-dot ring) reused by comets + powerups
6+
function h(x,y,a,c1,c2)for i=0,3 do local g=a+i*0.25 pset(flr(x+cos(g)*3),flr(y+sin(g)*3),i%2==0 and c1 or c2)end end
7+
58
function p_add(x,y,dx,dy,life,typ,col,dat) add(p,{x=x,y=y,dx=dx,dy=dy,l=life,t=typ,c=col,d=dat}) end
69

710
function p_upd()
@@ -37,7 +40,7 @@ function p_draw()
3740
if i.t==7 then
3841
local d=i.d
3942
if d==7 then pset(i.x,i.y,10)pset(i.x+1,i.y,10)pset(i.x,i.y+1,10)pset(i.x+1,i.y+1,10)
40-
else local sprid=(d==2 and 10) or (d==5 and 11) or 38 spr(sprid,i.x,i.y) end
43+
else h(i.x+2.5,i.y+2.5,time(),d==2 and 12 or d==5 and 9 or 11,d==2 and 1 or d==5 and 10 or 7) spr((d==2 and 10) or (d==5 and 11) or 38,i.x,i.y) end
4144
elseif i.t==4 and i.d then
4245
sspr(i.d[1],i.d[2],4,4,i.x,i.y)
4346
else

src/ui/controls.lua

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/ui/hud.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ function draw_hud()
2626
spr(10,58,2)
2727
local sp=ship.shield_power local fw=sp*0.2\1 if fw>0 then local r=sp/100 rectfill(65,3,64+fw,5,r>0.5 and 12 or(r>0.25 and 13 or 8)) end rect(65,3,84,5,5)
2828
if gsn~=gsx then if gsx=="game" and (gsn!="fanfare_depart" and gsn!="fanfare_arrive") then db=0 end gs=gsx end
29-
if (run or gsx=="fanfare_arrive") and mission_distance and mission_distance>0 then local t=level_fanfare_timer>0 and 1 or min(1,(mission_distance-(dr or mission_distance))/mission_distance) db=db<t and min(t,db+0.02) or(db>t and max(t,db-0.02) or db) local bx,by,bw=20,122,88 local w=db*bw rectfill(bx,by,bx+bw-1,123,1) if w>0 then rectfill(bx,by,bx+w-1,123,13) if db>0.95 then rectfill(bx+w-2,by,bx+w-1,123,flr(time()*4)%2==0 and 6 or 13) end end spr(39,111,119) end
29+
if (run or gsx=="fanfare_arrive") and mission_distance>0 then local t=level_fanfare_timer>0 and 1 or min(1,(mission_distance-(dr or mission_distance))/mission_distance) db=db<t and min(t,db+0.02) or(db>t and max(t,db-0.02) or db) local bx,by,bw=20,122,88 local w=db*bw rectfill(bx,by,bx+bw-1,123,1) if w>0 then rectfill(bx,by,bx+w-1,123,13) if db>0.95 then rectfill(bx+w-2,by,bx+w-1,123,flr(time()*4)%2==0 and 6 or 13) end end spr(39,111,119) end
3030
end

0 commit comments

Comments
 (0)