text stringlengths 0 234 |
|---|
-- Send ping echo request deadline |
Ping_Deadline : Ada.Real_Time.Time; |
Icmp_Handler : Net.Protos.Receive_Handler; |
begin |
Initialize ("STM32 Ping"); |
Pinger.Add_Host ((192, 168, 1, 1)); |
Pinger.Add_Host ((8, 8, 8, 8)); |
Net.Protos.Dispatchers.Set_Handler (Proto => Net.Protos.IPv4.P_ICMP, |
Handler => Pinger.Receive'Access, |
Previous => Icmp_Handler); |
-- Change font to 8x8. |
Demos.Current_Font := BMP_Fonts.Font8x8; |
Ping_Deadline := Ada.Real_Time.Clock; |
loop |
declare |
Now : constant Ada.Real_Time.Time := Ada.Real_Time.Clock; |
Dhcp_Deadline : Ada.Real_Time.Time; |
begin |
Net.Protos.Arp.Timeout (Demos.Ifnet); |
Demos.Dhcp.Process (Dhcp_Deadline); |
if Demos.Dhcp.Get_State = Net.DHCP.STATE_BOUND then |
Pinger.Add_Host (Demos.Dhcp.Get_Config.Router); |
Pinger.Add_Host (Demos.Dhcp.Get_Config.Dns1); |
Pinger.Add_Host (Demos.Dhcp.Get_Config.Dns2); |
Pinger.Add_Host (Demos.Dhcp.Get_Config.Ntp); |
Pinger.Add_Host (Demos.Dhcp.Get_Config.Www); |
end if; |
if Ping_Deadline < Now then |
Pinger.Do_Ping; |
Refresh; |
Ping_Deadline := Ping_Deadline + PING_PERIOD; |
end if; |
if Ping_Deadline < Dhcp_Deadline then |
delay until Ping_Deadline; |
else |
delay until Dhcp_Deadline; |
end if; |
Function Definition: function Check_Monster_Collision return Boolean; |
Function Body: -------------- |
-- Collides -- |
-------------- |
function Collides (Points : Collision_Points) return Boolean is |
X : constant Integer := Integer (P.Position.X); |
Y : constant Integer := Integer (P.Position.Y); |
begin |
for Pt of Points loop |
if Show_Collision_Points then |
declare |
Data : aliased HAL.UInt16_Array := (0 => 0); |
begin |
PyGamer.Screen.Set_Address (UInt16 (X + Pt.X), |
UInt16 (X + Pt.X), |
UInt16 (Y + Pt.Y), |
UInt16 (Y + Pt.Y)); |
PyGamer.Screen.Start_Pixel_TX; |
PyGamer.Screen.Push_Pixels (Data'Address, Data'Length); |
PyGamer.Screen.End_Pixel_TX; |
Function Definition: function Check_Monster_Collision return Boolean is |
Function Body: X : constant Integer := Integer (P.Position.X); |
Y : constant Integer := Integer (P.Position.Y); |
begin |
for Pt of Bounding_Box loop |
if Monsters.Check_Hit ((X + Pt.X, |
Y + Pt.Y), |
Lethal => False) |
then |
return True; |
end if; |
end loop; |
return False; |
end Check_Monster_Collision; |
----------- |
-- Spawn -- |
----------- |
procedure Spawn is |
begin |
P.Alive := True; |
P.Set_Mass (Value (90.0)); |
P.Sprite.Flip_Vertical (False); |
P.Set_Speed ((0.0, 0.0)); |
GESTE.Add (P.Sprite'Access, 3); |
P.Sprite.Flip_Horizontal (True); |
for Prj of Projs loop |
Prj.Init; |
end loop; |
end Spawn; |
---------- |
-- Move -- |
---------- |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.