aboutsummaryrefslogtreecommitdiff
path: root/graphics.adb
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-12-07 16:59:17 +0100
committerCharles <sircharlesaze@gmail.com>2019-12-07 16:59:17 +0100
commitacfbdcefdbc60e97a9e3447afed204b3e40d991e (patch)
tree8bd7db838cb47a39f985fd6a5be163fbe65a7a48 /graphics.adb
parent9b47ade2394becce870d195f198c235b3275ed34 (diff)
downloadsnake-acfbdcefdbc60e97a9e3447afed204b3e40d991e.tar.gz
snake-acfbdcefdbc60e97a9e3447afed204b3e40d991e.tar.bz2
snake-acfbdcefdbc60e97a9e3447afed204b3e40d991e.zip
Basic Graphics package
Diffstat (limited to 'graphics.adb')
-rw-r--r--graphics.adb60
1 files changed, 60 insertions, 0 deletions
diff --git a/graphics.adb b/graphics.adb
index e69de29..2cdea69 100644
--- a/graphics.adb
+++ b/graphics.adb
@@ -0,0 +1,60 @@
+with Ada.Text_IO;
+use Ada.Text_IO;
+
+with Graphics;
+use Graphics;
+
+with SDL;
+with SDL.Timers;
+with SDL.Events;
+with SDL.Events.Events;
+with SDL.Video.Windows;
+with SDL.Video.Windows.Makers;
+with SDL.Video.Renderers;
+with SDL.Video.Renderers.Makers;
+
+package body Graphics is
+
+ procedure Init(state: out T_State) is
+ begin
+ if not SDL.Initialise then
+ Put("Error");
+ end if;
+ SDL.Video.Windows.Makers.Create(state.window, WINDOW_TITLE, WINDOW_X, WINDOW_Y,
+ WINDOW_WIDTH, WINDOW_HEIGHT);
+ SDL.Video.Renderers.Makers.Create(state.renderer, state.window);
+ state.running := true;
+ end Init;
+
+ procedure Quit(state: T_State) is
+ begin
+ SDL.Finalise;
+ end Quit;
+
+ procedure Run(state: in out T_State) is
+ begin
+ while state.running loop
+ Event_Handler(state);
+ Update(state);
+ SDL.Timers.Wait_Delay(3);
+ end loop;
+ end Run;
+
+ procedure Event_Handler(state: in out T_State) is
+ event: SDL.Events.Events.Events;
+ begin
+ while SDL.Events.Events.Poll(event) loop
+ case event.common.event_type is
+ when SDL.Events.Quit => state.running := false;
+ when others => null;
+ end case;
+ end loop;
+ null;
+ end Event_Handler;
+
+ procedure Update(state: T_State) is
+ begin
+ null;
+ end Update;
+
+end Graphics;