Compare commits
3 Commits
3c447c764f
...
79e53e094f
Author | SHA1 | Date |
---|---|---|
dani | 79e53e094f | |
dani | 52dfaea7ed | |
dani | 11dd73c45a |
|
@ -1,2 +1,3 @@
|
||||||
/target
|
/target
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
|
/meow
|
|
@ -19,6 +19,9 @@ gilrs = "0.10.2"
|
||||||
winit = "0.28.6"
|
winit = "0.28.6"
|
||||||
softbuffer = "0.3.0"
|
softbuffer = "0.3.0"
|
||||||
gif = "0.12.0"
|
gif = "0.12.0"
|
||||||
|
clap = {version = "4.3.8", features = ["derive", "cargo"]}
|
||||||
|
dunce = "1.0.4"
|
||||||
|
path-slash = "0.2.1"
|
||||||
|
|
||||||
[profile.release-dani]
|
[profile.release-dani]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
|
@ -0,0 +1,16 @@
|
||||||
|
use gsa::{run, Gsa};
|
||||||
|
|
||||||
|
struct Game {}
|
||||||
|
|
||||||
|
fn init(gsa: &mut Gsa) -> Game {
|
||||||
|
//game initialisation code
|
||||||
|
gsa.sprites[0].tile = 0;
|
||||||
|
Game {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn update(game: &mut Game, gsa: &mut Gsa) {
|
||||||
|
gsa.sprites[0].pos += gsa.input_dir();
|
||||||
|
//once per frame code
|
||||||
|
}
|
||||||
|
|
||||||
|
run!(init, update);
|
|
@ -3,6 +3,8 @@
|
||||||
//! # Game Skunk Advance
|
//! # Game Skunk Advance
|
||||||
//! Game development library modelled after an imaginary console
|
//! Game development library modelled after an imaginary console
|
||||||
//!
|
//!
|
||||||
|
//! [Changelog](https://git.danitheskunk.com/DaniTheSkunk/gsa/src/branch/master/CHANGLOG.md)
|
||||||
|
//!
|
||||||
//! ## Specs
|
//! ## Specs
|
||||||
//! - Resolution: 304x176 (19x11 tiles)
|
//! - Resolution: 304x176 (19x11 tiles)
|
||||||
//! - Colors: 256 (indexed out of a possible 24-bit)
|
//! - Colors: 256 (indexed out of a possible 24-bit)
|
||||||
|
@ -57,7 +59,7 @@ pub const SCREEN_HEIGHT: usize = 176;
|
||||||
pub const BACKGROUND_MAX_SIZE: usize = 1024;
|
pub const BACKGROUND_MAX_SIZE: usize = 1024;
|
||||||
|
|
||||||
/// Tile considered empty (never drawn even if has contents)
|
/// Tile considered empty (never drawn even if has contents)
|
||||||
pub const EMPTY_TILE: u16 = 0xffff
|
pub const EMPTY_TILE: u16 = 0xffff;
|
||||||
|
|
||||||
/// Tile id of bold default font
|
/// Tile id of bold default font
|
||||||
pub const FONT_BOLD: u16 = 0xf000;
|
pub const FONT_BOLD: u16 = 0xf000;
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
use clap::{crate_name, crate_version, Parser, Subcommand};
|
||||||
|
use dunce::canonicalize;
|
||||||
|
use path_slash::PathExt;
|
||||||
|
use std::env::{current_dir, set_current_dir};
|
||||||
|
use std::fs;
|
||||||
|
use std::fs::{write, OpenOptions};
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::{exit, Command};
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
struct Cli {
|
||||||
|
#[command(subcommand)]
|
||||||
|
command: Cmd,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
enum Cmd {
|
||||||
|
/// Creates a new GSA project
|
||||||
|
New {
|
||||||
|
/// Name of new project
|
||||||
|
name: String,
|
||||||
|
/// Use local path to GSA instead of crates.io
|
||||||
|
#[arg(long, short)]
|
||||||
|
local: Option<PathBuf>,
|
||||||
|
/// Overwrite dir/file with name? WARNING: will delete stuff without further confirmation
|
||||||
|
#[arg(long)]
|
||||||
|
overwrite: bool,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let cli = Cli::parse();
|
||||||
|
|
||||||
|
match cli.command {
|
||||||
|
Cmd::New {
|
||||||
|
name,
|
||||||
|
local,
|
||||||
|
overwrite,
|
||||||
|
} => {
|
||||||
|
println!("creating {}", name);
|
||||||
|
let path = Path::new(&name);
|
||||||
|
if path.exists() {
|
||||||
|
if overwrite {
|
||||||
|
if path.is_dir() {
|
||||||
|
fs::remove_dir_all(path).unwrap();
|
||||||
|
} else {
|
||||||
|
fs::remove_file(path).unwrap();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
eprintln!(
|
||||||
|
"aborting: file or directory {} already exists; use --overwrite if you want to delete it",
|
||||||
|
name
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !Command::new("cargo")
|
||||||
|
.arg("new")
|
||||||
|
.arg(&name)
|
||||||
|
.status()
|
||||||
|
.unwrap()
|
||||||
|
.success()
|
||||||
|
{
|
||||||
|
eprintln!("aborting: cargo new failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
let mut cargo = OpenOptions::new()
|
||||||
|
.write(true)
|
||||||
|
.append(true)
|
||||||
|
.open(path.join("Cargo.toml"))
|
||||||
|
.expect("opening Cargo.toml failed");
|
||||||
|
match local {
|
||||||
|
None => {
|
||||||
|
writeln!(cargo, "{} = \"{}\"", crate_name!(), crate_version!()).unwrap();
|
||||||
|
}
|
||||||
|
Some(local) => {
|
||||||
|
writeln!(
|
||||||
|
cargo,
|
||||||
|
"{} = {{path = \"{}\"}}",
|
||||||
|
crate_name!(),
|
||||||
|
canonicalize(local)
|
||||||
|
.expect("couldn't find path")
|
||||||
|
.to_slash_lossy()
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write(
|
||||||
|
path.join("src/main.rs"),
|
||||||
|
include_str!("../examples/hello_world/main.rs"),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
write(
|
||||||
|
path.join("src/gfx.gif"),
|
||||||
|
include_bytes!("../examples/hello_world/gfx.gif"),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue