Skip to content

Commit

Permalink
SHERLOCK: RT: Beginnings of darts minigame
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 11, 2015
1 parent 3a0fb8a commit 4c4aa45
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 4 deletions.
1 change: 1 addition & 0 deletions engines/sherlock/module.mk
Expand Up @@ -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 \
Expand Down
27 changes: 23 additions & 4 deletions engines/sherlock/tattoo/tattoo.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions engines/sherlock/tattoo/tattoo.h
Expand Up @@ -24,6 +24,7 @@
#define SHERLOCK_TATTOO_H

#include "sherlock/sherlock.h"
#include "sherlock/tattoo/tattoo_darts.h"

namespace Sherlock {

Expand Down Expand Up @@ -52,6 +53,8 @@ enum {

class TattooEngine : public SherlockEngine {
private:
Darts _darts;

/**
* Loads the initial palette for the game
*/
Expand Down
131 changes: 131 additions & 0 deletions 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
81 changes: 81 additions & 0 deletions 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

0 comments on commit 4c4aa45

Please sign in to comment.