From 4c4aa45b5595990af3fc674b0c912be0d278be1e Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Fri, 10 Jul 2015 20:11:19 -0400 Subject: SHERLOCK: RT: Beginnings of darts minigame --- engines/sherlock/module.mk | 1 + engines/sherlock/tattoo/tattoo.cpp | 27 ++++++- engines/sherlock/tattoo/tattoo.h | 3 + engines/sherlock/tattoo/tattoo_darts.cpp | 131 +++++++++++++++++++++++++++++++ engines/sherlock/tattoo/tattoo_darts.h | 81 +++++++++++++++++++ 5 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 engines/sherlock/tattoo/tattoo_darts.cpp create mode 100644 engines/sherlock/tattoo/tattoo_darts.h (limited to 'engines/sherlock') diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk index 9997301710..c1591b647c 100644 --- a/engines/sherlock/module.mk +++ b/engines/sherlock/module.mk @@ -20,6 +20,7 @@ MODULE_OBJS = \ scalpel/scalpel_user_interface.o \ scalpel/settings.o \ tattoo/tattoo.o \ + tattoo/tattoo_darts.o \ tattoo/tattoo_fixed_text.o \ tattoo/tattoo_inventory.o \ tattoo/tattoo_journal.o \ diff --git a/engines/sherlock/tattoo/tattoo.cpp b/engines/sherlock/tattoo/tattoo.cpp index ab2e541bad..f6dd156ac3 100644 --- a/engines/sherlock/tattoo/tattoo.cpp +++ b/engines/sherlock/tattoo/tattoo.cpp @@ -33,7 +33,7 @@ namespace Sherlock { namespace Tattoo { TattooEngine::TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc) : - SherlockEngine(syst, gameDesc) { + SherlockEngine(syst, gameDesc), _darts(this) { _creditsActive = false; _runningProlog = false; _fastMode = false; @@ -80,16 +80,35 @@ void TattooEngine::initialize() { } void TattooEngine::startScene() { - if (_scene->_goToScene == OVERHEAD_MAP || _scene->_goToScene == OVERHEAD_MAP2) { + switch (_scene->_goToScene) { + case OVERHEAD_MAP: + case OVERHEAD_MAP2: // Show the map _scene->_currentScene = OVERHEAD_MAP; _scene->_goToScene = _map->show(); _people->_savedPos = Common::Point(-1, -1); _people->_savedPos._facing = -1; - } + break; - // TODO + case 101: + // Darts Board minigame + _darts.playDarts(GAME_CRICKET); + break; + + case 102: + // Darts Board minigame + _darts.playDarts(GAME_301); + break; + + case 103: + // Darts Board minigame + _darts.playDarts(GAME_501); + break; + + default: + break; + } _events->setCursor(ARROW); } diff --git a/engines/sherlock/tattoo/tattoo.h b/engines/sherlock/tattoo/tattoo.h index 57415c1c51..4c7977bd35 100644 --- a/engines/sherlock/tattoo/tattoo.h +++ b/engines/sherlock/tattoo/tattoo.h @@ -24,6 +24,7 @@ #define SHERLOCK_TATTOO_H #include "sherlock/sherlock.h" +#include "sherlock/tattoo/tattoo_darts.h" namespace Sherlock { @@ -52,6 +53,8 @@ enum { class TattooEngine : public SherlockEngine { private: + Darts _darts; + /** * Loads the initial palette for the game */ diff --git a/engines/sherlock/tattoo/tattoo_darts.cpp b/engines/sherlock/tattoo/tattoo_darts.cpp new file mode 100644 index 0000000000..05113da958 --- /dev/null +++ b/engines/sherlock/tattoo/tattoo_darts.cpp @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "sherlock/tattoo/tattoo_darts.h" +#include "sherlock/tattoo/tattoo.h" + +namespace Sherlock { + +namespace Tattoo { + +Darts::Darts(SherlockEngine *vm) : _vm(vm) { + _gameType = GAME_301; + _hand1 = _hand2 = nullptr; + _dartGraphics = nullptr; + _dartsLeft = nullptr; + _dartMap = nullptr; + _dartBoard = nullptr; + Common::fill(&_cricketScore[0][0], &_cricketScore[0][7], 0); + Common::fill(&_cricketScore[1][0], &_cricketScore[1][7], 0); + _score1 = _score2 = 0; + _roundNum = 0; + _level = 0; +} + +void Darts::playDarts(GameType gameType) { + +} + +void Darts::initDarts() { + _dartInfo = Common::Rect(430, 50, 430 + 205, 50 + 330); + + if (_gameType == GAME_CRICKET) { + _dartInfo = Common::Rect(430, 245, 430 + 205, 245 + 150); + } + + Common::fill(&_cricketScore[0][0], &_cricketScore[0][7], 0); + Common::fill(&_cricketScore[1][0], &_cricketScore[1][7], 0); + + switch (_gameType) { + case GAME_501: + _score1 = _score2 = 501; + _gameType = GAME_301; + break; + + case GAME_301: + _score1 = _score2 = 301; + break; + + default: + // Cricket + _score1 = _score2 = 0; + break; + } + + _roundNum = 1; + + if (_level == 9) { + // No computer players + _compPlay = 0; + _level = 0; + } else if (_level == 8) { + _level = _vm->getRandomNumber(3); + _compPlay = 2; + } else { + // Check for opponent flags + for (int idx = 0; idx < 4; ++idx) { + if (_vm->readFlags(314 + idx)) + _level = idx; + } + } + + _opponent = "Jock"; +} + +void Darts::loadDarts() { + Resources &res = *_vm->_res; + Screen &screen = *_vm->_screen; + byte palette[PALETTE_SIZE]; + + // Load images + _hand1 = new ImageFile("hand1.vgs"); + _hand2 = new ImageFile("hand2.vgs"); + _dartGraphics = new ImageFile("darts.vgs"); + _dartsLeft = new ImageFile("DartsLft.vgs"); + _dartMap = new ImageFile("DartMap.vgs"); + _dartBoard = new ImageFile("DartBd.vgs"); + + // Load and set the palette + Common::SeekableReadStream *stream = res.load("DartBoard.pal"); + stream->read(palette, PALETTE_SIZE); + screen.translatePalette(palette); + screen.setPalette(palette); + delete stream; + + // Load the initial background + screen._backBuffer1.blitFrom((*_dartBoard)[0], Common::Point(0, 0)); + screen._backBuffer2.blitFrom(screen._backBuffer1); + screen.blitFrom(screen._backBuffer1); +} + +void Darts::closeDarts() { + delete _dartBoard; + delete _dartsLeft; + delete _dartGraphics; + delete _dartMap; + delete _hand1; + delete _hand2; +} + +} // End of namespace Tattoo + +} // End of namespace Sherlock diff --git a/engines/sherlock/tattoo/tattoo_darts.h b/engines/sherlock/tattoo/tattoo_darts.h new file mode 100644 index 0000000000..762eb35c83 --- /dev/null +++ b/engines/sherlock/tattoo/tattoo_darts.h @@ -0,0 +1,81 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef SHERLOCK_TATTOO_DARTS_H +#define SHERLOCK_TATTOO_DARTS_H + +#include "common/scummsys.h" +#include "sherlock/image_file.h" + +namespace Sherlock { + +class SherlockEngine; + +namespace Tattoo { + +enum GameType { GAME_301, GAME_CRICKET, GAME_501 }; + +class Darts { +private: + SherlockEngine *_vm; + GameType _gameType; + ImageFile *_hand1, *_hand2; + ImageFile *_dartGraphics; + ImageFile *_dartsLeft; + ImageFile *_dartMap; + ImageFile *_dartBoard; + Common::Rect _dartInfo; + int _cricketScore[2][7]; + int _score1, _score2; + int _roundNum; + int _level; + int _compPlay; + Common::String _opponent; + + /** + * Initialize game variables + */ + void initDarts(); + + /** + * Load dartboard graphics + */ + void loadDarts(); + + /** + * Free loaded dart images + */ + void closeDarts(); +public: + Darts(SherlockEngine *vm); + + /** + * Play the darts game + */ + void playDarts(GameType gameType); +}; + +} // End of namespace Tattoo + +} // End of namespace Sherlock + +#endif -- cgit v1.2.3