Skip to content

Commit

Permalink
Simulate behavior of flippers when the game has ended (i.e. they cann…
Browse files Browse the repository at this point in the history
…ot be used)

Change on-screen messages related to configuration (reset and ball launch). Also make it possible to change the "reset" key, instead of it being hard-coded.

Add modification notices.
  • Loading branch information
c30zD authored and sergiomb2 committed Mar 24, 2018
1 parent 925793a commit 631b4d0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
8 changes: 8 additions & 0 deletions data/gnu/ModuleGnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
copyright : (C) 2001 by Henrik Enqvist
(C) 2013 Ben Asselstine
email : [email protected]
========================= Modifications =========================
Apr. 6, 2017:
Send the "game_start" signal. (c30zD)
***************************************************************************/

#include "Private.h"
Expand Down Expand Up @@ -334,6 +341,7 @@ class GnuBehavior : public Behavior {
//which ball do we activate if we just locked a ball?
int i = getFirstDeadBall();
if (i > -1) {
if (i == 0) SendSignal(loader->getSignal("game_start"), 0, this->getParent(), NULL);
SendSignal( PBL_SIG_BALL_ON, 0, this->getParent(), NULL );
table->activateBall(i, 19.5f, 0.0f, 30.0f);
m_iCurrentBallSlot = i;
Expand Down
21 changes: 18 additions & 3 deletions src/ArmBehavior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
begin : Wed Jan 26 2000
copyright : (C) 2000 by Henrik Enqvist
email : [email protected]
========================= Modifications =========================
Apr. 6, 2017:
- Replace name of "m_bOn" with "m_bActive". (c30zD)
- Add events for game over and game start signals. (c30zD)
- Modify function doArm to also use m_bActive. (c30zD)
***************************************************************************/

#include "Private.h"
Expand All @@ -19,7 +28,7 @@ ArmBehavior::ArmBehavior(bool right) : Behavior() {
m_bTilt = false;
m_bRight = right;
m_iCount = 0;
m_bOn = false;
m_bActive = false;
m_iSound = -1;
m_bFirst = true;
this->setType(PBL_TYPE_ARMBEH);
Expand All @@ -35,15 +44,21 @@ void ArmBehavior::StdOnSignal() {
this->getParent()->setUserProperty(PBL_UNACTIVE_ARM);
this->getParent()->unsetUserProperty(PBL_ACTIVE_ARM);
this->getParent()->setRotation(0.0f, m_vtxRot.y, 0.0f);
m_bOn = false;
m_bActive = false;
}
ElseOnSignal(PBL_SIG_TILT) {
m_bTilt = true;
}
ElseOnSignal(PBL_SIG_GAME_START) {
m_bActive = true;
}
ElseOnSignal(PBL_SIG_GAME_OVER) {
m_bActive = false;
}
}

void ArmBehavior::doArm(EMKey key) {
if (Keyboard::isKeyDown(key) && !m_bTilt) {
if (Keyboard::isKeyDown(key) && !m_bTilt && m_bActive) {
if (m_iCount < 10) {
m_iCount++;
this->getParent()->setUserProperty(PBL_ACTIVE_ARM);
Expand Down
9 changes: 8 additions & 1 deletion src/ArmBehavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
begin : Wed Jan 26 2000
copyright : (C) 2000 by
email :
========================= Modifications =========================
Apr. 6, 2017:
Replace name of "m_bOn" with "m_bActive". (c30zD)
***************************************************************************/

#ifndef ARMBEHAVIOR_H
Expand Down Expand Up @@ -33,7 +40,7 @@ class ArmBehavior : public Behavior {
Vertex3D m_vtxRot;
bool m_bRight;
int m_iCount;
bool m_bOn;
bool m_bActive;
int m_iSound;
bool m_bFirst;
bool m_bTilt;
Expand Down
9 changes: 8 additions & 1 deletion src/Pinball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
begin : Thu Mar 9 2000
copyright : (C) 2000-2016 by Henrik Enqvist
email : [email protected]
========================= Modifications =========================
Dec. 9, 2017:
Reset key is no longer hard-coded. (c30zD)
***************************************************************************/

#include <fstream>
Expand Down Expand Up @@ -823,7 +830,7 @@ int main(int argc, char *argv[]) {
SoundUtil::getInstance()->resumeMusic();
}

if (Keyboard::isKeyDown(SDLK_r)) {
if (Keyboard::isKeyDown(Config::getInstance()->getKey("reset"))) {
SendSignal(PBL_SIG_RESET_ALL, 0, engine, NULL);
}

Expand Down
12 changes: 10 additions & 2 deletions src/Score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
modifs
20030510 pnf : Display message ExtraBall when flag activated
for current ball.
20171209 c30zD : Correctly display the "reset" and "launch" keys.
***************************************************************************/

Expand Down Expand Up @@ -82,10 +83,14 @@ void Score::onTick() {

void Score::StdOnSignal() {
EM_COUT((int)em_signal, 1);
Config *cfg = Config::getInstance();

OnSignal( PBL_SIG_RESET_ALL ) {
this->clear();
this->setText1(gettext("press enter to launch ball"));
std::string txt = "press ";
txt += string(cfg->getKeyCommonName(cfg->getKey("launch")));
txt += string(" to launch ball");
this->setText1(gettext(txt.c_str()));
SendSignal( PBL_SIG_CLEAR_TEXT, 400, this->getParent(), NULL );
}
ElseOnSignal( PBL_SIG_TILT ) {
Expand All @@ -112,6 +117,9 @@ void Score::StdOnSignal() {
}
ElseOnSignal( PBL_SIG_GAME_OVER ) {
this->clearText();
std::string txt = "press ";
txt += string(cfg->getKeyCommonName(cfg->getKey("reset")));
txt += string(" to start new game");

//cout<<" TODO:give (only) one extra ball if high score"<<endl; //!rzr

Expand All @@ -123,7 +131,7 @@ void Score::StdOnSignal() {

this->setText2("");
this->setText3(gettext("game over"));
this->setText4(gettext("press r to start new game"));
this->setText4(gettext(txt.c_str()));
}
}

Expand Down

1 comment on commit 631b4d0

@rzr
Copy link

@rzr rzr commented on 631b4d0 Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is welcome to upstream

adoptware#15

Please sign in to comment.