Gamebit/src/gamebit-sprites.adb

72 lines
1.9 KiB
Ada

with HAL.Bitmap; use HAL.Bitmap;
package body Gamebit.Sprites is
function Height (B : in Bird) return Positive is
pragma Unreferenced (B);
begin
return 15;
end Height;
function Width (B : in Bird) return Positive is
pragma Unreferenced (B);
begin
return 15;
end Width;
function Position (B : in Bird) return Point is
begin
return (B.X, B.y);
end Position;
procedure Set_Position (B : in out Bird; Origin : in Point) is
begin
B.X := Origin.X;
B.Y := Origin.Y;
end Set_Position;
procedure Tick (B : in out Bird) is
begin
B.Buffer.Set_Source (B.Color);
B.Buffer.Fill_Rect (((B.X, B.Y), B.Width, B.Height));
if B.Y = 150 then
B.Trajectory := Right;
elsif B.Y = 0 then
B.Trajectory := Left;
end if;
if B.Trajectory = Left then
-- Erase before drawing a little bit anew
B.Buffer.Set_Source (Transparent);
B.Buffer.Draw_Line (
(B.X, B.Y),
((B.X + B.Height), B.Y)
);
-- Move across the screen in one direction for now
B.Y := B.Y + 1;
end if;
if B.Trajectory = Right then
-- Erase before drawing a little bit anew
B.Buffer.Set_Source (Transparent);
B.Buffer.Draw_Line (
(B.X, B.Y + B.Width),
((B.X + B.Height), B.Y + B.Width)
);
-- Move across the screen in one direction for now
B.Y := B.Y - 1;
end if;
end Tick;
procedure Set_Framebuffer (B : in out Bird;
Buffer : in HAL.Bitmap.Any_Bitmap_Buffer) is
begin
B.Buffer := Buffer;
end Set_Framebuffer;
end Gamebit.Sprites;