Language: lua
curves = {}
function PredictBird()
-- feos, 2014
-- draws birds trajectories
-- color marks direction
for slot = 0, 7 do
if (memory.readbyte(0x400 + slot) ~= 11) or (memory.readbyte(0x498 + slot) == 0) then
curves.slot = nil
else
if (curves.slot == nil) then curves.slot = {} end
local ryuY = memory.readbyte(0x8A)
local ryuX = memory.readbyte(0x86)
local birdY = memory.readbyte(0x480 + slot)
local birdX = memory.readbyte(0x460 + slot) + memory.readbyte(0x458 + slot)/256
local birdSpeed = memory.readbytesigned(0x450 + slot) + memory.readbyte(0x448 + slot)/256
local newY = 0
local newX = 0
local newSpeed = 0
while (#curves.slot <= 200) do
if (#curves.slot == 0) then
if (birdY > ryuY)
then newY = birdY - 1
else newY = birdY + 1
end
if (birdX > ryuX)
then newSpeed = birdSpeed - 16/256
else newSpeed = birdSpeed + 16/256
end
newX = birdX + newSpeed
else
local index = #curves.slot
local tempY = curves.slot[index].oldY
local tempX = curves.slot[index].oldX
local tempSpeed = curves.slot[index].oldSpeed
if (tempY > ryuY)
then newY = tempY - 1
else newY = tempY + 1
end
if (tempX > ryuX)
then newSpeed = tempSpeed - 16/256
else newSpeed = tempSpeed + 16/256
end
newX = tempX + newSpeed
end
table.insert(curves.slot, {oldY = newY, oldX = newX, oldSpeed = newSpeed})
end
if (#curves.slot == 200) then table.remove(curves.slot, 1) end
for index = 1, #curves.slot do
local color = nil
if (curves.slot[index].oldSpeed < 0) then color = "#008800" else color = "#0000ff" end
gui.box (curves.slot[index].oldX - 1, curves.slot[index].oldY - 1,
curves.slot[index].oldX + 1, curves.slot[index].oldY + 1, color)
end
for index = 1, #curves.slot do
gui.pixel(curves.slot[index].oldX, curves.slot[index].oldY, "white")
end
end
end
end