From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: Get_Immediate has raised CONSTRAINT_ERROR : s-wchcnv.adb:207 explicit raise
Date: Thu, 19 Feb 2015 22:37:04 +0100
Date: 2015-02-19T22:37:04+01:00 [thread overview]
Message-ID: <mc5l0p$5h6$1@dont-email.me> (raw)
In-Reply-To: <234cdad3-5c41-4b0d-b611-01c53273cb7f@googlegroups.com>
On 2015-02-18 18:29, darek wrote:
> Dear All,
> reading from a keyboard keys such as arrow keys, PgUp, PgDn, etc. seems to be a small challenge in Ada. For this purpose one of the Get_Immediate procedures from the Ada.Text_IO shall be used. For the keyboard we can use either
> - procedure Get_Immediate (Item : out Character)
> or
> - procedure Get_Immediate (Item : out Character; Available : out Boolean)
>
if you use SDL, I think it will do the trick. I have some code that does
SDL.Events.PollEventVP (PollEvent_Result, Event);
exit when PollEvent_Result = 0;
case Event.The_Type is
when SDL.Events.KEYDOWN =>
declare
-- player 0 -> w,a,s,z
-- player 1 -> up,left,rigt,down
Name_Of_Key : String :=
C.Strings.Value(SDL.Keyboard.GetKeyName(Event.key.keysym.sym));
begin
Log("Game.Handle_Events"," Key down: '" & Name_Of_Key & "'");
if Name_Of_Key = "up" then
Game.Player(Player_Idx).Game_Obj_Ptr.Heading := Up;
elsif Name_Of_Key = "right" then
Game.Player(Player_Idx).Game_Obj_Ptr.Heading := Right;
elsif Name_Of_Key = "down" then
Game.Player(Player_Idx).Game_Obj_Ptr.Heading := Down;
elsif Name_Of_Key = "left" then
....
--
Björn
prev parent reply other threads:[~2015-02-19 21:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-18 17:29 Get_Immediate has raised CONSTRAINT_ERROR : s-wchcnv.adb:207 explicit raise darek
2015-02-18 18:34 ` Dmitry A. Kazakov
2015-02-18 19:34 ` darek
2015-02-18 20:36 ` Dmitry A. Kazakov
2015-02-18 21:19 ` darek
2015-02-18 21:44 ` Dmitry A. Kazakov
2015-02-18 22:09 ` Georg Bauhaus
2015-02-18 20:16 ` Simon Wright
2015-02-18 20:34 ` darek
2015-02-19 21:37 ` Björn Lundin [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox