screen:blit
Moderators: Shine, Insert_witty_name
screen:blit
it seems that after i blit a second png the size of the full screen everything slows down is there a way to unblit the first background then re blit it once you close the second background?
as ugly as it may be here it is
Code: Select all
System.usbDiskModeActivate()
-- load images
background = Image.load("img/background.png")
bar = Image.load("img/bar.png")
bar_bright = Image.load("img/bar_bright.png")
pointer = Image.load("img/pointer.png")
programs = Image.load("img/programs.png")
exit_bright = Image.load("img/exit_bright.png")
my_comp = Image.load("img/my_computer.png")
my_computer = Image.load("img/my computer.png")
pad = Controls.read()
color = Color.new(255, 255, 255)
-- Variables
x0 = 0
y0 = 0
x1 = 0
y1 = 0
r=2
MYCOMP = false
MYCOMPUTER = false
Programs = 1
BarBrght = false
-- Main
while true do
function DRAW()
screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false)
if BarBrght == true then
screen:blit(0, 0, bar_bright)
if y0 > 249 and x0 < 60 and pad:cross() then
screen.waitVblankStart(15)
Programs = Programs + 1
end
end
if math.mod(Programs,r) == 0 then
screen:blit(0, 0, programs)
if x0>75 and y0>220 and x0<90 and y0<235 then
screen:blit(0,0,exit_bright)
if pad:cross() then
return
end
end
if y0 > 249 and x0 < 60 and pad:cross() then
PRGRAMS = false
end
end
if x0 > 70 and y0 > 135 and x0 < 144 and y0 < 154 then
screen:blit(0,0,my_comp)
if pad:cross() then
MYCOMPUTER = true
end
end
if MYCOMPUTER == true then
screen:blit(0,0,my_computer)
end
end
-- Analog Control
pad = Controls.read()
dx = pad:analogX()
if math.abs(dx) > 32 then
x0 = x0 + dx / 64
end
dy = pad:analogY()
if math.abs(dy) > 32 then
y0 = y0 + dy / 64
end
if x0 > 470 then
x0 = 470
end
if x0 < 0 then
x0 = 0
end
if y0 > 270 then
y0 = 270
end
if y0 < 0 then
y0 = 0
end
-- Time
time = os.time()
dateString = os.date("%c", time)
dateFields = os.date("*t", time)
hour = dateFields.hour
if hour < 12 then
c = "AM"
else
c = "PM"
end
if hour < 10 then
hour = "0" .. hour
end
min = dateFields.min
if min < 10 then
min = "0" .. min
end
-- Cursor Highlighting
if y0 > 249 and x0 < 60 then
BarBrght = true
end
if pad:cross() and x0>449 and y0>0 and x0<470 and y0<20 then
MYCOMPUTER=false
end
if pad:cross() and x0>5 and y0>54 and x0<54 and y0<85 then
MYCOMPUTER=false
end
-- Always up
screen:blit(0, 0, bar)
screen:print(400, 265, hour +7 .. ":" ..min .. " " .. c,color)
screen:blit(x0, y0, pointer)
screen.waitVblankStart()
screen.flip()
if pad:start() then
break
end
DRAW()
end