| View previous topic :: View next topic |
| Author |
Message |
haxx_blaster
Joined: 20 Jan 2006 Posts: 13
|
Posted: Tue Feb 21, 2006 8:18 pm Post subject: The mouse allways ontop? |
|
|
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 |
|
| Back to top |
|
 |
fattymc03
Joined: 11 Feb 2006 Posts: 18
|
Posted: Tue Feb 21, 2006 11:16 pm Post subject: |
|
|
| make sure you are clearing the screen every time thru the loop |
|
| Back to top |
|
 |
haxx_blaster
Joined: 20 Jan 2006 Posts: 13
|
Posted: Wed Feb 22, 2006 3:15 am Post subject: |
|
|
| If i do "screen:clear()" a huge black hole appears, can't i get it transparent in some way? |
|
| Back to top |
|
 |
fullerlee
Joined: 03 Nov 2005 Posts: 54
|
Posted: Wed Feb 22, 2006 3:31 am Post subject: |
|
|
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: |
while true do
clearScreen()
drawBackground()
drawWindows()
drawMouse()
flip()
end |
|
|
| Back to top |
|
 |
haxx_blaster
Joined: 20 Jan 2006 Posts: 13
|
Posted: Wed Feb 22, 2006 6:05 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
fullerlee
Joined: 03 Nov 2005 Posts: 54
|
Posted: Wed Feb 22, 2006 7:03 am Post subject: |
|
|
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: |
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 |
|
| Back to top |
|
 |
haxx_blaster
Joined: 20 Jan 2006 Posts: 13
|
Posted: Wed Feb 22, 2006 9:45 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
|