Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-12-10 Thread Pascal
Thanks Jeff for the welcome explanations.

Thus I switch to a map container (my son advice ;-).
I push the modifications to dev_1.3 branch on SF with some other fixes.
Next, I'll work on a smoother sprite movement instead of small hops, see 
sprite_test.adb.

NB: for those who use dev_1.3 with GPS, do:
$ make # as usual
$ make gps # to launch GPS with GNAT project paths set
Don't forget to set GPS variables in scenario tab.

Feel free to report any bad or good results especially on Linux or Windows as I 
make only macOS tests.

Regards, Pascal.
http://blady.pagesperso-orange.fr


> Le 5 déc. 2016 à 05:04, Jeffrey R. Carter  a écrit :
> 
> On 12/04/2016 11:35 AM, Pascal wrote:
>> I used a vector of sprites, the private Sprite_Type is the cursor type of 
>> the vector.
>> After I created 2 sprites SP1 and SP2 of Sprite_Type and I deleted SP1 with 
>> no error then I deleted SP2 with the error:
>> raised CONSTRAINT_ERROR : 
>> Gnoga.Gui.Element.Canvas.Context_2D.Sprite.Sprite_Lists.Element: Position 
>> cursor is out of range
>> I can't get SP2 element before deleting it.
>> 
>> Is it cursor tampering when deleting SP1?
>> If yes, I don't understand actually why.
>> Any clue?
>> Thus what should I take for Sprite_Type?
> 
> I've never really understood what a cursor is supposed to be for a vector. 
> Since
> it should be named Unbounded_Arrays, the idea should be that you access 
> elements
> through indices. Anyway, GNAT 4.9 implements Cursor as
> 
>   type Cursor is record
> 
>  Container : Vector_Access;
> 
>  Index : Index_Type := Index_Type'First;
> 
>   end record;
> 
> So I'd guess when you delete SP1, the Index in SP2 becomes invalid. Not very
> useful, and we shouldn't have to look in the private part to understand how it
> works. You'd probably do better with a list, since Cursor would then be an
> access to a list node, and not change when nodes are inserted or deleted.
> 
> -- 
> Jeff Carter
> "I snapped my chin down onto some guy's fist and
> hit another one in the knee with my nose."
> Play It Again, Sam
> 129
> 
> 
> 
> --
> ___
> Gnoga-list mailing list
> Gnoga-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gnoga-list


--
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-12-04 Thread Jeffrey R. Carter
On 12/04/2016 11:35 AM, Pascal wrote:
> I used a vector of sprites, the private Sprite_Type is the cursor type of the 
> vector.
> After I created 2 sprites SP1 and SP2 of Sprite_Type and I deleted SP1 with 
> no error then I deleted SP2 with the error:
> raised CONSTRAINT_ERROR : 
> Gnoga.Gui.Element.Canvas.Context_2D.Sprite.Sprite_Lists.Element: Position 
> cursor is out of range
> I can't get SP2 element before deleting it.
>
> Is it cursor tampering when deleting SP1?
> If yes, I don't understand actually why.
> Any clue?
> Thus what should I take for Sprite_Type?

I've never really understood what a cursor is supposed to be for a vector. Since
it should be named Unbounded_Arrays, the idea should be that you access elements
through indices. Anyway, GNAT 4.9 implements Cursor as

   type Cursor is record

  Container : Vector_Access;

  Index : Index_Type := Index_Type'First;

   end record;

So I'd guess when you delete SP1, the Index in SP2 becomes invalid. Not very
useful, and we shouldn't have to look in the private part to understand how it
works. You'd probably do better with a list, since Cursor would then be an
access to a list node, and not change when nodes are inserted or deleted.

-- 
Jeff Carter
"I snapped my chin down onto some guy's fist and
hit another one in the knee with my nose."
Play It Again, Sam
129



--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-12-04 Thread Pascal
Hello,

I used a vector of sprites, the private Sprite_Type is the cursor type of the 
vector.
After I created 2 sprites SP1 and SP2 of Sprite_Type and I deleted SP1 with no 
error then I deleted SP2 with the error:
raised CONSTRAINT_ERROR : 
Gnoga.Gui.Element.Canvas.Context_2D.Sprite.Sprite_Lists.Element: Position 
cursor is out of range
I can't get SP2 element before deleting it.

Is it cursor tampering when deleting SP1?
If yes, I don't understand actually why.
Any clue?
Thus what should I take for Sprite_Type?

