Skip to content

Commit cc1668a

Browse files
Updates for the menu screen
1 parent f49fac6 commit cc1668a

File tree

4 files changed

+25
-51
lines changed

4 files changed

+25
-51
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<img src="misc/thumbnail.png">
2-
3-
# Call of Ferris ( Ownership War )
1+
<p align="center"><img src="resources/images/logo.png"></p>
42

53
## Screenshots
64

resources/images/logo.png

4.86 KB
Loading

resources/images/menu_bg.png

294 KB
Loading

src/menu.rs

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
use ggez::{
2-
event::KeyCode,
3-
graphics::{self, Scale, Text, TextFragment},
4-
Context, GameResult,
5-
};
1+
use ggez::{Context, GameResult, event::KeyCode, graphics::{self, Scale, Text, TextFragment}, nalgebra::{Point2, Vector2}};
2+
use graphics::DrawParam;
63
use std::process::exit;
74

85
use crate::HEIGHT;
@@ -11,68 +8,47 @@ use crate::WIDTH;
118
pub struct Menu {
129
pub consolas: graphics::Font,
1310
pub ferris_ninja: graphics::Image,
11+
pub logo: graphics::Image,
12+
pub bg: graphics::Image
1413
}
1514

1615
impl Menu {
1716
pub fn create(ctx: &mut Context) -> Self {
1817
Self {
1918
consolas: graphics::Font::new(ctx, "/fonts/Consolas.ttf").unwrap(),
2019
ferris_ninja: graphics::Image::new(ctx, "/images/ferris_ninja.png").unwrap(),
20+
logo: graphics::Image::new(ctx, "/images/logo.png").unwrap(),
21+
bg: graphics::Image::new(ctx, "/images/menu_bg.png").unwrap(),
2122
}
2223
}
2324

2425
pub fn draw(&self, ctx: &mut Context) -> GameResult<()> {
2526
// Clear the screen
2627
graphics::clear(ctx, graphics::BLACK);
2728

28-
let title_call = TextFragment {
29-
text: "CALL".to_owned(),
30-
font: Some(self.consolas),
31-
scale: Some(Scale::uniform(30.0)),
32-
33-
..Default::default()
34-
};
35-
36-
let title_of = TextFragment {
37-
text: "OF".to_owned(),
38-
font: Some(self.consolas),
39-
scale: Some(Scale::uniform(15.0)),
40-
41-
..Default::default()
42-
};
43-
44-
let title_ferris = TextFragment {
45-
text: "FERRIS".to_owned(),
46-
font: Some(self.consolas),
47-
scale: Some(Scale::uniform(30.0)),
48-
49-
..Default::default()
50-
};
51-
52-
graphics::draw(
53-
ctx,
54-
&Text::new(title_call),
55-
(ggez::nalgebra::Point2::new(WIDTH - 220.0, 10.0),),
56-
)?;
57-
5829
graphics::draw(
5930
ctx,
60-
&Text::new(title_of),
61-
(ggez::nalgebra::Point2::new(WIDTH - 150.0, 20.0),),
31+
&self.bg,
32+
DrawParam::default()
33+
.dest(Point2::new(0.0, 0.0))
34+
.scale(Vector2::new(0.6, 0.5))
6235
)?;
6336

6437
graphics::draw(
6538
ctx,
66-
&Text::new(title_ferris),
67-
(ggez::nalgebra::Point2::new(WIDTH - 130.0, 10.0),),
39+
&self.logo,
40+
(ggez::nalgebra::Point2::new(
41+
WIDTH - (self.logo.width() as f32 + 20.0),
42+
10.0
43+
),),
6844
)?;
6945

7046
graphics::draw(
7147
ctx,
7248
&self.ferris_ninja,
7349
(ggez::nalgebra::Point2::new(
74-
WIDTH - (WIDTH - 100.0),
75-
HEIGHT - (&self.ferris_ninja.height() + 30) as f32,
50+
WIDTH - (WIDTH - 400.0),
51+
HEIGHT - (&self.ferris_ninja.height() + 140) as f32,
7652
),),
7753
)?;
7854

@@ -97,32 +73,32 @@ impl Menu {
9773
&Text::new(press_and_to),
9874
(ggez::nalgebra::Point2::new(
9975
WIDTH - 200.0,
100-
HEIGHT - (&self.ferris_ninja.height() + 60) as f32,
76+
HEIGHT - (&self.ferris_ninja.height() + 30) as f32,
10177
),),
10278
)?;
10379

10480
let play_rect = graphics::Mesh::new_rectangle(
10581
ctx,
10682
graphics::DrawMode::fill(),
10783
graphics::Rect::new(
108-
WIDTH - 260.0,
109-
HEIGHT - (&self.ferris_ninja.height() + 40) as f32,
84+
WIDTH - 200.0,
85+
HEIGHT - (&self.ferris_ninja.height() + 10) as f32,
11086
220.0,
11187
40.0,
11288
),
113-
[36.0 / 255.0, 36.0 / 255.0, 36.0 / 255.0, 1.0].into(),
89+
[36.0 / 255.0, 36.0 / 255.0, 36.0 / 255.0, 0.5].into(),
11490
)?;
11591

11692
let quit_rect = graphics::Mesh::new_rectangle(
11793
ctx,
11894
graphics::DrawMode::fill(),
11995
graphics::Rect::new(
120-
WIDTH - 260.0,
96+
WIDTH - 200.0,
12197
HEIGHT - (&self.ferris_ninja.height() - 70) as f32,
12298
220.0,
12399
40.0,
124100
),
125-
[36.0 / 255.0, 36.0 / 255.0, 36.0 / 255.0, 1.0].into(),
101+
[36.0 / 255.0, 36.0 / 255.0, 36.0 / 255.0, 0.5].into(),
126102
)?;
127103

128104
let play_text = TextFragment {
@@ -149,7 +125,7 @@ impl Menu {
149125
&Text::new(play_text),
150126
(ggez::nalgebra::Point2::new(
151127
WIDTH - 170.0,
152-
HEIGHT - (&self.ferris_ninja.height() + 28) as f32,
128+
HEIGHT - self.ferris_ninja.height() as f32,
153129
),),
154130
)?;
155131

0 commit comments

Comments
 (0)