Elite?
How did you add text that shows fps?
@andymac3d - Bingo!, somewhere on a hard drive I’ve got a copy of Matthew Pinder’s Elite - A New Kind, the original GBA version that he did before it got pulled, I’d love to be able to find the code and port it to Lua.
FWIW - There is a version already on the appstore (http://www.gamerealism.se/) but the controls could do with some tweaking, I’ve love to see Frontier do the job properly #FingersCrossed
I just sold a copy of Frontier: Elite II for the Amiga on eBay. Galaxy on Fire 2 is the closest to Elite/ Frontier on iOS IMO
@Minersnation7 There’s a global variable DeltaTime
that stores how long it took to render the previous frame, and so the current frame rate can be calculated using 1 / DeltaTime
. Although, that variable can change so quickly you’ll probably need to smooth it out, with something like this:
function setup()
FPS = 60
end
function draw()
FPS = FPS * 0.9 + 0.1 / DeltaTime
print(FPS)
end
However, if you want your frames per second (more accurate than your framerate, yes there is a difference between FPS and framerate), I made this code that works pretty well, just put it in another tab and whenever you need your FPS just use the variable FPS
:
FPS = 0
local frames = 0
local time = 0
tween.delay(0, function()
local d = draw
draw = function()
frames = frames + 1
if math.floor(ElapsedTime) ~= math.floor(time) then
FPS = frames - 1
frames = 1
end
time = ElapsedTime
d()
end
end)
whats the differrence between ~draw = function()~ and ~function draw()~?
@firewolf, as @SkyTheCoder already mentioned in another thread, it’s the same, but
function draw()
is a more used syntax
EDIT: Ignatz explained it better with adresses etc
None whatsoever
When Codea creates a function, it stores it somewhere in memory and puts the address in the name of the function. A function name is actually a variable containing a member address (number).
So draw = function() ... end
is actually what happens.
function draw()
is an alternative that is easier to read, that’s all.
i understand it, function name could be changed