6 Commits bf943a868e ... 05a1fcbc98

Author SHA1 Message Date
  pixelbath 05a1fcbc98 Merge branch 'master' of https://git.pixelbath.com/pixelbath/tic80-stuff 5 months ago
  pixelbath 7ba5da9485 added rspr example 5 months ago
  pixelbath 7f240af941 some other shmup stuff 5 months ago
  pixelbath c25ec13bf7 Merge branch 'master' of https://git.pixelbath.com/pixelbath/tic80-stuff 5 months ago
  pixelbath cf832b6a8c ants go marching 5 months ago
  pixelbath 4a77b1b7ad more dark 5 months ago
5 changed files with 130 additions and 0 deletions
  1. 30 0
      awesome/antmarch.lua
  2. 100 0
      awesome/rspr.lua
  3. BIN
      dark/dark-v03.aseprite
  4. BIN
      shmup/mockup2.aseprite
  5. BIN
      shmup/palette.aseprite

+ 30 - 0
awesome/antmarch.lua

@@ -0,0 +1,30 @@
+-- title:   antmarch
+-- author:  _gav, pixelbath
+-- desc:    _gav found a neat (cheap) way to represent marching ants on an 8x8 tile. can be extended to larger sizes if needed
+-- script:  lua
+
+local flip_states = {0,1,3,2}
+local flip_state = flip_states[math.floor((time() / 333) % 4)+1]
+local draw_x = 0
+local draw_y = 0
+function TIC()
+
+	if btnp(0) then draw_y=draw_y-8 end
+	if btnp(1) then draw_y=draw_y+8 end
+	if btnp(2) then draw_x=draw_x-8 end
+	if btnp(3) then draw_x=draw_x+8 end
+
+	cls(13)
+	flip_state = flip_states[math.floor((time() / 333) % 4)+1]
+	spr(256, draw_x, draw_y, 0, 1, flip_state)
+end
+
+-- <SPRITES>
+-- 000:cc0ccc0cc000000c0000000cc0000000c000000cc000000c0000000cccc0ccc0
+-- 001:000c000cc000000000000000000000000000000cc00000000000000000c000c0
+-- </SPRITES>
+
+-- <PALETTE>
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
+-- </PALETTE>
+

+ 100 - 0
awesome/rspr.lua

@@ -0,0 +1,100 @@
+-- title:  rspr
+-- author: pixelbath
+-- desc:   rotate a sprite (code by ArchaicVirus)
+
+local t = 0
+vec2 = {}
+vec2_mt = {}
+vec2_mt.__index = vec2_mt
+setmetatable(vec2, { __call = function(V, x, y) return setmetatable({ x = x or 0, y = y or x or 0 }, vec2_mt) end })
+
+
+function rspr(id, x, y, colorkey, scaleX, scaleY, flip, rotate, tile_width, tile_height, pivot)
+	colorkey = colorkey or -1
+	scaleX = scaleX or 1
+	scaleY = scaleY or 1
+	flip = flip or 0
+	rotate = rotate or 0
+	tile_width = tile_width or 1
+	tile_height = tile_height or 1
+	pivot = pivot or vec2(0, 0)
+
+	-- Draw a sprite using two textured triangles.
+	-- Apply affine transformations: scale, shear, rotate, flip
+
+	-- scale / flip
+	if flip % 2 == 1 then
+		scaleX = -scaleX
+	end
+	if flip >= 2 then
+		scaleY = -scaleY
+	end
+	local ox = tile_width * 8 // 2
+	local oy = tile_height * 8 // 2
+	local ox = ox * -scaleX
+	local oy = oy * -scaleY
+
+	-- shear / rotate
+	local shx1 = 0
+	local shy1 = 0
+	local shx2 = 0
+	local shy2 = 0
+	local shx1 = shx1 * -scaleX
+	local shy1 = shy1 * -scaleY
+	local shx2 = shx2 * -scaleX
+	local shy2 = shy2 * -scaleY
+	local rr = math.rad(rotate)
+	local sa = math.sin(rr)
+	local ca = math.cos(rr)
+
+	local function rot(x, y, px, py)
+		-- Translate point to origin (pivot)
+		x, y = x - px, y - py
+		-- Rotate
+		local rx, ry = x * ca - y * sa, x * sa + y * ca
+		-- Translate back
+		return rx + px, ry + py
+	end
+
+	local rx1, ry1 = rot(ox + shx1, oy + shy1, pivot.x, pivot.y)
+	local rx2, ry2 = rot(((tile_width * 8) * scaleX) + ox + shx1, oy + shy2, pivot.x, pivot.y)
+	local rx3, ry3 = rot(ox + shx2, ((tile_height * 8) * scaleY) + oy + shy1, pivot.x, pivot.y)
+	local rx4, ry4 = rot(((tile_width * 8) * scaleX) + ox + shx2, ((tile_height * 8) * scaleY) + oy + shy2, pivot.x,
+		pivot.y)
+
+	local x1 = x + rx1 - pivot.x
+	local y1 = y + ry1 - pivot.y
+	local x2 = x + rx2 - pivot.x
+	local y2 = y + ry2 - pivot.y
+	local x3 = x + rx3 - pivot.x
+	local y3 = y + ry3 - pivot.y
+	local x4 = x + rx4 - pivot.x
+	local y4 = y + ry4 - pivot.y
+
+	-- UV coords
+	local u1 = (id % 16) * 8
+	local v1 = math.floor(id / 16) * 8
+	local u2 = u1 + tile_width * 8
+	local v2 = v1 + tile_height * 8
+    ttri(x1, y1, x2, y2, x3, y3, u1, v1, u2, v1, u1, v2, 0, colorkey)
+    ttri(x3, y3, x4, y4, x2, y2, u1, v2, u2, v2, u2, v1, 0, colorkey)
+end
+
+
+function TIC()
+    cls(0)
+    rspr(1, 100, 50, 0, 1, 1, 0, t, 2, 2)
+    t=t+1
+end
+
+-- <TILES>
+-- 001:999900009990000099000000900000000000000000000002000000220000022c
+-- 002:0000333300000333000000330000000300000000200000002200000022200000
+-- 017:00000222000000220000000200000000b0000000bb000000bbb00000bbbb0000
+-- 018:c220000022000000200000000000000000000005000000550000055500005555
+-- </TILES>
+
+-- <PALETTE>
+-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57
+-- </PALETTE>
+

BIN
dark/dark-v03.aseprite


BIN
shmup/mockup2.aseprite


BIN
shmup/palette.aseprite