Skip to content
Snippets Groups Projects
Commit 3d68fdb5 authored by radow's avatar radow
Browse files

hacky quick titlescreen

parent e4cca055
Branches
No related tags found
No related merge requests found
resources/title.png

15.3 KiB

......@@ -52,7 +52,7 @@ impl GameState {
if textures.is_ok() {
if font.is_ok() && huge.is_ok() {
Ok(GameState {
current_run: Run::new(),
current_run: Run::new(0),
high_score: 0,
textures: textures.unwrap(),
sounds: sounds.unwrap(),
......@@ -66,6 +66,7 @@ impl GameState {
} else {
Err(textures.err().unwrap())
}
}
}
......@@ -146,15 +147,21 @@ impl GameState {
Key::N => !is_player_alive && self.create_new_run(),
Key::W | Key::A | Key::S | Key::D | Key::Down | Key::Up | Key::Right | Key::Left => {
self.current_run.combat_log.level_up = false;
let moved = self.handle_user_movement(key, ctx);
if moved{
match key{
Key::A => self.current_run.player.orientation = -1.0,
Key::D => self.current_run.player.orientation = 1.0,
_ => {}
if is_player_alive && !is_treasure_choice{
let moved = self.handle_user_movement(key, ctx);
if moved{
match key{
Key::A => self.current_run.player.orientation = -1.0,
Key::D => self.current_run.player.orientation = 1.0,
_ => {}
}
}
return moved;
}
else {
return false;
}
return is_player_alive && !is_treasure_choice && moved;
}
Key::Space => {
self.current_run.combat_log.level_up = false;
......@@ -207,7 +214,7 @@ impl GameState {
}
fn create_new_run(&mut self) -> bool {
self.current_run = Run::new();
self.current_run = Run::new(config::PLAYER_STARTING_HP);
false
}
......@@ -215,7 +222,7 @@ impl GameState {
let player_position = self.current_run.level.get_player_position();
let target_position = GameState::calculate_target_position(player_position, key);
if player_position == target_position {
if player_position == target_position{
return false;
}
......@@ -438,9 +445,18 @@ impl GameState {
impl GameState {
fn draw_game_over(&mut self, ctx: &mut Context) {
Text::new("YOU ARE DEAD", self.font_huge.clone())
.draw(ctx, Vec2::new(500.0, 400.0));
self.draw_string("For a new run, press 'N'!".parse().unwrap(), 500.0, 460.0, ctx);
self.textures.title.draw(ctx, DrawParams{
position: Vec2::new(0.0,0.0),
scale: Vec2::new(1.0,1.0),
origin: Vec2::new(0.0,0.0),
rotation: 0.0,
color: Color::WHITE,
});
Text::new("For a new run, press 'N'!", self.font_huge.clone())
.draw(ctx, Vec2::new(700.0, 950.0));
//self.draw_string("For a new run, press 'N'!".parse().unwrap(), 550.0, 50.0, ctx);
}
fn draw_board(&mut self, ctx: &mut Context) {
......@@ -614,6 +630,9 @@ impl GameState {
}
fn draw_stats(&self, ctx: &mut Context) {
if self.current_run.player.current_hp <= 0{
return
}
let text_top = GameState::calculate_text_top();
let stats_string = format!(
"Health: {} / {} Damage: {} + 1d{}",
......@@ -636,6 +655,9 @@ impl GameState {
}
fn draw_combat_log(&self, ctx: &mut Context) {
if self.current_run.player.current_hp <= 0{
return
}
if let Some(treasure_choice) = self.current_run.combat_log.treasure_choice {
self.draw_treasure_choice(treasure_choice.0, treasure_choice.1, ctx);
} else {
......
use std::usize;
use crate::game_state::player::Player;
use crate::game_state::level::Level;
use crate::game_state::config;
......@@ -11,8 +13,8 @@ pub struct Run {
}
impl Run {
pub fn new() -> Run {
let hp = config::PLAYER_STARTING_HP;
pub fn new(hp: usize) -> Run {
//let hp = config::PLAYER_STARTING_HP;
let ap = config::PLAYER_STARTING_AP;
let weapon = config::PLAYER_STARTING_WEAPON;
......
......@@ -11,6 +11,7 @@ pub struct Textures {
pub enemy: Texture,
pub treasure: Texture,
pub exit: Texture,
pub title: Texture,
}
impl Textures {
......@@ -25,6 +26,7 @@ impl Textures {
enemy: Texture::new(ctx, "./resources/foe.png")?,
treasure: Texture::new(ctx, "./resources/chest.png")?,
exit: Texture::new(ctx, "./resources/stairs.png")?,
title: Texture::new(ctx, "./resources/title.png")?,
})
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment