Remove extra advance frame calls which were causing stutter
This commit is contained in:
parent
2751f90884
commit
b93a52af65
4 changed files with 55 additions and 30 deletions
|
@ -14,9 +14,10 @@ _M.PoolDir = _M.ScriptDir .. "/pool/"
|
|||
--]]
|
||||
_M.State = {
|
||||
"PiratePanic.lsmv",
|
||||
"PiratePanicDitch.lsmv",
|
||||
}
|
||||
|
||||
_M.Filename = _M.PoolDir .. _M.State[1]
|
||||
_M.Filename = _M.PoolDir .. _M.State[2]
|
||||
|
||||
--[[
|
||||
Start game with specific powerup.
|
||||
|
|
67
game.lua
67
game.lua
|
@ -15,6 +15,7 @@ TILEDATA_POINTER = 0x7e0098
|
|||
HAVE_BOTH = 0x7e08c2
|
||||
CAMERA_X = 0x7e17ba
|
||||
CAMERA_Y = 0x7e17c0
|
||||
LEAD_CHAR = 0x7e08a4
|
||||
PARTY_X = 0x7e0a2a
|
||||
PARTY_Y = 0x7e0a2c
|
||||
SOLID_LESS_THAN = 0x7e00a0
|
||||
|
@ -62,7 +63,8 @@ end
|
|||
|
||||
function _M.getBoth()
|
||||
-- FIXME consider invincibility barrels
|
||||
return bit.band(memory.readword(HAVE_BOTH), 0x40)
|
||||
local both = memory.readword(HAVE_BOTH)
|
||||
return bit.band(both, 0x4000)
|
||||
end
|
||||
|
||||
function _M.writePowerup(powerup)
|
||||
|
@ -180,28 +182,47 @@ function _M.getTile(dx, dy)
|
|||
return 1
|
||||
end
|
||||
|
||||
function _M.getJumpHeight()
|
||||
local leader = memory.readword(LEAD_CHAR)
|
||||
local sprite = _M.getSprite(leader)
|
||||
return sprite.jumpHeight
|
||||
end
|
||||
|
||||
function _M.getSprite(idx)
|
||||
local base_addr = idx * 94 + SPRITE_BASE
|
||||
|
||||
local control = memory.readword(base_addr)
|
||||
|
||||
if control == 0 then
|
||||
return nil
|
||||
end
|
||||
|
||||
local x = memory.readword(base_addr + 0x06)
|
||||
local y = memory.readword(base_addr + 0x0a)
|
||||
local sprite = {
|
||||
control = control,
|
||||
screenX = x - 256 - cameraX - 256,
|
||||
screenY = y - 256 - cameraY - 256,
|
||||
jumpHeight = memory.readword(base_addr + 0x0e),
|
||||
x = x,
|
||||
y = y,
|
||||
good = spritelist.Sprites[control]
|
||||
}
|
||||
|
||||
if sprite.good == nil then
|
||||
sprite.good = -1
|
||||
end
|
||||
|
||||
return sprite
|
||||
end
|
||||
|
||||
function _M.getSprites()
|
||||
local sprites = {}
|
||||
for idx = 2,22,1 do
|
||||
local base_addr = idx * 94 + SPRITE_BASE
|
||||
|
||||
local control = memory.readword(base_addr)
|
||||
if control == 0 then
|
||||
local sprite = _M.getSprite(idx)
|
||||
if sprite == nil then
|
||||
goto continue
|
||||
end
|
||||
local x = memory.readword(base_addr + 0x06)
|
||||
local y = memory.readword(base_addr + 0x0a)
|
||||
local sprite = {
|
||||
screenX = x - 256 - cameraX - 256,
|
||||
screenY = y - 256 - cameraY - 256,
|
||||
x = x,
|
||||
y = y,
|
||||
good = spritelist.Sprites[control]
|
||||
}
|
||||
|
||||
if sprite.good == nil then
|
||||
sprite.good = -1
|
||||
end
|
||||
|
||||
sprites[#sprites+1] = sprite
|
||||
::continue::
|
||||
|
@ -272,8 +293,14 @@ function _M.getInputs()
|
|||
inputDeltaDistance[#inputDeltaDistance+1] = 1
|
||||
|
||||
tile = _M.getTile(dx, dy)
|
||||
if tile == 1 --[[and partyY+dy < 0x1B0]] then
|
||||
inputs[#inputs] = 1
|
||||
if tile == 1 then
|
||||
if _M.getTile(dx, dy-1) == 1 then
|
||||
inputs[#inputs] = -1
|
||||
else
|
||||
inputs[#inputs] = 1
|
||||
end
|
||||
elseif tile == 0 and _M.getTile(dx + 1, dy) == 1 and _M.getTile(dx + 1, dy - 1) == 1 then
|
||||
inputs[#inputs] = -1
|
||||
end
|
||||
|
||||
for i = 1,#sprites do
|
||||
|
|
|
@ -9,6 +9,7 @@ mathFunctions = dofile(base.."/mathFunctions.lua")
|
|||
util = dofile(base.."/util.lua")
|
||||
|
||||
kong = 0
|
||||
lastBoth = 0
|
||||
form = nil
|
||||
netPicture = nil
|
||||
runInitialized = {}
|
||||
|
@ -734,9 +735,7 @@ end
|
|||
function mainLoop (species, genome)
|
||||
advanceFrame(function()
|
||||
if not config.Running then
|
||||
advanceFrame(function()
|
||||
mainLoop(species, genome)
|
||||
end)
|
||||
mainLoop(species, genome)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -793,7 +792,7 @@ function mainLoop (species, genome)
|
|||
-- FIXME Measure distance to target / area exit
|
||||
-- We might not always be horizontal
|
||||
|
||||
local hitTimer = game.getHitTimer(powerUpBefore)
|
||||
local hitTimer = game.getHitTimer(lastBoth)
|
||||
|
||||
if hitTimer > 0 then
|
||||
partyHitCounter = partyHitCounter + 1
|
||||
|
@ -801,6 +800,7 @@ function mainLoop (species, genome)
|
|||
end
|
||||
|
||||
powerUp = game.getBoth()
|
||||
lastBoth = powerUp
|
||||
if powerUp > 0 then
|
||||
if powerUp ~= powerUpBefore then
|
||||
powerUpCounter = powerUpCounter+1
|
||||
|
@ -838,7 +838,7 @@ function mainLoop (species, genome)
|
|||
end
|
||||
|
||||
|
||||
local fitness = bananaCoinsFitness - hitPenalty + powerUpBonus + most
|
||||
local fitness = bananaCoinsFitness - hitPenalty + powerUpBonus + most + game.getJumpHeight()
|
||||
|
||||
if startLives < lives then
|
||||
local ExtraLiveBonus = (lives - startLives)*1000
|
||||
|
@ -873,11 +873,8 @@ function mainLoop (species, genome)
|
|||
return
|
||||
end
|
||||
|
||||
advanceFrame(function()
|
||||
mainLoop(species, genome)
|
||||
end)
|
||||
mainLoop(species, genome)
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
function writeFile(filename)
|
||||
|
|
BIN
pool/PiratePanicDitch.lsmv
Normal file
BIN
pool/PiratePanicDitch.lsmv
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue