Hi everyone,
so Im still creating a game, and I have encountered next problem I cannot solve.
Im creating game field with something like that:
bimg := TBGRABitmap.Create(clientWidth, clientHeight, BGRAPixelTransparent);
{here Im creating game elements using another TBGRA variable - img and function bimg.PutImage();}
bimg.Draw(Canvas,0,0,True);
bimg.Free;
Game is refreshed every 40 ms, so I have to use True in the Draw mode, simply to clear the field and redraw it properly - each object with new coords etc.
But I would like to add graphical wallpaper beneath it, that doesnt need to be refreshed - I mean, a static wallpaper in .jpg format, res, maybe 1280x800px and there is my problem.
If I replace:
bimg := TBGRABitmap.Create(clientWidth, clientHeight, BGRAPixelTransparent);
with
bimg := TBGRABitmap.Create('./graphics/wallpaper.jpg');
Game starts to lag awfully - Im not surprised, if such a big file is loaded so many times.
I think it should work properly if I do not draw bimg on form Canvas but on wallpaper Canvas. I mean, to put bimg beyond wallpaper and refresh only bimg, without rest.
It should be fine, but... how to do it?
I tried something like
bimg.Draw(wallpaper.Canvas,0,0,True);
But It doesnt work.
Can someone help me with this? How should I code it?