The mouse allways ontop?

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

Moderators: Shine, Insert_witty_name

Post Reply
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

The mouse allways ontop?

Post by haxx_blaster »

How do i do that if i want to blit: lets say a window which is a picture.
The window will be over the mouse because its further down the code,
but if i set the mouse blit after that it blits forever, you know when it blits over and over again, and when i move the mouse there is blits all over the place.

Please help me out here. Peace
fattymc03
Posts: 18
Joined: Sat Feb 11, 2006 12:22 am

Post by fattymc03 »

make sure you are clearing the screen every time thru the loop
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

Post by haxx_blaster »

If i do "screen:clear()" a huge black hole appears, can't i get it transparent in some way?
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

You will generally have to redraw everything each cycle, even stuff that hasn't changed. If you bear that in mind, you should solve your problem.

Lee

eg:

Code: Select all

while true do
   
   clearScreen()
   drawBackground()
   drawWindows()
   drawMouse()
   flip()

end
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

Post by haxx_blaster »

Is that the only way to do it?
It will be fucking hard to make it like that because i have to remake everything.

Edit: I tryed it, and it makes everything go slower then a turtle. ;P
fullerlee
Posts: 54
Joined: Thu Nov 03, 2005 9:46 am

Post by fullerlee »

Another way would be to cache the drawing of things that don't change.

So, say you have a background, and a bunch of windows to draw. You only really want to redraw windows that have changed, so you could draw each window to an image, and keep a reference to each image prior to blitting the images to the screen.

Something like this (pseudo code):

Code: Select all

function redraw()
   backBuffer:clear()
   for eachWindow
      if eachWindow has changed
         eachWindow.windowImage = generateWindowImage()
      end 
      backBuffer:blit(eachWindow.windowImage)
   end
   
   drawMouse(backBuffer)
  
   --Finally blit the backbuffer to the screen
   screen:blit(backBuffer)
Hopefully that will give you an idea.

Have a look at the bits of render code where you're doing the most complex calculations and see if the final image is cacheable.

For example, in the project I'm working on, I have an instructions screen which displays as long as the L button is held down. There's a fair bit of code which generates the instructions screen, but I only need execute it once, because I blit the instructions to an image, and then all I have to do each cycle is blit the final instructions image to the screen.

Lee
haxx_blaster
Posts: 13
Joined: Fri Jan 20, 2006 4:21 pm

Post by haxx_blaster »

I dont really recognize that kind of code.
But, you know in the beginning of the code you can have "do while true" and blit pictures there, it all transparent.
Can't i redo that later down the code? Why is it so special?
Post Reply