private with Ada.Real_Time;
private with Tiles;
private with Tiles.Libraries;
package Widgets.Paddle_Wars is
type Paddle_War is new Widget and Animated with private;
type A_Paddle_War is access all Paddle_War'Class;
function Create_Paddle_War( view : not null access Game_Views.Game_View'Class;
id : String;
libName : String ) return A_Paddle_War;
pragma Precondition( id'Length > 0 );
pragma Precondition( libName'Length > 0 );
pragma Postcondition( Create_Paddle_War'Result /= null );
procedure Reset( this : not null access Paddle_War'Class );
private
use Ada.Real_Time;
use Tiles;
use Tiles.Libraries;
type Entity_Rec is
record
x, y : Float := 0.0;
xv, yv : Float := 0.0;
w, h : Float := 0.0;
w2, h2 : Float := 0.0;
end record;
type Paddle_War is new Widget and Animated with
record
lib : A_Tile_Library := null;
backgroundId : Natural := 0;
paddleId : Natural := 0;
ballId : Natural := 0;
boundsX1,
boundsY1,
boundsX2,
boundsY2 : Float := 0.0;
ball,
compPlayer,
keenPlayer : Entity_Rec;
compScore,
keenScore : Natural := 0;
outOfBounds : Boolean := False;
nextBall : Time_Span := Time_Span_Last;
end record;
procedure Construct( this : access Paddle_War;
view : not null access Game_Views.Game_View'Class;
id : String;
libName : String );
pragma Precondition( id'Length > 0 );
pragma Precondition( libName'Length > 0 );
procedure Delete( this : in out Paddle_War );
procedure Draw_Content( this : access Paddle_War );
function Get_Min_Height( this : access Paddle_War ) return Natural;
function Get_Min_Width( this : access Paddle_War ) return Natural;
procedure On_Key_Press( this : access Paddle_War;
evt : not null A_Key_Event;
handled : in out Boolean );
procedure On_Key_Release( this : access Paddle_War;
evt : not null A_Key_Event;
handled : in out Boolean );
procedure On_Shown( this : access Paddle_War; shown : Boolean );
procedure Tick( this : access Paddle_War; time : Tick_Time );
end Widgets.Paddle_Wars;