Thanks, Pascal.
http://blady.pagesperso-orange.fr


> Le 1 déc. 2016 à 21:24, Jeffrey R. Carter  a écrit :
> 
> On 12/01/2016 12:46 PM, Pascal wrote:
>> Ok for Update_Interval.
>> Concerning access type, Sprite_Type is a limited record because of 
>> Context_2D_Type and Image_Data_Type are limited.
>> Thus Sprite_Type can't be part of Vector.
>> Maybe I could have used an array of Sprite_Type?
> 
> OK, then you have a valid reason, which it might be useful to document so you
> don't get similar comments from others who, like me, don't look closely enough
> at the declaration to realize it's limited. You can't use Indefinite_Vectors 
> either.
> 
> You could use an array, but then you'd have an upper limit on the number of
> sprites, either hard-coded or a generic parameter. If you want to keep it
> unbounded, you'd need to replicate the needed functionality from Vectors. That
> can probably be done for a specific limited type; generalizing it to
> Limited_Vectors is probably not possible.
> 
> -- 
> Jeff Carter
> "If you think you got a nasty taunting this time,
> you ain't heard nothing yet!"
> Monty Python and the Holy Grail
> 23
> 
> 
> 
> --
> ___
> Gnoga-list mailing list
> Gnoga-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gnoga-list


--
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-12-01 Thread Jeffrey R. Carter
On 12/01/2016 12:46 PM, Pascal wrote:
> Ok for Update_Interval.
> Concerning access type, Sprite_Type is a limited record because of 
> Context_2D_Type and Image_Data_Type are limited.
> Thus Sprite_Type can't be part of Vector.
> Maybe I could have used an array of Sprite_Type?

OK, then you have a valid reason, which it might be useful to document so you
don't get similar comments from others who, like me, don't look closely enough
at the declaration to realize it's limited. You can't use Indefinite_Vectors 
either.

You could use an array, but then you'd have an upper limit on the number of
sprites, either hard-coded or a generic parameter. If you want to keep it
unbounded, you'd need to replicate the needed functionality from Vectors. That
can probably be done for a specific limited type; generalizing it to
Limited_Vectors is probably not possible.

-- 
Jeff Carter
"If you think you got a nasty taunting this time,
you ain't heard nothing yet!"
Monty Python and the Holy Grail
23



--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-12-01 Thread Pascal
Hello Jeff,

Ok for Update_Interval.
Concerning access type, Sprite_Type is a limited record because of 
Context_2D_Type and Image_Data_Type are limited.
Thus Sprite_Type can't be part of Vector.
Maybe I could have used an array of Sprite_Type?

Regards, Pascal.
http://blady.pagesperso-orange.fr


> Le 27 nov. 2016 à 20:15, Jeffrey R. Carter  a écrit :
> 
> On 11/27/2016 11:48 AM, Pascal wrote:
>> Many thanks Jeff.
>> 
>> Specification has been modified and pushed to SF GIT branch dev_1.3 with a 
>> test case:
>> https://sourceforge.net/p/gnoga/code/ci/dev_1.3/tree/src/gnoga-gui-element-canvas-context_2d-sprite.ads
> 
> This looks good. I'd suggest Update_Interval rather than Trigger, and a 
> comment
> to specify the default value.
> 
> Why not store the sprite data directly in the vector? That would eliminate the
> need for memory management. I don't see why you'd need the access type.
> 
> -- 
> Jeff Carter
> "I'm a lumberjack and I'm OK."
> Monty Python's Flying Circus
> 54
> 
> 
> 
> --
> ___
> Gnoga-list mailing list
> Gnoga-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gnoga-list


--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-11-27 Thread Jeffrey R. Carter
On 11/27/2016 11:48 AM, Pascal wrote:
> Many thanks Jeff.
>
> Specification has been modified and pushed to SF GIT branch dev_1.3 with a 
> test case:
> https://sourceforge.net/p/gnoga/code/ci/dev_1.3/tree/src/gnoga-gui-element-canvas-context_2d-sprite.ads

This looks good. I'd suggest Update_Interval rather than Trigger, and a comment
to specify the default value.

Why not store the sprite data directly in the vector? That would eliminate the
need for memory management. I don't see why you'd need the access type.

-- 
Jeff Carter
"I'm a lumberjack and I'm OK."
Monty Python's Flying Circus
54



--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-11-27 Thread Pascal
Many thanks Jeff.

