Browse Source

start more stuff that i won't finish

pixelbath 8 months ago
parent
commit
f71e9072bf
1 changed files with 89 additions and 0 deletions
  1. 89 0
      cylshooter/main.lua

+ 89 - 0
cylshooter/main.lua

@@ -0,0 +1,89 @@
+-- title:   cylshooter
+-- author:  pixelbath
+-- desc:    short description
+-- site:    website link
+-- license: MIT License (change this to your license of choice)
+-- version: 0.1
+-- script:  lua
+
+
+-- The idea:
+-- like Resogun, a cylindrical shooter
+-- 1. render map
+-- 2. fix column-by-column, raycast style
+-- 3. how to draw background?
+
+-- 1. render bg map offscreen
+-- 2. memcpy to onscreen
+-- 3. render fg map offscreen
+-- 4. memcpy/pix the fg to the screen?
+
+
+
+local world = {}
+local entities = {}
+
+local player = {
+    x=0, y=0,
+    vx=0, vy=0,
+    speed=1.5,
+}
+
+function player:update()
+	self.vx = 0
+	self.vy = 0
+	if btn(0) then
+		self.vy=-self.speed
+	end
+	if btn(1) then
+		self.vy=self.speed
+	end
+	if btn(2) then
+		self.vx=-self.speed
+	end
+	if btn(3) then
+		self.vx=self.speed
+	end
+
+	-- slow down diagonal movements
+	if self.vx * self.vy ~= 0 then
+		self.vx = self.vx * 0.707
+		self.vy = self.vy * 0.707
+	end
+
+	self.x = self.x + self.vx
+	self.y = self.y + self.vy
+end
+
+function player:draw()
+    rect(self.x, self.y, 8, 8, 4)
+end
+
+function world:add_entity(en)
+    table.insert(entities, en)
+end
+
+function world:update()
+	for key,val in ipairs(entities) do
+        entities[key]:update()
+    end
+end
+
+function world:draw()
+	for key,val in ipairs(entities) do
+        entities[key]:draw()
+    end
+end
+
+world:add_entity(player)
+
+function TIC()
+    cls()
+    world:update()
+    world:draw()
+end
+
+-- <PALETTE>
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
+-- </PALETTE>
+