From 25d96515ee9ebae1604c9ee4d6d5e2bcb2da7b3f Mon Sep 17 00:00:00 2001 From: sander Date: Tue, 15 Nov 2022 20:52:37 +0100 Subject: [PATCH 001/120] re added code that was missing after merge --- game/src/maschienen/maschiene.rs | 44 +++++++++++++++++++++++++ game/src/maschienen/maschiene_sprite.rs | 31 +++++++++++++++++ game/src/maschienen/trade.rs | 22 +++++++++++++ 3 files changed, 97 insertions(+) diff --git a/game/src/maschienen/maschiene.rs b/game/src/maschienen/maschiene.rs index 8b13789..dfbe053 100644 --- a/game/src/maschienen/maschiene.rs +++ b/game/src/maschienen/maschiene.rs @@ -1 +1,45 @@ +use std::default::default; +use ggez::graphics::Rect; +use crate::maschienen::maschiene_sprite::MaschineSprite; +pub enum State { + Broken, + Idel, + Running +} + +pub struct Maschine { + name: String, + hitbox: Rect, + interaction_area: Rect, + state: State, + sprite: MaschineSprite, + trades: Vec, + +} +impl Default for Maschine +{ + fn default() -> Self { + Self{ + name : String::default("Machiene ohne namen"), + hitbox : Rect::default(), + interaction_area:Rect::default(), + state: State::Broken, + sprite : MaschineSprite, + trades: vec![], + } + } +} + +impl Maschine { + + pub fn new(name: String, trades: Vec) -> Self { + + let loadedSprite: MaschineSprite = AssetService::get(name); + let default = Maschine::default(); + Self { name, hitbox:default.hitbox, interaction_area, state, sprite: loadedSprite, trades } + } + + + pub fn +} \ No newline at end of file diff --git a/game/src/maschienen/maschiene_sprite.rs b/game/src/maschienen/maschiene_sprite.rs index 8b13789..e2f1d53 100644 --- a/game/src/maschienen/maschiene_sprite.rs +++ b/game/src/maschienen/maschiene_sprite.rs @@ -1 +1,32 @@ +use ggez::graphics::{Image}; + +pub struct MaschineSprite { + name:String, + idel:Image, + broken: Image, + running: Image, +} + +impl Default for MaschineSprite{ + fn default() -> Self { + Self{ + name: String::default("Machiene ohne namen"), + idel: Image(), + broken: Image(), + running: Image() + } + } +} + + +impl MaschineSprite { + + pub fn name(&self) -> String { + self.name + } + pub fn new(name: String, idel: Image, broken: Image, running: Image) -> Self { + Self { name, idel, broken, running } + } + +} diff --git a/game/src/maschienen/trade.rs b/game/src/maschienen/trade.rs index 8b13789..84c1a34 100644 --- a/game/src/maschienen/trade.rs +++ b/game/src/maschienen/trade.rs @@ -1 +1,23 @@ +use std::collections::HashMap; +use std::path::Iter; +use ggez::glam::Vec2; +use super::super::game_core::item; +struct Trade { + time_ms: usize, + cost: HashMap, + result: item, + amount_produced: usize, +} + +impl Default for Trade { + fn default() -> Self { + + Self{ + time_ms:1000, + cost:HashMap::default(), + result:item, + amount_produced: 0 + } + } +} \ No newline at end of file From 78ef845991ab61de56ae7511d0eb0a0bb92ff778 Mon Sep 17 00:00:00 2001 From: mfloto <60036186+mfloto@users.noreply.github.com> Date: Tue, 15 Nov 2022 21:21:52 +0100 Subject: [PATCH 002/120] -Added deathscreen from old branch -Fixed dependencies (except Buttons, see #45) --- game/src/game_core/deathscreen.rs | 69 +++++++++++++++++++++++++++++++ game/src/game_core/mod.rs | 1 + 2 files changed, 70 insertions(+) create mode 100644 game/src/game_core/deathscreen.rs diff --git a/game/src/game_core/deathscreen.rs b/game/src/game_core/deathscreen.rs new file mode 100644 index 0000000..690432b --- /dev/null +++ b/game/src/game_core/deathscreen.rs @@ -0,0 +1,69 @@ +//TODO: refactor buttons first +use crate::main_menu::mainmenu::Button; +use crate::RedResult; +use ggez::{graphics, Context}; +use std::fmt::{Debug, Formatter}; +use ggez::winit::event::VirtualKeyCode; +use crate::backend::screen::{Screen, StackCommand}; +use crate::backend::utils::get_scale; + +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum DeathReason { + Oxygen, + Energy, +} + +const DEATH_MESSAGES: [&str; 2] = [ + "You died because you ran out of oxygen!", + "You died because you ran out of energy!", +]; + +#[derive(Debug)] +pub struct DeathScreen { + buttons: Vec