From a6bdaace984e26d528c451ce858a73b2aa2400e0 Mon Sep 17 00:00:00 2001 From: Gnarwhal Date: Wed, 7 Aug 2024 05:08:06 +0000 Subject: [PATCH] Window --- .gitignore | 5 ++++ Cargo.toml | 14 ++++++++++ config/bindings.ron | 4 +++ config/display.ron | 4 +++ src/main.rs | 68 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 config/bindings.ron create mode 100644 config/display.ron create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f4c5cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.idea/ +target/ + +Cargo.lock + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..6e234de --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "djam_4" +version = "0.1.0" +authors = ["Gnarwhal "] +edition = "2018" + +[dependencies] +amethyst = "0.15.0" + +[features] +default = ["vulkan"] +empty = ["amethyst/empty"] +metal = ["amethyst/metal"] +vulkan = ["amethyst/vulkan"] diff --git a/config/bindings.ron b/config/bindings.ron new file mode 100644 index 0000000..093c4d2 --- /dev/null +++ b/config/bindings.ron @@ -0,0 +1,4 @@ +( + axes: {}, + actions: {} +) \ No newline at end of file diff --git a/config/display.ron b/config/display.ron new file mode 100644 index 0000000..3831bfa --- /dev/null +++ b/config/display.ron @@ -0,0 +1,4 @@ +( + title: "DJam 4!", + dimensions: Some((500, 500)) +) \ No newline at end of file diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..abf6662 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,68 @@ +/******************************************************************************* + * + * Copyright (c) 2020 Gnarwhal + * + * ----------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files(the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ + +use amethyst::{ + prelude::*, + input::{InputBundle, StringBindings}, + renderer::{ + RenderingBundle, + types::DefaultBackend, + plugins::{RenderFlat2D, RenderToWindow}, + }, + utils::application_root_dir, +}; + +pub struct DJam; + +impl SimpleState for DJam {} + +fn main() -> amethyst::Result<()> { + amethyst::start_logger(Default::default()); + + let app_root = application_root_dir()?; + + let assets_dir = app_root.join("assets"); + let display_config_path = app_root.join("config").join("display.ron"); + let binding_path = app_root.join("config").join("bindings.ron"); + + let input_bundle = InputBundle::::new().with_bindings_from_file(binding_path)?; + + let game_data = GameDataBuilder::default() + .with_bundle(input_bundle)? + .with_bundle( + RenderingBundle::::new() + .with_plugin( + RenderToWindow::from_config_path(display_config_path)? + .with_clear([0.0, 0.0, 0.0, 1.0]), + ) + .with_plugin(RenderFlat2D::default()) + )?; + + let mut game = Application::new(assets_dir, DJam,game_data)?; + game.run(); + + Ok(()) +}