mirror of
https://github.com/Xevion/Pac-Man.git
synced 2025-12-09 14:07:57 -06:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24e8b3e3bc | ||
|
|
da0f4d856a | ||
|
|
aaf30efde7 | ||
|
|
89f1e71568 |
2
.github/workflows/build.yaml
vendored
2
.github/workflows/build.yaml
vendored
@@ -151,7 +151,7 @@ jobs:
|
||||
done
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
uses: actions/upload-pages-artifact@v4
|
||||
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
||||
with:
|
||||
path: "./dist/"
|
||||
|
||||
6
.github/workflows/coverage.yaml
vendored
6
.github/workflows/coverage.yaml
vendored
@@ -9,6 +9,8 @@ env:
|
||||
jobs:
|
||||
coverage:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
@@ -49,13 +51,13 @@ jobs:
|
||||
just coverage
|
||||
|
||||
- name: Download Coveralls CLI
|
||||
if: ${{ env.COVERALLS_REPO_TOKEN != '' }}
|
||||
run: |
|
||||
# use GitHub Releases URL instead of coveralls.io because they can't maintain their own files; it 404s
|
||||
curl -L https://github.com/coverallsapp/coverage-reporter/releases/download/v0.6.15/coveralls-linux-x86_64.tar.gz | tar -xz -C /usr/local/bin
|
||||
|
||||
- name: Upload coverage to Coveralls
|
||||
env:
|
||||
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
||||
if: ${{ env.COVERALLS_REPO_TOKEN != '' }}
|
||||
run: |
|
||||
if [ ! -f "lcov.info" ]; then
|
||||
echo "Error: lcov.info file not found. Coverage generation may have failed."
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,3 +18,4 @@ coverage.html
|
||||
|
||||
# Profiling output
|
||||
flamegraph.svg
|
||||
/profile.*
|
||||
|
||||
7
Justfile
7
Justfile
@@ -5,6 +5,8 @@ set windows-shell := ["powershell.exe", "-NoLogo", "-Command"]
|
||||
# You can use src\\\\..., but the filename alone is acceptable too
|
||||
coverage_exclude_pattern := "src\\\\app.rs|audio.rs|src\\\\error.rs|platform\\\\emscripten.rs"
|
||||
|
||||
binary_extension := if os() == "windows" { ".exe" } else { "" }
|
||||
|
||||
# !!! --ignore-filename-regex should be used on both reports & coverage testing
|
||||
# !!! --remap-path-prefix prevents the absolute path from being used in the generated report
|
||||
|
||||
@@ -31,3 +33,8 @@ coverage:
|
||||
--output-path lcov.info \
|
||||
--profile coverage \
|
||||
--no-fail-fast nextest
|
||||
|
||||
# Profile the project using 'samply'
|
||||
samply:
|
||||
cargo build --profile profile
|
||||
samply record ./target/profile/pacman{{ binary_extension }}
|
||||
|
||||
10
src/app.rs
10
src/app.rs
@@ -5,6 +5,7 @@ use crate::error::{GameError, GameResult};
|
||||
use crate::constants::{CANVAS_SIZE, LOOP_TIME, SCALE};
|
||||
use crate::game::Game;
|
||||
use crate::platform::get_platform;
|
||||
use sdl2::{AudioSubsystem, Sdl};
|
||||
|
||||
/// Main application wrapper that manages SDL initialization, window lifecycle, and the game loop.
|
||||
///
|
||||
@@ -15,6 +16,9 @@ pub struct App {
|
||||
pub game: Game,
|
||||
last_tick: Instant,
|
||||
focused: bool,
|
||||
// Keep SDL alive for the app lifetime so subsystems (audio) are not shut down
|
||||
_sdl_context: Sdl,
|
||||
_audio_subsystem: AudioSubsystem,
|
||||
}
|
||||
|
||||
impl App {
|
||||
@@ -31,8 +35,8 @@ impl App {
|
||||
pub fn new() -> GameResult<Self> {
|
||||
let sdl_context = sdl2::init().map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
let video_subsystem = sdl_context.video().map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
let _audio_subsystem = sdl_context.audio().map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
let _ttf_context = sdl2::ttf::init().map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
let audio_subsystem = sdl_context.audio().map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
// TTF context is initialized within Game::new where it is leaked for font usage
|
||||
let event_pump = sdl_context.event_pump().map_err(|e| GameError::Sdl(e.to_string()))?;
|
||||
|
||||
let window = video_subsystem
|
||||
@@ -65,6 +69,8 @@ impl App {
|
||||
game,
|
||||
focused: true,
|
||||
last_tick: Instant::now(),
|
||||
_sdl_context: sdl_context,
|
||||
_audio_subsystem: audio_subsystem,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user