i want to figure out a way to do some blurring after the text has been added... but yet have seen any code or any reference on how to do it... i dont know, i just want to have some fun and use this as a tool on how to learn more of LUA.... With my (very very) limited programming experience (mainly PHP CSS and HTML) its not too hard to figure out things like syntax etc...
my only issues with LUA at this point in time are the things i just dont know... but i'm learning as i go, so it cant be all that bad.... >_>;
btw, im trying to figure out FPS (or iterations persecond...)
and my current code for it is as such
clock = Timer.new(0)
currenttime = clock:time()
fpscurrent = iter (iterations) / currenttime * 100
now im getting ~ 6FPS using waitforVsync within the same loop as screen:flip() but if i remove it, i boost my FPS to about 15FPS... (depending of course on number of organisms...) at 1500 organisms im getting 6.5-6.6~ FPS with the waitforVsync outside the loop... also runs very smooth...
I notice i dont get over ~ 15.5 FPS even with a single organism...
who knows...
btw revised code follows...
Code: Select all
-- Demonstration No-User-App
-- Author: RanDom_ErrOr
-- Copyright 2006
-- No liscense with this product what so ever. Use at your own risk. I will accept no liability or responsibility if you **** something up.
System.usbDiskModeActivate()
clock = {}
clock = Timer.new(0)
screenwidth = 482
screenheight = 274
organisms =1500
letter = "o"
black = Color.new(0,0,0)
red = Color.new (255,0,0)
white = Color.new(255,255,255)
canvas = Image.createEmpty(480,272)
canvas:clear(black)
screennum = 0
organism = { }
color = { }
iter = 1
fpscurrent = 1
speed = 5
function shadow(x, y, text, c1, c2)
screen:print(x - 1, y, text, c2)
screen:print(x, y - 1, text, c2)
screen:print(x + 1, y, text, c2)
screen:print(x + 1, y + 1, text, c2)
screen:print(x + 1, y - 1, text, c2)
screen:print(x + 2, y, text, c2)
screen:print(x, y + 1, text, c2)
screen:print(x, y, text, c1)
screen:print(x + 1, y, text, c1)
end
white = Color.new(255,255,255)
math.randomseed(os.time() )
for i=1,organisms do
color[i] = {color = Color.new(math.random(0,255), math.random(0,255), math.random(0,255)) }
organism[i] = {posx = math.random(1,480), posy = math.random(1,272) }
end
while true do
pad = Controls.read()
if pad:up() then
speed = speed + 1
if speed >= 15 then
speed = 15
end
end
if pad:down() then
speed = speed - 1
if speed <= 1 then
speed = 1
end
end
if pad:start() then
break
end
if pad:triangle() then
screen:blit(-1,-1,canvas)
screen.flip()
screen:save("screenshot".. screennum..".png")
screennum = screennum + 1
end
if pad:r() and pad:l() then
canvas:clear(black)
iter = 1
end
for i=1,organisms do
x = organism[i].posx
y = organism[i].posy
canvas:print(x,y,letter,color[i].color)
organism[i].posx = organism[i].posx + math.random(-speed,speed)
organism[i].posy = organism[i].posy + math.random(-speed,speed)
if organism[i].posx >= screenwidth or organism[i].posx <= 0 then
organism[i].posx = math.random(1,480)
end
if organism[i].posy >= screenheight or organism[i].posy <= 0 then
organism[i].posy = math.random(1,272)
end
end
screen:clear()
screen:blit(-1,-1,canvas)
shadow(2, 262, "Step: " .. iter, black, white)
currenttime = clock:time()
fpscurrent = iter / currenttime * 100
shadow(2,2,"Frames Per Second: " .. fpscurrent,red, white)
shadow(2,11, "Speed: " .. speed, red, white)
shadow(2,20, "Organisms: " .. organisms, red,white)
screen.flip()
iter = iter + 1
end
while true do
screen.waitVblankStart()
end
too bad this method is flawed... /cry anyone have a slightly more accurate way of counting iterations per second in real time? w/o having slight clock inaccuracies...? (i.e if you reset the display with L and R it displays crazy numbers... /cry)
oh an interesting use for this application... stuck pixel unsticker... theoretically it should work >>; anyone want to give it a whirl and see if it works? hehe, at very least, its more pleasing on the eyes than a RGB flasher is... :x