mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-11 16:07:58 -06:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 163855b6e7 | |||
| 645d48aeae | |||
| ec800a88fc | |||
| abc37dee4e | |||
| 1ae7839275 |
14
.github/workflows/build.yaml
vendored
14
.github/workflows/build.yaml
vendored
@@ -11,8 +11,6 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build (${{ matrix.target }})
|
name: Build (${{ matrix.target }})
|
||||||
env:
|
|
||||||
VCPKG_SYSTEM_LIBRARIES: "OFF"
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -46,16 +44,18 @@ jobs:
|
|||||||
- name: Cache vcpkg
|
- name: Cache vcpkg
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
|
save-always: true # deprecated
|
||||||
path: target/vcpkg
|
path: target/vcpkg
|
||||||
key: ${{ runner.os }}-vcpkg-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
|
key: vcpkg-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.toml', 'Cargo.lock') }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-vcpkg-
|
${{ runner.os }}-vcpkg
|
||||||
|
vcpkg-${{ runner.os }}-${{ matrix.target }}-
|
||||||
|
|
||||||
- name: Vcpkg Linux Dependencies
|
- name: Vcpkg Linux Dependencies
|
||||||
if: runner.os == 'Linux'
|
if: runner.os == 'Linux'
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y build-essential gettext libltdl-dev
|
sudo apt-get install -y build-essential gettext libltdl-dev zlib1g-dev
|
||||||
|
|
||||||
- name: Vcpkg
|
- name: Vcpkg
|
||||||
run: |
|
run: |
|
||||||
@@ -91,7 +91,7 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Emscripten SDK
|
- name: Setup Emscripten SDK
|
||||||
uses: mymindstorm/setup-emsdk@v14
|
uses: pyodide/setup-emsdk@v15
|
||||||
with:
|
with:
|
||||||
version: 3.1.43
|
version: 3.1.43
|
||||||
actions-cache-folder: "emsdk-cache"
|
actions-cache-folder: "emsdk-cache"
|
||||||
@@ -125,7 +125,7 @@ jobs:
|
|||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
cp assets/site/{build.css,favicon.ico,index.html} dist
|
cp assets/site/{build.css,favicon.ico,index.html} dist
|
||||||
output_folder="target/wasm32-unknown-emscripten/release"
|
output_folder="target/wasm32-unknown-emscripten/release"
|
||||||
cp $output_folder/pacman.{wasm,js,data} dist
|
cp $output_folder/pacman.{wasm,js} $output_folder/deps/pacman.data dist
|
||||||
|
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@v3
|
||||||
|
|||||||
18
src/asset.rs
18
src/asset.rs
@@ -78,15 +78,17 @@ mod imp {
|
|||||||
#[cfg(target_os = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
mod imp {
|
mod imp {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::fs;
|
use sdl2::rwops::RWops;
|
||||||
use std::path::Path;
|
use std::io::Read;
|
||||||
pub fn get_asset_bytes(asset: Asset) -> Result<Cow<'static, [u8]>, AssetError> {
|
pub fn get_asset_bytes(asset: Asset) -> Result<Cow<'static, [u8]>, AssetError> {
|
||||||
let path = Path::new("assets/game").join(asset.path());
|
let path = format!("assets/game/{}", asset.path());
|
||||||
if !path.exists() {
|
let mut rwops = RWops::from_file(&path, "rb").map_err(|_| AssetError::NotFound(asset.path().to_string()))?;
|
||||||
return Err(AssetError::NotFound(asset.path().to_string()));
|
let len = rwops.len().ok_or_else(|| AssetError::NotFound(asset.path().to_string()))?;
|
||||||
}
|
let mut buf = vec![0u8; len];
|
||||||
let bytes = fs::read(&path)?;
|
rwops
|
||||||
Ok(Cow::Owned(bytes))
|
.read_exact(&mut buf)
|
||||||
|
.map_err(|e| AssetError::Io(std::io::Error::new(std::io::ErrorKind::Other, e)))?;
|
||||||
|
Ok(Cow::Owned(buf))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ impl Audio {
|
|||||||
let frequency = 44100;
|
let frequency = 44100;
|
||||||
let format = DEFAULT_FORMAT;
|
let format = DEFAULT_FORMAT;
|
||||||
let channels = 4;
|
let channels = 4;
|
||||||
let chunk_size = 128;
|
let chunk_size = 256; // 256 is minimum for emscripten
|
||||||
|
|
||||||
mixer::open_audio(frequency, format, 1, chunk_size).expect("Failed to open audio");
|
mixer::open_audio(frequency, format, 1, chunk_size).expect("Failed to open audio");
|
||||||
mixer::allocate_channels(channels);
|
mixer::allocate_channels(channels);
|
||||||
|
|||||||
Reference in New Issue
Block a user