Browse Source

some updates

pixelbath 1 year ago
parent
commit
834269838a
4 changed files with 109 additions and 1 deletions
  1. 1 1
      _setup-folder.bat
  2. 31 0
      awesome/fsm.lua
  3. 5 0
      awesome/screenmelt.lua
  4. 72 0
      survivor/survivor.lua

+ 1 - 1
_setup-folder.bat

@@ -1,7 +1,7 @@
 @echo off
 REM this will link the TIC-80\repo folder to this folder (wherever this is).
 
-fsutil reparsepoint query %APPDATA%\com.nesbox.tic\TIC-80\repo | find "Symbolic Link" >nul && goto :doneNoAction || mklink /D %APPDATA%\com.nesbox.tic\TIC-80\repo  .
+fsutil reparsepoint query %APPDATA%\com.nesbox.tic\TIC-80\repo | find "Symbolic Link" >nul && goto :doneNoAction || mklink /D %APPDATA%\com.nesbox.tic\TIC-80\repo %CD%
 
 :doneAction
 echo Link created. Access /repo in TIC-80 to view these repository files.

+ 31 - 0
awesome/fsm.lua

@@ -0,0 +1,31 @@
+-- title:  fsm
+-- author: pixelbath
+-- desc:   test implementation of the barest-bones finite state machine
+
+local t = 0
+local state_update = nil
+
+function state1_update()
+    print("state1_update()", 0, 16)
+    if btnp(4) then
+        state_update = state2_update
+    end
+end
+
+function state2_update()
+    print("state2_update()", 0, 16)
+    if btnp(4) then
+        state_update = state1_update
+    end
+end
+
+state_update = state1_update
+
+function TIC()
+    cls(0)
+    state_update()
+end
+
+-- <PALETTE>
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
+-- </PALETTE>

+ 5 - 0
awesome/screenmelt.lua

@@ -13,3 +13,8 @@ function TIC()
 		end
 	end
 end
+
+-- <PALETTE>
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
+-- </PALETTE>
+

+ 72 - 0
survivor/survivor.lua

@@ -0,0 +1,72 @@
+-- title:  survivor
+-- author: pixelbath
+-- desc:   a game where you try not to die
+
+local t = 0
+
+local p = {
+    x = 120, y = 68, hp = 1000,
+}
+local cam = {
+    x = 120, y = 68,
+}
+local enemies = {}
+local drops = {}
+function add_drop(x, y, t)
+    table.insert(enemies, {
+        x = x, y = y, type = t, dc = 0.25,
+    })
+end
+
+function spawn_enemy(x, y)
+    table.insert(enemies, {x=x, y=y,})
+end
+
+function kill_enemy(en)
+    -- TODO: check drop chance
+    if math.random() > en.dc then
+        add_drop(en.x, en.y, 0)
+    end
+    table.remove(enemies, en)
+end
+
+function draw_player()
+    rect(p.x + cam.x, p.y + cam.y, 8, 8, 5)
+end
+
+-- also update here to save a loop
+function draw_enemies()
+    for k, en in ipairs(enemies) do
+        rect(en.x, en.y, 8, 8, 3)
+
+        if en.x > p.x and en.x < p.x + 8 and en.y > p.y and en.y < p.y + 8 then
+            p.hp = p.hp - 1
+        else
+            -- TODO: trig
+            en.x = en.x
+        end
+    end
+end
+
+for i=1,30 do
+    spawn_enemy(i * 20, 80)
+end
+
+function TIC()
+    if btn(0) then p.y = p.y - 1 end
+    if btn(1) then p.y = p.y + 1 end
+    if btn(2) then p.x = p.x - 1 end
+    if btn(3) then p.x = p.x + 1 end
+    cam.x = 120 - p.x
+    cam.y = 68 - p.y
+
+    cls(0)
+    draw_player()
+    draw_enemies()
+
+    print("hp: "..p.hp)
+end
+
+-- <PALETTE>
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
+-- </PALETTE>