@@ -7,7 +7,7 @@ use rand;
7
7
8
8
use ggez:: conf:: { NumSamples , WindowSetup , WindowMode , FullscreenType } ;
9
9
use ggez:: event:: { self , EventHandler } ;
10
- use ggez:: graphics:: { self , Text , DrawParam } ;
10
+ use ggez:: graphics:: { self , Text , DrawParam , Rect , Color , MeshBuilder , DrawMode , FillOptions } ;
11
11
use ggez:: input:: keyboard:: { KeyCode , KeyMods } ;
12
12
use ggez:: nalgebra as na;
13
13
@@ -29,6 +29,7 @@ struct MainState {
29
29
start : Instant ,
30
30
found : u8 ,
31
31
assets : Assets ,
32
+ hidden : bool
32
33
}
33
34
34
35
impl MainState {
@@ -72,6 +73,7 @@ impl MainState {
72
73
found : 0 ,
73
74
player : Player :: new ( player_animations) ,
74
75
assets,
76
+ hidden : false
75
77
} )
76
78
}
77
79
}
@@ -83,6 +85,7 @@ impl EventHandler for MainState {
83
85
self . info = Text :: new ( format ! ( "{:02}" , diff) ) ;
84
86
} else {
85
87
self . info = Text :: new ( format ! ( "{}/3" , self . found) ) ;
88
+ self . hidden = true ;
86
89
}
87
90
88
91
Ok ( ( ) )
@@ -96,6 +99,21 @@ impl EventHandler for MainState {
96
99
97
100
graphics:: draw ( ctx, & self . info , DrawParam :: new ( ) . dest ( na:: Point2 :: new ( 725.0 , 50.0 ) ) . scale ( na:: Vector2 :: new ( 2.0 , 2.0 ) ) ) ?;
98
101
102
+ if self . hidden {
103
+ let ( x, y) = self . player . pos ;
104
+
105
+ let black = Color :: from_rgb ( 0 , 0 , 0 ) ;
106
+ let mut mesh = MeshBuilder :: new ( ) ;
107
+
108
+ mesh. rectangle ( DrawMode :: Fill ( FillOptions :: DEFAULT ) , Rect { x : 0.0 , y : 0.0 , w : x * 32.0 - 15.0 , h : 675.0 } , black. clone ( ) ) ;
109
+ mesh. rectangle ( DrawMode :: Fill ( FillOptions :: DEFAULT ) , Rect { x : x * 32.0 - 15.0 , y : 0.0 , w : 55.0 , h : y * 32.0 - 15.0 } , black. clone ( ) ) ;
110
+ mesh. rectangle ( DrawMode :: Fill ( FillOptions :: DEFAULT ) , Rect { x : x * 32.0 - 15.0 , y : y * 32.0 - 10.0 + 50.0 , w : 55.0 , h : 675.0 - y * 32.0 - 15.0 + 55.0 } , black. clone ( ) ) ;
111
+ mesh. rectangle ( DrawMode :: Fill ( FillOptions :: DEFAULT ) , Rect { x : x * 32.0 - 15.0 + 55.0 , y : 0.0 , w : 800.0 - x * 32.0 - 15.0 + 55.0 , h : 675.0 } , black. clone ( ) ) ;
112
+
113
+ let mesh = & mesh. build ( ctx) ?;
114
+ graphics:: draw ( ctx, mesh, ( na:: Point2 :: new ( 0.0 , 0.0 ) , ) ) ?;
115
+ }
116
+
99
117
graphics:: present ( ctx) ?;
100
118
101
119
Ok ( ( ) )
0 commit comments