Specification has been modified and pushed to SF GIT branch dev_1.3 with a test 
case:
https://sourceforge.net/p/gnoga/code/ci/dev_1.3/tree/src/gnoga-gui-element-canvas-context_2d-sprite.ads
https://sourceforge.net/p/gnoga/code/ci/dev_1.3/tree/src/gnoga-gui-element-canvas-context_2d-sprite.adb
https://sourceforge.net/p/gnoga/code/ci/dev_1.3/tree/test/sprite_test.adb

This a very preliminary commit:
- memory for saved image on Javascript side is not managed (how to do this?)
- events are not managed (how to do this?)

Any feedbacks are welcome.

Regards, Pascal.
http://blady.pagesperso-orange.fr


> Le 26 nov. 2016 à 22:34, Jeffrey R. Carter  a écrit :
> 
> On 11/26/2016 01:07 PM, Pascal wrote:
> 
>>   procedure Create
>> (Context   : in out Context_2D_Type;
>>  Sprite: in out Sprite_Type'Class;
>>  Image_Data: in out Image_Data_Type'Class;
>>  Row, Column   : in Integer;
>>  Row_Velocity, Column_Velocity : in Integer := 0);
>>  --  Defines sprite, specifying the image to draw, the position and the 
>> motion (optionnal)
> 
> How are the position values interpreted? What are the units of velocity?
> 
>> 
>>   procedure Locate
>> (Sprite  : in out Sprite_Type;
>>  Row, Column : in Integer);
>>  --  Specifies the position of the upper left hand corner of a sprite
> 
> This probably answers the position question above. Perhaps such information
> should be pulled out into a single comment preceding all the operations.
> 
>> 
>>   procedure Pattern
>> (Sprite : in out Sprite_Type;
>>  Image_Data : in out Image_Data_Type'Class);
>>  --  Specifies the image that defines a sprite
>> 
>>   procedure Motion
>> (Sprite: in out Sprite_Type;
>>  Row_Velocity, Column_Velocity : in Integer);
>>  --  Specifies the motion of a sprite
> The units of velocity question also applies here. As with position, perhaps 
> this
> should be answered in a single comment preceding all the operations.
>> 
>>   function Coincidence
>> (Sprite1, Sprite2 : in Sprite_Type;
>>  Tolerance: in Natural)
>>  return Boolean;
>>   function Coincidence
>> (Sprite  : in Sprite_Type;
>>  Row, Column : in Integer;
>>  Tolerance   : in Natural)
>>  return Boolean;
>>   --  Determines if two sprites or a sprite and a point on the screen at or 
>> near the same location on the screen
> 
> What does it mean for 2 sprites to coincide with a tolerance of zero? For a
> sprite and a point? What are the units of tolerance?
> 
>> 
>>   function Distance
>> (Sprite1, Sprite2 : in Sprite_Type)
>>  return Natural;
>>   function Distance
>> (Sprite  : in Sprite_Type;
>>  Row, Column : in Integer)
>>  return Natural;
>>   --  Determines the distance between two sprites or a sprite and a location
>>   --  The result is the square root between the upper left hand corner of 
>> two sprites
>>   --  or between the upper left hand corner of a sprite and a location
> Since distances are often fractional, should these return a real type?
>> 
>>   procedure Position
>> (Sprite  : in Sprite_Type;
>>  Row, Column :out Integer);
>>  --  Determines the position of a sprite
> 
> For completeness, should there be query operations for the image and 
> velocities?
> 
>> 
>>   procedure Del_Sprite (Sprite : in out Sprite_Type);
>>   procedure Del_Sprite_All;
>>   --  Deletes sprites
> 
> I think Delete and Delete_All would be better names for these.
> 
> -- 
> Jeff Carter
> "Hold your temper. Count ten Now let 'er go.
> You got a good aim."
> Never Give a Sucker an Even Break
> 105
> 
> 
> 
> --
> ___
> Gnoga-list mailing list
> Gnoga-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gnoga-list


--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-11-26 Thread Jeffrey R. Carter
On 11/26/2016 01:07 PM, Pascal wrote:

>procedure Create
>  (Context   : in out Context_2D_Type;
>   Sprite: in out Sprite_Type'Class;
>   Image_Data: in out Image_Data_Type'Class;
>   Row, Column   : in Integer;
>   Row_Velocity, Column_Velocity : in Integer := 0);
>   --  Defines sprite, specifying the image to draw, the position and the 
> motion (optionnal)

How are the position values interpreted? What are the units of velocity?

>
>procedure Locate
>  (Sprite  : in out Sprite_Type;
>   Row, Column : in Integer);
>   --  Specifies the position of the upper left hand corner of a sprite

This probably answers the position question above. Perhaps such information
should be pulled out into a single comment preceding all the operations.

>
>procedure Pattern
>  (Sprite : in out Sprite_Type;
>   Image_Data : in out Image_Data_Type'Class);
>   --  Specifies the image that defines a sprite
>
>procedure Motion
>  (Sprite: in out Sprite_Type;
>   Row_Velocity, Column_Velocity : in Integer);
>   --  Specifies the motion of a sprite
The units of velocity question also applies here. As with position, perhaps this
should be answered in a single comment preceding all the operations.
>
>function Coincidence
>  (Sprite1, Sprite2 : in Sprite_Type;
>   Tolerance: in Natural)
>   return Boolean;
>function Coincidence
>  (Sprite  : in Sprite_Type;
>   Row, Column : in Integer;
>   Tolerance   : in Natural)
>   return Boolean;
>--  Determines if two sprites or a sprite and a point on the screen at or 
> near the same location on the screen

What does it mean for 2 sprites to coincide with a tolerance of zero? For a
sprite and a point? What are the units of tolerance?

>
>function Distance
>  (Sprite1, Sprite2 : in Sprite_Type)
>   return Natural;
>function Distance
>  (Sprite  : in Sprite_Type;
>   Row, Column : in Integer)
>   return Natural;
>--  Determines the distance between two sprites or a sprite and a location
>--  The result is the square root between the upper left hand corner of 
> two sprites
>--  or between the upper left hand corner of a sprite and a location
Since distances are often fractional, should these return a real type?
>
>procedure Position
>  (Sprite  : in Sprite_Type;
>   Row, Column :out Integer);
>   --  Determines the position of a sprite

For completeness, should there be query operations for the image and velocities?

>
>procedure Del_Sprite (Sprite : in out Sprite_Type);
>procedure Del_Sprite_All;
>--  Deletes sprites

I think Delete and Delete_All would be better names for these.

-- 
Jeff Carter
"Hold your temper. Count ten Now let 'er go.
You got a good aim."
Never Give a Sucker an Even Break
105



--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list


Re: [Gnoga-list] Project for someone - Chess - Sprite

2016-11-26 Thread Pascal
Hello,

Here is in attached file the specification proposal of the sprite specification.



gnoga-gui-element-canvas-context_2d-sprite.ads
Description: Binary data


Any feedback will be appreciated.

Thanks, Pascal.
http://blady.pagesperso-orange.fr


> Le 24 nov. 2016 à 21:33, Pascal  a écrit :
> 
> Hello,
> 
> Well, I'll try to draft something.
> 
> But there many Javascript possibilities or direct HTML5:
> 
> - https://spritejs.readthedocs.io/en/latest/
> - http://www.createjs.com/docs/easeljs/classes/Sprite.html
> - others
> 
> What is your advice?
> 
> Regards, Pascal.
> http://blady.pagesperso-orange.fr
> 
> 
>> Le 19 nov. 2016 à 18:26, Gautier de Montmollin  a écrit 
>> :
>> 
>> Cool!
>> This depends - again - on a project for someone else (or perhaps the 
>> same...) : provide a simple example of a sprite with GNOGA.
>> If you Google "sprite html5" you get plenty of examples, even complete games.
>> So I guess it is possible, but how exactly ?...
>> Cheers
>> Gautier
>> From: Pascal 
>> Sent: Sunday, November 13, 2016 5:52:22 PM
>> To: Gnoga support list
>> Subject: Re: [Gnoga-list] Project for someone
>> 
>> Hello,
>> 
>> FYI, XBoard a graphical user interface in GTK for AdaChess may be useful for 
>> some graphics materials:
>> https://www.gnu.org/software/xboard
>> and source code:
>> http://ftp.gnu.org/gnu/xboard
>> 
>> HTH, Pascal.
>> http://blady.pagesperso-orange.fr
>> 
>> 
>>> Le 8 nov. 2016 à 22:32, David Botton  a écrit :
>>> 
>>> http://adachess.com
>>> 
>>> Someone interested in writing a front end for AdaChess in Gnoga, shouldn't 
>>> be too hard.
>>> 
>>> David Botton
>> 

--
___
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list