diff options
-rw-r--r-- | resources/fonts/SOBAD___.ttf | bin | 0 -> 50988 bytes | |||
-rw-r--r-- | resources/fonts/SOCOND__.ttf | bin | 0 -> 60708 bytes | |||
-rw-r--r-- | resources/fonts/SOEXT___.ttf | bin | 0 -> 57668 bytes | |||
-rw-r--r-- | resources/fonts/SONARR__.ttf | bin | 0 -> 55520 bytes | |||
-rw-r--r-- | resources/fonts/SONORM__.ttf | bin | 0 -> 55800 bytes | |||
-rw-r--r-- | resources/fonts/SOSHAD__.ttf | bin | 0 -> 117832 bytes | |||
-rw-r--r-- | resources/fonts/SOSUE___.ttf | bin | 0 -> 45124 bytes | |||
-rw-r--r-- | resources/fonts/SOWIDE__.ttf | bin | 0 -> 57184 bytes | |||
-rw-r--r-- | resources/fonts/readme.txt | 1 | ||||
-rw-r--r-- | src/constants.rs | 5 | ||||
-rw-r--r-- | src/dialogbox.rs | 61 | ||||
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/world.rs | 6 |
13 files changed, 73 insertions, 1 deletions
diff --git a/resources/fonts/SOBAD___.ttf b/resources/fonts/SOBAD___.ttf Binary files differnew file mode 100644 index 0000000..5787346 --- /dev/null +++ b/resources/fonts/SOBAD___.ttf diff --git a/resources/fonts/SOCOND__.ttf b/resources/fonts/SOCOND__.ttf Binary files differnew file mode 100644 index 0000000..f746afe --- /dev/null +++ b/resources/fonts/SOCOND__.ttf diff --git a/resources/fonts/SOEXT___.ttf b/resources/fonts/SOEXT___.ttf Binary files differnew file mode 100644 index 0000000..89e7425 --- /dev/null +++ b/resources/fonts/SOEXT___.ttf diff --git a/resources/fonts/SONARR__.ttf b/resources/fonts/SONARR__.ttf Binary files differnew file mode 100644 index 0000000..1c1e81a --- /dev/null +++ b/resources/fonts/SONARR__.ttf diff --git a/resources/fonts/SONORM__.ttf b/resources/fonts/SONORM__.ttf Binary files differnew file mode 100644 index 0000000..1768301 --- /dev/null +++ b/resources/fonts/SONORM__.ttf diff --git a/resources/fonts/SOSHAD__.ttf b/resources/fonts/SOSHAD__.ttf Binary files differnew file mode 100644 index 0000000..13c8e17 --- /dev/null +++ b/resources/fonts/SOSHAD__.ttf diff --git a/resources/fonts/SOSUE___.ttf b/resources/fonts/SOSUE___.ttf Binary files differnew file mode 100644 index 0000000..209354a --- /dev/null +++ b/resources/fonts/SOSUE___.ttf diff --git a/resources/fonts/SOWIDE__.ttf b/resources/fonts/SOWIDE__.ttf Binary files differnew file mode 100644 index 0000000..733063a --- /dev/null +++ b/resources/fonts/SOWIDE__.ttf diff --git a/resources/fonts/readme.txt b/resources/fonts/readme.txt new file mode 100644 index 0000000..63cf3c7 --- /dev/null +++ b/resources/fonts/readme.txt @@ -0,0 +1 @@ +This font is freeware and can be used as is in any context without permission from Apostrophic Laboratories, except to produce material that is racist, criminal and/or illegal in nature. It is prohibited to modify any Apostrophic Laboratories font(s) for repackaging and/or re-release without an express written authorization by the designer(s) of the font(s) or Apostrophic Laboratories. Under no circumstance shall any Apostrophic Laboratories design or font design be sold or purchased. Email info@apostrophiclab.com if you want more information. diff --git a/src/constants.rs b/src/constants.rs index 1f6bb9f..8a873c6 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,6 +1,6 @@ pub const TILE_WIDTH: f32 = 16.0; pub const TILE_HEIGHT: f32 = 16.0; -pub const TILE_SCALE: f32 = 2.5; +pub const TILE_SCALE: f32 = 2.75; pub const PLAYER_SPEED: f32 = 3.0; pub const WANDER_DISTANCE: f32 = 200.0; @@ -13,3 +13,6 @@ pub const FLIP_H: usize = 0x8000_0000; pub const FLIP_V: usize = 0x4000_0000; pub const FLIP_D: usize = 0x2000_0000; pub const FLIP_A: usize = FLIP_D | FLIP_H | FLIP_V; + +use ggez::graphics::Color; +pub const PURPLE: Color = Color::new(0.4, 0.0, 0.2, 1.0); diff --git a/src/dialogbox.rs b/src/dialogbox.rs new file mode 100644 index 0000000..1f6415b --- /dev/null +++ b/src/dialogbox.rs @@ -0,0 +1,61 @@ +use ggez::conf::Conf; +use ggez::graphics::{ + self, DrawMode, DrawParam, Font, Mesh, MeshBuilder, Rect, Scale, Text, TextFragment, +}; +use ggez::nalgebra::Point2; +use ggez::{Context, GameResult}; + +use crate::constants; + +pub struct DialogBox { + mesh: Mesh, + text: Text, + conf: Conf, + pub visible: bool, +} + +impl DialogBox { + pub fn new(context: &mut Context) -> DialogBox { + let conf = Conf::new(); + let font = Font::new(context, "/fonts/SONORM__.ttf").unwrap(); + + DialogBox { + text: Text::new( + TextFragment::new("Ave !") + .font(font) + .scale(Scale::uniform(40.0)), + ), + mesh: MeshBuilder::new() + .rectangle( + DrawMode::fill(), + Rect::new( + conf.window_mode.width * 0.10, + 2.5 * conf.window_mode.height / 4.0, + conf.window_mode.width * 0.80, + conf.window_mode.height / 4.0, + ), + constants::PURPLE, + ) + .build(context) + .unwrap(), + visible: false, + conf, + } + } + + pub fn draw(&self, context: &mut Context) -> GameResult { + if self.visible { + graphics::draw(context, &self.mesh, DrawParam::default())?; + graphics::draw( + context, + &self.text, + DrawParam::default().dest(Point2::new( + self.conf.window_mode.width * 0.11, + 2.6 * self.conf.window_mode.height / 4.0, + )), + )?; + } + + Ok(()) + } +} @@ -2,6 +2,7 @@ pub mod animations; pub mod camera; pub mod cell; pub mod constants; +pub mod dialogbox; pub mod entity; pub mod layer; pub mod map; diff --git a/src/world.rs b/src/world.rs index f89e9e7..abbb9c1 100644 --- a/src/world.rs +++ b/src/world.rs @@ -3,6 +3,7 @@ use ggez::graphics::{self, spritebatch::SpriteBatch, DrawParam, FilterMode, Imag use ggez::{filesystem, Context, GameResult}; use crate::camera::Camera; +use crate::dialogbox::DialogBox; use crate::entity::Operable; use crate::map::Map; use crate::npc::NPC; @@ -12,6 +13,7 @@ use crate::tileset::Tileset; pub struct World { map: Map, spritebatch: SpriteBatch, + dialogbox: DialogBox, camera: Camera, player: Player, npcs: Vec<NPC>, @@ -30,6 +32,7 @@ impl World { Ok(World { map: map.clone(), spritebatch: SpriteBatch::new(image), + dialogbox: DialogBox::new(context), camera: Camera::new(map.get_dimensions()), player: Player::new( &tileset, @@ -68,6 +71,8 @@ impl EventHandler for World { DrawParam::default().dest(self.camera.draw), )?; + self.dialogbox.draw(context)?; + self.spritebatch.clear(); graphics::present(context)?; @@ -89,6 +94,7 @@ impl EventHandler for World { if !repeat { match keycode { KeyCode::Q => context.continuing = false, + KeyCode::E => self.dialogbox.visible = !self.dialogbox.visible, _ => self.player.give_key_down(keycode), } } |