Stubbing out tetris game
parent
b576de94e4
commit
277260ecf6
@ -0,0 +1,53 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Create tetris game with camera that renders to subset of viewport
|
||||||
|
///
|
||||||
|
/// Focus on a single piece and making it really tight mechanically
|
||||||
|
/// A single piece with movement, rotation, jump-to-end, line clearing, etc.
|
||||||
|
///
|
||||||
|
/// Once done, make pieces a data input so we can add arbitrary metadata to them
|
||||||
|
pub struct BlocksPlugin;
|
||||||
|
|
||||||
|
impl Plugin for BlocksPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app.add_systems(Startup, init_blocks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Shape asset
|
||||||
|
/// Stores shape data in an asset file, likely toml
|
||||||
|
#[derive(Asset, TypePath, Debug, Deserialize)]
|
||||||
|
struct ShapeAsset {
|
||||||
|
layout: Vec<Vec<u8>>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct ShapeAssetLoader;
|
||||||
|
|
||||||
|
impl AssetLoader for ShapeAssetLoader {
|
||||||
|
type Asset = ShapeAsset;
|
||||||
|
type Settings = ();
|
||||||
|
type Error = ();
|
||||||
|
async fn load(
|
||||||
|
&self,
|
||||||
|
reader: &mut dyn Reader,
|
||||||
|
_settings: &(),
|
||||||
|
_load_context: &mut LoadContext<'_>,
|
||||||
|
) -> Result<Self::Asset, Self::Error> {
|
||||||
|
let mut bytes = Vec::new();
|
||||||
|
reader.read_to_end(&mut bytes).await.unwrap_or(());
|
||||||
|
let shape_asset = toml::from_slice::<ShapeAsset>(bytes.into()).unwrap_or(());
|
||||||
|
Ok(shape_asset)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extension(&self) -> &[str] {
|
||||||
|
&["shape.toml"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Initialize camera and block game area
|
||||||
|
fn init_blocks(
|
||||||
|
mut commands: Commands,
|
||||||
|
) {
|
||||||
|
commands.spawn((Camera2d, Camera::default()));
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Debug UI for Tetris
|
||||||
|
/// Some overlap with more general purpose debug tools,
|
||||||
|
/// but built one-off because of the changse to UI in Bevy 0.17
|
||||||
|
|
||||||
|
struct DebugPlugin;
|
||||||
|
|
||||||
|
impl Plugin for DebugPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
/// Create figher game that renders to another subset of the viewport
|
||||||
|
///
|
||||||
|
/// Focus on a single fighter class with a single enemy (blob) to start with
|
||||||
|
/// Once damage both ways is tight, add multiple enemies as assets
|
||||||
|
pub struct FighterPlugin;
|
||||||
|
|
||||||
|
impl Plugin for FighterPlugin {
|
||||||
|
fn build(&self, app: &mut App) {
|
||||||
|
app;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue