screen:blit

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Squall333
Posts: 91
Joined: Thu Apr 28, 2005 5:32 am

screen:blit

Post by Squall333 »

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?
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Post by Shine »

Do you have some code, which is too slow? I don't understand your problem.
Squall333
Posts: 91
Joined: Thu Apr 28, 2005 5:32 am

Post by Squall333 »

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&#58;cross&#40;&#41; then
		screen.waitVblankStart&#40;15&#41;
		Programs = Programs + 1
		end
	end	

	if math.mod&#40;Programs,r&#41; == 0 then
	screen&#58;blit&#40;0, 0, programs&#41;
		if x0>75 and y0>220 and x0<90 and y0<235 then
			screen&#58;blit&#40;0,0,exit_bright&#41;
				if pad&#58;cross&#40;&#41; then 
					return
				end
   
         	end
	if y0 > 249 and x0 < 60 and pad&#58;cross&#40;&#41; then
		PRGRAMS = false
	end
   end    
 	
	if x0 > 70 and y0 > 135 and x0 < 144 and y0 < 154 then
              screen&#58;blit&#40;0,0,my_comp&#41;
			if pad&#58;cross&#40;&#41; then
		 	MYCOMPUTER = true
			end		
	end



	if MYCOMPUTER == true then
	   screen&#58;blit&#40;0,0,my_computer&#41;
	end
end


-- Analog Control

	pad = Controls.read&#40;&#41;
	dx = pad&#58;analogX&#40;&#41;
	if math.abs&#40;dx&#41; > 32 then
		x0 = x0 + dx / 64
	end
	dy = pad&#58;analogY&#40;&#41;
	if math.abs&#40;dy&#41; > 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&#40;&#41;
	dateString = os.date&#40;"%c", time&#41;
	dateFields = os.date&#40;"*t", time&#41;
	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&#58;cross&#40;&#41; and x0>449 and y0>0 and x0<470 and y0<20 then
		MYCOMPUTER=false
	end

	if pad&#58;cross&#40;&#41; and x0>5 and y0>54 and x0<54 and y0<85 then
		MYCOMPUTER=false
	end

-- Always up 
	
	screen&#58;blit&#40;0, 0, bar&#41;
	screen&#58;print&#40;400, 265, hour +7 .. "&#58;" ..min .. " " .. c,color&#41;
	screen&#58;blit&#40;x0, y0, pointer&#41;
	
	screen.waitVblankStart&#40;&#41;
	screen.flip&#40;&#41;
	if pad&#58;start&#40;&#41; then
	break
	end
DRAW&#40;&#41;
end
Post Reply