Skip to content

Commit

Permalink
Patris v1.2 release
Browse files Browse the repository at this point in the history
 - print GAME OVER on screen
 - Fix movement latency by redrawing the board layer after an action
  • Loading branch information
Fabien-Chouteau committed Nov 4, 2015
1 parent b758065 commit 4d5a33f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
24 changes: 23 additions & 1 deletion projects/Patris/ada/src/game_window.adb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ package body Game_Window is
when Button_Id_Select => Action_Request (Turn_Counter_Clockwise);
when others => null;
end case;
Mark_Dirty (Board_Layer);
end if;
end Button_Handler;

Expand Down Expand Up @@ -104,10 +105,29 @@ package body Game_Window is
------------------------

procedure Update_Board_Layer (L : Layer; Ctx : Gcontext) is
pragma Unreferenced (L);
Bounds : constant Grect := Get_Bounds (L);
Over_Box : constant Grect :=
((5, Bounds.Size.H / 2 - 10), (Bounds.Size.W - 10, 20));
begin
Draw_Board (Ctx, Get_Board);
Draw_Walls (Ctx);

if Get_State = Game_Over then
Set_Fill_Color (Ctx, Colors.Black);
Fill_Rect (Ctx, Over_Box, Corners_Radius, Gcornersall);
Set_Stroke_Color (Ctx, Frames_Color);
Set_Stroke_Width (Ctx, 1);
Draw_Round_Rect (Ctx, Over_Box, Corners_Radius);

Set_Text_Color (Ctx, Colors.White);
Draw_Text (Ctx => Ctx,
Text => UI_Texts.Get_Str (UI_Texts.ID_Game_Over),
Font => Font,
Box => Over_Box,
Overflow_Mode => Gtextoverflowmodefill,
Alignment => Gtextalignmentcenter,
Cache => Null_Cacheref);
end if;
end Update_Board_Layer;

------------------------
Expand Down Expand Up @@ -196,9 +216,11 @@ package body Game_Window is
Redraw_Board, Redraw_Score, Redraw_Current_Piece : Boolean;
begin
Game_Step (Redraw_Board, Redraw_Score, Redraw_Current_Piece);

if Redraw_Board or else Redraw_Current_Piece then
Mark_Dirty (Board_Layer);
end if;

if Redraw_Score then
Mark_Dirty (Score_Layer);
end if;
Expand Down
5 changes: 3 additions & 2 deletions projects/Patris/ada/src/game_window.ads
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ with Interfaces.C; use Interfaces.C;
with Pebble.Graphics; use Pebble.Graphics;
package Game_Window is

Font_Txt : aliased char_array := "RESOURCE_ID_GOTHIC_14_BOLD";
Font_Txt : aliased char_array := "RESOURCE_ID_GOTHIC_14_BOLD" &
char (ASCII.NUL);
Corners_Radius : constant := 7;
Frames_Color : constant Gcolor := Colors.Blue;
Version_Txt : aliased char_array := "v1.1";
Version_Txt : aliased char_array := "v1.2" & char (ASCII.NUL);

procedure Push;

Expand Down
32 changes: 22 additions & 10 deletions projects/Patris/ada/src/ui_texts.adb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ with Strings_Interface; use Strings_Interface;
package body UI_Texts is

package En_US is
Str_Score : aliased char_array := "Score";
Str_Level : aliased char_array := "Level";
Str_Menu : aliased char_array := "Menu";
Str_Change_Level : aliased char_array := "change level:";
Str_Reset : aliased char_array := "Restart game";
Str_Reset_Long : aliased char_array := "Erase board and score";
Str_Best_Score : aliased char_array := "Best score";
Str_About : aliased char_array := "About";
Str_Score : aliased char_array :=
"Score" & char (ASCII.NUL);
Str_Level : aliased char_array :=
"Level" & char (ASCII.NUL);
Str_Menu : aliased char_array :=
"Menu" & char (ASCII.NUL);
Str_Change_Level : aliased char_array :=
"change level : " & char (ASCII.NUL);
Str_Reset : aliased char_array :=
"Restart game" & char (ASCII.NUL);
Str_Reset_Long : aliased char_array :=
"Erase board and score" & char (ASCII.NUL);
Str_Best_Score : aliased char_array :=
"Best score" & char (ASCII.NUL);
Str_About : aliased char_array :=
"About" & char (ASCII.NUL);
Str_Game_Over : aliased char_array :=
"GAME OVER" & char (ASCII.NUL);

Strings : constant array (Text_IDs) of Char_Array_Access :=
(ID_Score => Str_Score'Access,
ID_Level => Str_Level'Access,
Expand All @@ -20,10 +31,11 @@ package body UI_Texts is
ID_Reset => Str_Reset'Access,
ID_Reset_Game_Long => Str_Reset_Long'Access,
ID_Best_Score => Str_Best_Score'Access,
ID_About => Str_About'Access
ID_About => Str_About'Access,
ID_Game_Over => Str_Game_Over'Access
);

end En_US;

function Get_Str (Id : Text_IDs) return Strings_Interface.Chars_Ptr is
begin
return To_Chars_Ptr (En_US.Strings (Id));
Expand Down
2 changes: 1 addition & 1 deletion projects/Patris/ada/src/ui_texts.ads
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ with Strings_Interface;
package UI_Texts is
type Text_IDs is (ID_Score, ID_Level, ID_Menu, ID_Change_Level,
ID_Reset, ID_Reset_Game_Long, ID_Best_Score,
ID_About);
ID_About, ID_Game_Over);

function Get_Str (Id : Text_IDs) return Strings_Interface.Chars_Ptr;
end UI_Texts;
2 changes: 1 addition & 1 deletion projects/Patris/appinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"shortName": "Patris",
"longName": "Patris",
"companyName": "Fabien",
"versionLabel": "1.1",
"versionLabel": "1.2",
"sdkVersion": "3",
"targetPlatforms": ["basalt"],
"watchapp": {
Expand Down

0 comments on commit 4d5a33f

Please sign in to comment.