Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  172

•  TDictionary Custom Sort  3 344

•  Fast Watermark Sources  3 095

•  3D Designer  4 853

•  Sik Screen Capture  3 350

•  Patch Maker  3 556

•  Айболит (remote control)  3 665

•  ListBox Drag & Drop  3 020

•  Доска для игры Реверси  81 747

•  Графические эффекты  3 948

•  Рисование по маске  3 253

•  Перетаскивание изображений  2 633

•  Canvas Drawing  2 761

•  Рисование Луны  2 586

•  Поворот изображения  2 196

•  Рисование стержней  2 172

•  Paint on Shape  1 570

•  Генератор кроссвордов  2 241

•  Головоломка Paletto  1 771

•  Теорема Монжа об окружностях  2 238

•  Пазл Numbrix  1 685

•  Заборы и коммивояжеры  2 059

•  Игра HIP  1 282

•  Игра Go (Го)  1 232

•  Симулятор лифта  1 477

•  Программа укладки плитки  1 219

•  Генератор лабиринта  1 549

•  Проверка числового ввода  1 368

•  HEX View  1 497

•  Физический маятник  1 359

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Реализация анимации без мерцания



Оформил: DeeCo

{ 
 You will need an image, called ImageSprite, containing a sprite bitmap with 
 black as the background (the transparent part). You will also need an image, 
 called ImageMask, containing a black silouette of the sprite with white as the 
 background and an Image called ImageBackground containing the background 
 image. All these images are set to visible := false. Image1 is the image you 
 will see and is the same size as the background image. 
}

 // Global variables 
var
   Form1: TForm1;
   x, y, xvel, yvel, xold, yold: integer;

 implementation

 {$R *.dfm}

 procedure TForm1.Button1Click(Sender: TObject);
 var
   ARect: TRect; // Destination/Source rectangles 
begin
   // Initialize sprites position/velocity 
  x := 0;
   y := 0;
   xvel := 2;
    yvel := 2;
   xold := 0;
    yold := 0;

   // copy background to the image 
  ARect := Rect(0, 0, ImageBackground.Width, ImageBackground.Height);
   with Image1.Canvas do
    begin
     CopyMode := cmSrcCopy;
     CopyRect(ARect, ImageBackground.Canvas, ARect);
   end;

   // start animation 
  Timer1.Enabled := True;
 end;

 procedure TForm1.Timer1Timer(Sender: TObject);
 var
   Dest, Sour: TRect; // Destination/Source rectangles 
begin
   // Erase sprite from old position 
  Sour := Rect(xold, yold, xold + ImageMask.Width, yold + ImageMask.Height);
   with Image1.Canvas do
    begin
     CopyMode := cmSrcCopy;
     CopyRect(Sour, ImageBackground.Canvas, Sour);
   end;

   // Draw new sprite 
  Sour := Rect(0, 0, ImageMask.Width, ImageMask.Height);
   Dest := Rect(x, y, x + ImageMask.Width, y + ImageMask.Height);
   with Image1.Canvas do
    begin
     // Place mask onto image 
    CopyMode := cmSrcAnd;
     CopyRect(Dest, ImageMask.Canvas, Sour);
     // Place sprite into mask 
    CopyMode := cmSrcPaint;
     CopyRect(Dest, ImageSprite.Canvas, Sour);
   end;

   { 
   if multiple sprites are being used, then erase them all before drawing them 
   all. Do not erase and draw each sprite in turn 
  }

   // store sprites old position before updating 
  xold := x;
   yold := y;

   // Update sprites position (equations to describe movement of sprite) 
  Inc(x, xvel);
   Inc(y, yvel);
   if x >= ImageBackground.Width then x := -ImageMask.Width;
   if y >= ImageBackground.Height then y := -ImageMask.Height;
 end;




Похожие по теме исходники

База данных без BDE

БД без BDE

Кривая Безье

Bezier Curves (кривые Безье)

 

Splay Line (Безье)

Сплайн на 8 точек (Безье)

Text Bezier Curve (Безье)

Кривые Безье на OpenGL

 



Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте