Skip to content

Commit 77da729

Browse files
committed
Added black mask around the player
1 parent 1fa9b86 commit 77da729

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rand;
77

88
use ggez::conf::{NumSamples, WindowSetup, WindowMode, FullscreenType};
99
use ggez::event::{self, EventHandler};
10-
use ggez::graphics::{self, Text, DrawParam};
10+
use ggez::graphics::{self, Text, DrawParam, Rect, Color, MeshBuilder, DrawMode, FillOptions};
1111
use ggez::input::keyboard::{KeyCode, KeyMods};
1212
use ggez::nalgebra as na;
1313

@@ -29,6 +29,7 @@ struct MainState {
2929
start: Instant,
3030
found: u8,
3131
assets: Assets,
32+
hidden: bool
3233
}
3334

3435
impl MainState {
@@ -72,6 +73,7 @@ impl MainState {
7273
found: 0,
7374
player: Player::new(player_animations),
7475
assets,
76+
hidden: false
7577
})
7678
}
7779
}
@@ -83,6 +85,7 @@ impl EventHandler for MainState {
8385
self.info = Text::new(format!("{:02}", diff));
8486
} else {
8587
self.info = Text::new(format!("{}/3", self.found));
88+
self.hidden = true;
8689
}
8790

8891
Ok(())
@@ -96,6 +99,21 @@ impl EventHandler for MainState {
9699

97100
graphics::draw(ctx, &self.info, DrawParam::new().dest(na::Point2::new(725.0, 50.0)).scale(na::Vector2::new(2.0, 2.0)))?;
98101

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+
99117
graphics::present(ctx)?;
100118

101119
Ok(())

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy