From 33e4341a672875f717f791250c7c1509d4a2576d Mon Sep 17 00:00:00 2001 From: nick black Date: Fri, 10 Apr 2020 18:05:19 -0400 Subject: [PATCH] tetris: use background from installed path #466 --- src/tetris/background.h | 6 +++++- src/tetris/main.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tetris/background.h b/src/tetris/background.h index c1bddf674..b9bdfc42d 100644 --- a/src/tetris/background.h +++ b/src/tetris/background.h @@ -19,7 +19,11 @@ void DrawBackground(const std::string& s) { // drawn to the standard plane } void DrawBoard() { // draw all fixed components of the game - DrawBackground(BackgroundFile); + try{ + DrawBackground(BackgroundFile); + }catch(TetrisNotcursesErr& e){ + stdplane_->printf(1, 1, "couldn't load %s", BackgroundFile.c_str()); + } int y, x; stdplane_->get_dim(&y, &x); board_top_y_ = y - (BOARD_HEIGHT + 2); diff --git a/src/tetris/main.cpp b/src/tetris/main.cpp index ef6cd2c74..4920b1e88 100644 --- a/src/tetris/main.cpp +++ b/src/tetris/main.cpp @@ -8,7 +8,7 @@ #include #include "version.h" -const std::string BackgroundFile = "../data/tetris-background.jpeg"; +const std::string BackgroundFile = NOTCURSES_SHARE "/tetris-background.jpeg"; using namespace std::chrono_literals;