Browse Source

shooting animation, highlights

pixelbath 1 year ago
parent
commit
513448ddc3
1 changed files with 34 additions and 19 deletions
  1. 34 19
      megamang/megamang.lua

+ 34 - 19
megamang/megamang.lua

@@ -11,14 +11,15 @@ x=96
 y=24
 
 local player = {
-	screenx=0,
-	screeny=0,
+	screenx=110,
+	screeny=80,
 	spr=0,
 	spr_base=256,
 	flip=0,
 	cnt_run=0,
 	cnt_fire=0,
-	frames_run={258,260,262,260}
+	frames_run={258,260,262,260},
+	frame_slide=266,
 }
 
 function BOOT()
@@ -26,36 +27,50 @@ function BOOT()
 end
 
 function update()
-	-- if btn(0) then y=y-1 end
-	-- if btn(1) then y=y+1 end
+	local is_running = false
+
 	if btn(2) then
 		player.cnt_run = player.cnt_run + 1
 		player.flip = 1
+		is_running = true
 	end
 	if btn(3) then
 		player.cnt_run = player.cnt_run + 1
 		player.flip = 0
+		is_running = true
 	end
 	if btn(4) then
-		player.cnt_fire = 30
+		player.cnt_fire = 10
 	else
 		player.cnt_fire = player.cnt_fire - 1
 	end
 
+	-- reset run counter if not pressing a button
+	if not is_running then player.cnt_run = 0 end
+
 	local spr_offset = 0
 	if player.cnt_run > 0 then
 		spr_offset = ((player.cnt_run // 6) % 4) + 1
 		player.spr = player.frames_run[spr_offset]
+	else
+		player.spr = player.spr_base
 	end
 
 	if player.cnt_fire > 0 then
-		spr_offset = 32 + spr_offset
+		player.spr = player.spr + 32
 	end
 
 end
 
 function draw_player(colorkey)
 	spr(player.spr, player.screenx, player.screeny, colorkey, 1, player.flip, 0, 2, 2)
+	if player.cnt_fire > 8 then
+		if player.flip == 1 then
+			spr(270, player.screenx, player.screeny+2, colorkey, 1, player.flip)
+		else
+			spr(270, player.screenx+8, player.screeny+2, colorkey, 1, player.flip)
+		end
+	end
 end
 
 function TIC()
@@ -86,8 +101,8 @@ end
 -- 011:5555555555555555555555555555555555555555555555550555555500005555
 -- 012:55089000550990ab5509b9bb550b99bb550bb9aa5500b99955509b9955500b99
 -- 013:00555555a00555559a0055559990555599b0555599b005559b9905559b990555
--- 014:5555555555555555555555555555555555555555555555555555555555555555
--- 015:5555555555555555555555555555555555555555555555555555555555555555
+-- 014:555555555ab555555cb5555555b555555c5555555555bc555555abc555555b55
+-- 015:5ff55555fccf5555fccf55555ff5555555555555555555555555555555555555
 -- 016:55000bbb5509b0bb5509909955099b99550000bb555009995550999955509988
 -- 017:bb000555b0b90555909905559b990555b00005559a0555559900555599a05555
 -- 018:509bbb9950990bbb509900bb5500bb995009ab9b509999095000000955555508
@@ -96,14 +111,14 @@ end
 -- 021:b0555555b005555599055555b9055555a005555590555555900555559a055555
 -- 022:5009bbb9509b0bbb509900bb50000b99009abb99099999000009900055000050
 -- 023:40055555b9905555b990555500055555bba055559990555599905555899a0555
--- 024:55500bbb555500bb5555009955550b9955550bb055009ab55509990555099805
+-- 024:55500bbb555500bb5555009955550b9955550bb055009ab05509990555099805
 -- 025:bb005555b00555559bb005559bba055509990555099905550999a05500000055
 -- 026:5099999950b999bb50b994f4550b94445000994b509bbbbb00990bb909980099
 -- 027:99a055559b9005559b990055b999a055bb99900099b999a09bb9999090089900
 -- 028:555500bb555550bb5555009955550b9955500bb0555099b05550989055508880
 -- 029:bbb90555bb005555abba05559999055508890555089905555099055550000555
--- 030:5555555555555555555555555555555555555555555555555555555555555555
--- 031:5555555555555555555555555555555555555555555555555555555555555555
+-- 030:5fff5555fcccf555fcccf5555fff555555555555555555555555555555555555
+-- 031:55ffff555f5555f5f55ff55ff5fccf5ff5fccf5ff55ff55f5f5555f555ffff55
 -- 032:55555000555500bb55500999555099995550b9995550b99455500b9455509b99
 -- 033:00555555b0055555ab00555599905555bb905555f49055554400000540009a00
 -- 034:5555555555555000555500bb55500999555099995550b9995550b99450000b94
@@ -114,24 +129,24 @@ end
 -- 039:5555555500555555b0055555ab00555599905555bb905555f490555544000005
 -- 040:55555000555500bb5000099950990999509909995099b99450099b945500bb99
 -- 041:00555555b0055555ab00555599905555bb905555f4905555440000054b009a00
--- 042:5555555555555555555555555555555555555555555555555555555555555555
--- 043:5555555555555555555555555555555555555555555555555555555555555555
+-- 042:55555000555500bb55500a99555099995550b9995550b99455500b9455550099
+-- 043:00555555b0055555ab00555599a05555bb905555349055554400555540055555
 -- 044:55099000550990bb5509bb99550bb999550b9bb955009bb95550b9bb55500b99
 -- 045:00555555b0055555ab055555990055559bb05555f490000544009a009bb999a0
--- 046:5555555555555555555555555555555555555555555555555555555555555555
+-- 046:5fffff55faafaaf5fafbfaf5faafaaf55fffff55555555555555555555555555
 -- 047:5555555555555555555555555555555555555555555555555555555555555555
 -- 048:5550bbbb555099bb555099995550bb9955509b9b550099005509990555099805
 -- 049:bbb999a0b00b990000500005bb005555bba055559990555599900555899a0555
--- 050:509bbb9950995bbb509900bb5500bb995009ab9b509999095000000955555508
+-- 050:509bbb9950990bbb509900bb5500bb995009ab9b509999095000000955555508
 -- 051:40009a00bbb999a0b000990000550005aa055555990555559900555599a05555
--- 052:55500bbb5550b5bb5550b99955509999555099bb555099995550909955500089
+-- 052:55500bbb5550b0bb5550b99955509999555099bb555099995550909955500089
 -- 053:bbb999a0b000990090550005b9055555a005555590555555900555559a055555
 -- 054:55550bb955550bbb555550bb50000b99009abb99099999000009900055000050
 -- 055:40009a00b99999a0b990990000050005bba055559990555599905555899a0555
 -- 056:55500bbb555500bb5555509955550b9955550bb055009ab05509990555099805
 -- 057:bbb999a0b00099009bb000059bba055509990555099905550999a05500000055
--- 058:5555555555555555555555555555555555555555555555555555555555555555
--- 059:5555555555555555555555555555555555555555555555555555555555555555
+-- 058:55000bbb5509b0bb5509909955099b99550000bb555009995550999955509988
+-- 059:bb000555b0b90555909905559b990555b00005559a0555559900555599a05555
 -- 060:555500bb555550bb5555009955550b9955500bb0555099b05550989055508880
 -- 061:bb009900bb000055abba05559999055508890555089905555099055550000555
 -- 062:5555555555555555555555555555555555555555555555555555555555555555