Compare commits

..

No commits in common. "22007e22a3a6c4bc83af17c48cc55563bd5da4bb" and "b8140d49d548b6ecc188012fa76f4041bd7602a8" have entirely different histories.

3 changed files with 6 additions and 13 deletions

View file

@ -1,7 +1,7 @@
use std::{path::PathBuf, sync::LazyLock};
use include_dir::{include_dir, Dir};
use rusqlite::{config::DbConfig, params, Connection};
use rusqlite::{params, Connection};
use rusqlite_migration::Migrations;
static MIGRATIONS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/migrations");
@ -10,20 +10,15 @@ static MIGRATIONS: LazyLock<Migrations<'static>> =
LazyLock::new(|| Migrations::from_directory(&MIGRATIONS_DIR).unwrap());
static ASSETS_DB: LazyLock<PathBuf> = LazyLock::new(|| {
let d = dirs::data_dir().unwrap_or(".".into()).join("autobarts");
std::fs::create_dir_all(&d)
.unwrap_or_else(|e| panic!("could not create autobarts data dir {d:?}: {e}"));
d.join("assets.db")
dirs::data_dir()
.unwrap_or(".".into())
.join("autobarts")
.join("assets.db")
});
pub fn init_db() -> Result<Connection, String> {
let mut conn = Connection::open(&*ASSETS_DB).map_err(|e| format!("oh shit: {e}"))?;
conn.set_db_config(DbConfig::SQLITE_DBCONFIG_ENABLE_FKEY, true)
.map_err(|e| format!("oh shit: {e}"))?;
let _ = conn.pragma_update(None, "journal_mode", "WAL");
MIGRATIONS
.to_latest(&mut conn)
.map_err(|e| format!("oh shit: {e}"))?;

View file

@ -1,6 +1,5 @@
//! Renders a 2D scene containing a single, moving sprite.
use bevy::prelude::*;
use db::init_db;
mod db;
@ -19,7 +18,6 @@ enum Direction {
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
let conn = init_db().unwrap();
commands.spawn(Camera2d);
commands.spawn((
@ -32,7 +30,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
image_mode: SpriteImageMode::Tiled {
tile_x: true,
tile_y: true,
stretch_value: 1.0, // The image will tile every 128px
stretch_value: 0.5, // The image will tile every 128px
},
custom_size: Some(Vec2::splat(2048.0)),
..default()