procedure TForm1.DGCScreen1Initialize(Sender: TObject); begin //Draw stuff on the hidden surface DrawFrame; //Quickly fade palette to black DGCScreen1.FadePaletteOut(1); //Flip the hidden surface with the visible one so you can //see it on the screen - but you can't see it yet cause the //palette is still black??? DGCScreen1.Flip; //Finally Smoothly fade the palette in DGCScreen1.FadePaletteIn(100); //Copy the Front surface to the back buffer so //both surfaces contain the same info DGCScreen1.Back.BltFast(0, 0, DGCScreen1.Front, DGCScreen1.Front.ClientRect, False); //Initialise the image attributes (for my crude bounce code) x := 150; y := 200; yvel := 1; xvel := 2; //Now Start the page flipping DGCScreen1.FlippingEnabled := True; end; |
DGCScreen1.Back.BltFast(0, 0, DGCScreen1.Front, DGCScreen1.Front.ClientRect, False); |
DrawFrame; |
//Now Start the page flipping DGCScreen1.FlippingEnabled := True; |
procedure TForm1.DGCScreen1Flip(Sender: TObject); begin //Erase the area theat the sprite will bounce in DGCScreen1.Back.EraseRect(Rect(0, 200, 640, 468), 0); //Now Draw the Sprite DGCScreen1.Back.Draw(x, y, DGCScreen1.Images[0], False); //Update the Images X position Inc(x, xvel); if (x < 0) or (x > 500) then xvel := -xvel; //Update the y position using yvel Inc(y, yvel); //Uncrease the Velocity and make sure it is in a range Inc(yvel); if yvel > 18 then yvel := 18; if yvel < -18 then yvel := -18; //If the image has reached the bottom then reverse direction if y > 380 then begin y := 380; yvel := -yvel; end; end; |
procedure TForm1.DGCScreen1Paint(Sender: TObject); begin //The paint event should only be called when surfaces are lost. This //can be caused when application switching with ALT+TAB. DrawFrame; DGCScreen1.Flip; DrawFrame; end; |