switch to rocket

This commit is contained in:
Ponj 2024-11-14 20:46:45 -05:00
parent af5b623327
commit 3d36b53fa1
Signed by: p6nj
GPG key ID: 6FED68D87C479A59
9 changed files with 437 additions and 3510 deletions

3813
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,3 +1,10 @@
[workspace]
resolver = "2"
members = ["game", "server"]
[package]
name = "typonomy"
version = "0.1.0"
edition = "2021"
[dependencies]
rocket = "0"
shuttle-rocket = "*"
shuttle-runtime = "*"
tokio = "1"

BIN
dist/Roboto-Black.ttf vendored

Binary file not shown.

29
dist/index.html vendored
View file

@ -1,29 +0,0 @@
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
html,
body,
canvas {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background: black;
z-index: 0;
}
</style>
<title>Typonomy</title>
</head>
<body>
<canvas id="canvas" width="1280" height="720" cursor="auto"></canvas>
<script type="module">
import init from "./game.js";
init();
</script>
</body>
</html>

View file

@ -1,7 +0,0 @@
[package]
name = "game"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy = { version = "0.14", features = ["webgl2"] }

View file

@ -1,50 +0,0 @@
use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
use bevy::diagnostic::LogDiagnosticsPlugin;
use bevy::prelude::*;
use bevy::window::{MonitorSelection, WindowPosition};
fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(WindowPlugin {
primary_window: Some(Window {
prevent_default_event_handling: false,
canvas: Some("#canvas".to_string()),
position: WindowPosition::Centered(MonitorSelection::Current),
..default()
}),
..default()
}),
LogDiagnosticsPlugin::default(),
FrameTimeDiagnosticsPlugin,
))
.add_systems(Startup, setup)
.add_systems(Update, main_menu)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}
fn main_menu(mut commands: Commands, asset_server: Res<AssetServer>) {
let font = asset_server.load("/Roboto-Black.ttf");
let title_font = title_text_style(60.0, font.clone());
commands.spawn({
Text2dBundle {
text: Text::from_section("Hello world!", title_font.clone())
.with_justify(JustifyText::Center),
..default()
}
});
}
fn title_text_style(font_size: f32, font: Handle<Font>) -> TextStyle {
TextStyle {
font,
font_size,
color: Color::WHITE,
}
}

View file

@ -1,11 +0,0 @@
[package]
name = "shuttle-bevy-ex"
version = "0.1.0"
edition = "2021"
[dependencies]
axum = "0.7"
shuttle-axum = "*"
shuttle-runtime = "*"
tokio = "1"
tower-http = { version = "0", features = ["fs"] }

View file

@ -1,11 +0,0 @@
use axum::Router;
use tower_http::services::{ServeDir, ServeFile};
#[shuttle_runtime::main]
async fn main() -> shuttle_axum::ShuttleAxum {
let router = Router::new().nest_service(
"/",
ServeDir::new("dist").not_found_service(ServeFile::new("dist/index.html")),
);
Ok(router.into())
}

13
src/main.rs Normal file
View file

@ -0,0 +1,13 @@
use rocket::{get, routes};
#[get("/")]
fn index() -> &'static str {
"Hello, world!"
}
#[shuttle_runtime::main]
async fn main() -> shuttle_rocket::ShuttleRocket {
let rocket = rocket::build().mount("/", routes![index]);
Ok(rocket.into())
}