Ok... I think I'm too dumb to make my code work with animated gif :v
If someone makes it work, he'll be given a virtual cookie.
Code: Select all
local colliders = loadSharedAPI("colliders")
local rng = loadSharedAPI("rng")
local encrypt = loadSharedAPI("encrypt")
xData = encrypt.Data(Data.DATA_WORLD,true)
intro = false
local hurt = 0
local time = 100
local Aura = 0
local showInstruction = 0
------------------------------------------------------------------------------------------
local star_gfx = Graphics.loadImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\star.png")
local hp_gfx = Graphics.loadImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\hp.png")
local coin_gfx = Graphics.loadImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\coin.png")
local life_gfx = Graphics.loadImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\1up.png")
local ssj0 = Graphics.loadAnimatedImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\ssj 0.gif")
local ssj1 = Graphics.loadAnimatedImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\ssj 1.gif")
local ssj2 = Graphics.loadAnimatedImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\ssj 2.gif")
local ssj3 = Graphics.loadAnimatedImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\ssj 3.gif")
local ssj_blue = Graphics.loadAnimatedImage(getSMBXPath().."\\worlds\\The Seven Stars (by DeMuZ)\\hud gfx\\ssj 4.gif")
------------------------------------------------------------------------------------------
if xData:get("coins") == nil then
xData:set("coins",0)
xData:save()
end
if xData:get("Max_hp") == nil then
xData:set("Max_hp",5)
xData:save()
end
if xData:get("world") == nil then
xData:set("world",1)
xData:save()
end
if xData:get("aura") == nil then
xData:set("aura",0)
xData:save()
end
------------------------------------------------------------------------------------------
local max_hp = xData:get("Max_hp")
------------------------------------------------------------------------------------------
function onTick()
max_hp = xData:get("Max_hp")
--all the forms
if xData:get("hp") > max_hp*2/3 then
aura()
else
Aura = 0
if player.altJumpKeyPressing == true then
player.altJumpKeyPressing = false
player.jumpKeyPressing = true
end
Defines.jumpheight = 16
Defines.jumpheight_bounce = 16
Defines.player_runspeed = 5
Defines.player_walkspeed = 2.5
end
--hp_system_core
HP()
if Level.filename() == "intro.lvl" then
if intro == true then
player.speedX = 0
player.speedY = 0
player.jumpKeyPressing = false
player.altJumpKeyPressing = false
end
end
if Level.filename() ~= "intro.lvl" then
--hp
Graphics.drawImage(hp_gfx,8,64)
Text.print(xData:get("hp").."/"..max_hp,32,64)
--lives
Graphics.drawImage(life_gfx,8,44)
Text.print(mem(0x00B2C5AC,FIELD_FLOAT),32,44)
--coins
coins()
--stars
if mem(0x00B251E0,FIELD_WORD) > 0 then
Graphics.drawImage(star_gfx,8,84)
Text.print(mem(0x00B251E0,FIELD_WORD).."/7",32,84)
end
end
end
------------------------------------------------------------------------------------------
Graphics.activateHud(false)
------------------------------------------------------------------------------------------
function aura()
local X1 = player.x - 12
local Y1 = player.y - 12
if Aura < 0 then
Aura = 0
end
function onKeyboardPress(key)
--instruction
if key == VK_TAB then
showInstruction = 100
end
--power up!!!
if key == VK_SPACE then
if Aura < (xData:get("aura")+1)*20 then
Aura = Aura + 1
end
else
if Aura < 20 then
Aura = 0
elseif Aura < 40 then
Aura = 20
elseif Aura < 60 then
Aura = 40
elseif Aura < 80 then
Aura = 60
elseif Aura < 100 then
Aura = 80
end
end
end
--power down!!!
if player.altRunKeyPressing then
Aura = 0
end
--instruction
if showInstruction > 0 then
Text.print("Hold (Space) to power up.",8,556)
Text.print("Press (Tanooki) to power down.",8,576)
showInstruction = showInstruction - 1
else
Text.print("(TAB)",8,576)
end
--base form
if Aura < 20 then
if player.altJumpKeyPressing == true then
player.altJumpKeyPressing = false
player.jumpKeyPressing = true
end
Defines.jumpheight = 16
Defines.jumpheight_bounce = 16
Defines.player_runspeed = 5
Defines.player_walkspeed = 2.5
end
--full potential base form
if Aura >= 20 and Aura < 40 then
for i = 1, 3 do
frame = ssj0[i]
Graphics.drawImageToSceneWP(frame, X1, Y1, 5)
end
Defines.jumpheight = 20
Defines.jumpheight_bounce = 20
Defines.player_runspeed = 6
Defines.player_walkspeed = 3
end
--super saiyan form (ssj)
if Aura >= 40 and Aura < 60 and xData:get("aura") > 0 then
for i = 1, 3 do
frame = ssj1[i]
Graphics.drawImageToSceneWP(frame, X1, Y1, 5)
end
player.powerup = PLAYER_FIREFLOWER
Defines.jumpheight = 24
Defines.jumpheight_bounce = 24
Defines.player_runspeed = 7
Defines.player_walkspeed = 3.5
end
--ascended super saiyan form (ssj2)
if Aura >= 60 and Aura < 80 and xData:get("aura") > 1 then
for i = 1, 3 do
frame = ssj2[i]
Graphics.drawImageToSceneWP(frame, X1, Y1, 5)
end
Defines.jumpheight = 28
Defines.jumpheight_bounce = 28
Defines.player_runspeed = 8
Defines.player_walkspeed = 4
end
--final super saiyan form (ssj3)
if Aura >= 80 and Aura < 100 and xData:get("aura") > 2 then
for i = 1, 3 do
frame = ssj3[i]
Graphics.drawImageToSceneWP(frame, X1, Y1, 5)
end
Defines.jumpheight = 32
Defines.jumpheight_bounce = 32
Defines.player_runspeed = 9
Defines.player_walkspeed = 4.5
end
--super saiyan blue (ssjb)
if Aura >= 100 and xData:get("aura") > 3 then
for i = 1, 3 do
frame = ssj_blue[i]
Graphics.drawImageToSceneWP(frame, X1, Y1, 5)
end
Defines.jumpheight = 36
Defines.jumpheight_bounce = 36
Defines.player_runspeed = 8
Defines.player_walkspeed = 4
end
end
------------------------------------------------------------------------------------------
function coins()
if mem(0x00B2C5A8,FIELD_WORD) > 0 then
xData:set("coins",xData:get("coins")+1)
mem(0x00B2C5A8,FIELD_WORD,mem(0x00B2C5A8,FIELD_WORD)-1)
end
Graphics.drawImage(coin_gfx,8,24)
Text.print(xData:get("coins"),32,24)
end
------------------------------------------------------------------------------------------
function onExitLevel()
xData:save()
end
---------------------------------------------------------------------------------
function onEvent(name)
if name == "checkpoint" and xData:get("hp") < max_hp and time == 0 then
xData:set("hp", xData:get("hp")+1)
xData:save()
end
if name == "exit1" then
xData:set("world",2)
xData:save()
end
intro = false
if name == "START" then
intro = true
end
--SHOP!!!
if name == "SHOP mushroom" and xData:get("coins") >= 200 and xData:get("hp") < max_hp then
xData:set("hp", xData:get("hp")+1)
xData:set("coins", xData:get("coins")-200)
xData:save()
end
if name == "SHOP 1up" and xData:get("coins") >= 300 then
mem(0x00B2C5AC,FIELD_FLOAT, mem(0x00B2C5AC,FIELD_FLOAT)+1)
xData:set("coins", xData:get("coins")-300)
xData:save()
end
if name == "SHOP max_hp 6" and xData:get("coins") >= 1000 and xData:get("Max_hp") < 6 then
xData:set("Max_hp", 6)
xData:set("coins", xData:get("coins")-1000)
xData:save()
end
end
---------------------------------------------------------------------------------
function onStart()
if Level.filename() == "intro.lvl" then
xData:set("coins",0)
xData:set("hp",1)
xData:set("Max_hp",5)
xData:set("world",1)
xData:set("aura",0)
xData:save()
end
if xData:get("hp") == nil or xData:get("hp") == 0 then
xData:set("hp",1)
xData:save()
end
if xData:get("world") > 1 then
triggerEvent("warp1")
end
end
---------------------------------------------------------------------------------
function onNPCKill(eventObj, npcObj, npcKillReason)
if xData:get("hp") < max_hp and npcObj.id == 9 and npcKillReason == 9 then
xData:set("hp", xData:get("hp")+1)
xData:save()
end
if npcObj.id == 184 and npcKillReason == 9 then
xData:set("hp", max_hp)
xData:save()
end
end
--<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
function HP()
if time > 0 then
time = time - 1
end
if player.powerup ~= PLAYER_SMALL and xData:get("hp") == 1 then
player.powerup = PLAYER_SMALL
player:mem(0x122,FIELD_WORD,12)
end
if player.powerup == PLAYER_HAMMER then
player.powerup = PLAYER_BIG
end
if player:mem(0x158, FIELD_WORD) == 9 then
player:mem(0x158, FIELD_WORD,0)
end
if player:mem(0x13E, FIELD_WORD) > 0 and hurt == 0 then
xData:set("hp",0)
xData:save()
end
if hurt == 0 then
if player:mem(0x122, FIELD_WORD) == 2 then
xData:set("hp", xData:get("hp")-1)
xData:save()
hurt = 1
end
end
if player:mem(0x122, FIELD_WORD) ~= 2 and hurt > 0 then
hurt = 0
end
if xData:get("hp") > 1 and player.powerup == PLAYER_SMALL then
player.powerup = PLAYER_BIG
player:mem(0x122,FIELD_WORD,12)
end
end