Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F102580
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
10 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/Demo.cpp b/src/Demo.cpp
index 09d8d45..97e7d7e 100644
--- a/src/Demo.cpp
+++ b/src/Demo.cpp
@@ -1,358 +1,358 @@
/***************************************************************************
Demo.cpp - description
-------------------
begin : Wed Aug 16 22:18:47 CEST 2003
copyright : (C) 2003 by upi
email : upi@apocalypse.rulez.org
***************************************************************************/
#include "FlyingChars.h"
#include "SDL.h"
#include "State.h"
#include "gfx.h"
#include "common.h"
#include "Backend.h"
#include "Demo.h"
Demo::Demo()
{
m_poFlyingChars = NULL;
m_bAdvanceGame = false;
}
Demo::~Demo()
{
delete m_poFlyingChars;
m_poFlyingChars = NULL;
}
int Demo::Advance( int a_iNumFrames, bool a_bFlip )
{
int iRetVal = 1;
if ( a_iNumFrames > 5 )
a_iNumFrames = 5;
if ( m_poBackground )
{
SDL_BlitSurface( m_poBackground, NULL, gamescreen, NULL );
}
if ( m_poFlyingChars )
{
iRetVal &= AdvanceFlyingChars( a_iNumFrames );
m_poFlyingChars->Draw();
}
if ( m_bAdvanceGame )
{
iRetVal &= AdvanceGame( a_iNumFrames );
//@ DRAW GAME?
}
if ( a_bFlip )
{
SDL_Flip( gamescreen );
}
return iRetVal;
}
int Demo::AdvanceFlyingChars( int a_iNumFrames )
{
m_poFlyingChars->Advance( a_iNumFrames );
return ( m_poFlyingChars->IsDone() ? 1 : 0 );
}
int Demo::AdvanceGame( int a_iNumFrames )
{
for ( int i=0; i<a_iNumFrames; ++i )
{
g_oBackend.AdvancePerl();
}
- return g_oState.m_bGameOver ? 1 : 0;
+ return 0;
}
int Demo::Run()
{
int thisTick, lastTick, firstTick, gameSpeed;
SDL_Event event;
gameSpeed = 12;
thisTick = SDL_GetTicks() / gameSpeed;
lastTick = thisTick - 1;
firstTick = SDL_GetTicks() / gameSpeed;
while ( 1 )
{
// 1. Wait for the next tick (on extremely fast machines..)
while (1)
{
thisTick = SDL_GetTicks() / gameSpeed;
if ( thisTick==lastTick )
{
SDL_Delay(1);
}
else
{
break;
}
}
// 2. Call ADVANCE.
int iRetVal = Advance(thisTick-lastTick, true);
lastTick = thisTick;
if ( iRetVal )
{
return 0;
}
// 3. Handle events.
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
g_oState.m_bQuitFlag = true;
break;
case SDL_KEYDOWN:
if ( event.key.keysym.sym == SDLK_ESCAPE )
{
OnMenu();
break;
}
for ( int i=0; i<2; ++i )
{
for ( int j=0; j<9; ++j )
{
if ( g_oState.m_aiPlayerKeys[i][j] == event.key.keysym.sym)
{
g_oState.m_enGameMode = SState::IN_MULTI;
}
}
}
break;
} // switch
} // while SDL_PollEvent
if ( g_oState.m_enGameMode != SState::IN_DEMO
|| g_oState.m_bQuitFlag )
{
return 1;
}
} // while 1;
}
void DoMenu( bool a_bDrawBackground );
void Demo::OnMenu()
{
::DoMenu( true );
}
class CreditsDemo: public Demo
{
public:
CreditsDemo()
{
m_poBackground = LoadBackground( "Credits.png", 240 );
SDL_UnlockSurface( m_poBackground );
DrawGradientText( "Credits", titleFont, 20, m_poBackground );
SDL_Flip( m_poBackground );
SDL_Rect oRect;
oRect.x = 110; oRect.w = gamescreen->w - 220;
oRect.y = 100; oRect.h = 350;
m_poFlyingChars = new FlyingChars( creditsFont, oRect );
m_poFlyingChars->AddText( "OPENMORTAL CREDITS\n\n\n"
"-- THE OPENMORTAL TEAM ARE --\n\n"
"CODING - UPi\n"
"MUSIC - Oedipus\n"
"GRAPHICS - UPi\n"
"\n-- CAST --\n\n"
"Boxer - Zoli\n"
"Cumi - As himself\n"
"Descant - As himself\n"
"Fureszes Orult - Ambrus\n"
"Grizli - As himself\n"
"Kinga - As herself\n"
"Macy - As herself\n"
"Misi - As himself\n"
"Rising-san - Surba\n"
"Sirpi - As himself\n"
"Taka Ito - Bence\n"
"Tokeletlen Katona - Dani\n"
"Watasiwa Baka Janajo - Ulmar\n"
"Black Dark Evil Mage - UPi\n"
"\n-- HOSTING --\n\n"
"sourceforge.net\n"
"apocalypse.rulez.org\n"
"freshmeat.net\n"
"\nOpenMortal is Copyright 2003 of the OpenMortal Team\n"
"Distributed under the GNU General Public Licence Version 2\n\n",
FlyingChars::FC_AlignCenter, true );
m_poFlyingChars->AddText( "Thanks to Midway for not harrassing us with legal stuff so far, "
"even though we must surely violate at least 50 of their patents, international "
"copyrights and registered trademarks.\n\n"
"OpenMortal needs your help! If you can contribute music, graphics, improved code, "
"additional characters, cash, beer, pizza or any other consumable, please mail us "
"at upi@apocalypse.rulez.org! The same address is currently accepting comments and "
"fanmail too (hint, hint!).\n\n",
FlyingChars::FC_AlignJustify, true );
m_poFlyingChars->AddText( "Be sure to check out other stuff from\n"
"Apocalypse Production\n"
"and\n"
"Degec Entertainment\n\n",
FlyingChars::FC_AlignCenter, true );
m_poFlyingChars->AddText( "\n\n\n\n\n\n:)", FlyingChars::FC_AlignRight, true );
}
};
class Story1Demo: public Demo
{
public:
Story1Demo()
{
m_poBackground = LoadBackground( "Story1.png", 240 );
SDL_UnlockSurface( m_poBackground );
SDL_Rect oRect;
oRect.x = 50; oRect.w = gamescreen->w - 100;
oRect.y = 50; oRect.h = gamescreen->h - 100;
m_poFlyingChars = new FlyingChars( storyFont, oRect, -1 );
m_poFlyingChars->AddText(
"We, the Gods of the Evil Killer Black Antipathic Dim (witted) Fire Mages "
"no longer tolerate the lack of evildoing.\n\n"
"We send them out on a "
"mission so diabolical, so evil that the world will never be the same "
"again!\n\n"
"We order our unworthy followers to "
"\nDESTROY THE SATURDAY\n"
"and plunge humanity into a dark age of 5 working days and 1 holiday "
"per week... FOREVER!\n\n\n\n\n\n\n\n\n",
FlyingChars::FC_AlignJustify, true );
}
};
class MainScreenDemo: public Demo
{
public:
MainScreenDemo()
{
m_iTimeLeft = 100;
m_poBackground = LoadBackground( "Mortal.png", 240 );
}
int Advance( int a_iNumFrames, bool a_bFlip )
{
m_iTimeLeft -= a_iNumFrames;
Demo::Advance( a_iNumFrames, true );
return ( m_iTimeLeft <= 0 ) ? 1 : 0;
}
protected:
int m_iTimeLeft;
};
void DoReplayDemo()
{
static int aiOrder[6] = {-1, -1, -1, -1, -1, -1};
static int iNext = 0;
if ( aiOrder[0]<0 )
{
// shuffle
int i, j, k;
for ( i=0; i<6; ++i ) aiOrder[i]=i;
for ( i=0; i<6; ++i )
{
j = rand() % 6;
k = aiOrder[i];
aiOrder[i] = aiOrder[j];
aiOrder[j] = k;
}
iNext = 0;
}
char acFilename[1024];
sprintf( acFilename, DATADIR "/demo%d.om", aiOrder[iNext] );
DoGame( acFilename, true, false );
iNext = ( iNext + 1 ) % 6;
}
void DoDemos()
{
#define DoDemos_BREAKONEND \
if ( g_oState.m_enGameMode != SState::IN_DEMO \
|| g_oState.m_bQuitFlag ) \
return;
while (1)
{
DoDemos_BREAKONEND;
{
MainScreenDemo oDemo;
oDemo.Run();
}
DoDemos_BREAKONEND;
DoReplayDemo();
DoDemos_BREAKONEND;
{
Story1Demo oDemo;
oDemo.Run();
}
DoDemos_BREAKONEND;
DoReplayDemo();
DoDemos_BREAKONEND;
{
FighterStatsDemo oDemo;
oDemo.Run();
}
DoDemos_BREAKONEND;
DoReplayDemo();
DoDemos_BREAKONEND;
{
CreditsDemo oDemo;
oDemo.Run();
}
DoDemos_BREAKONEND;
}
}
diff --git a/src/State.h b/src/State.h
index 9b486e7..9e29218 100644
--- a/src/State.h
+++ b/src/State.h
@@ -1,101 +1,91 @@
/***************************************************************************
State.h - description
-------------------
begin : Mon Aug 12 2003
copyright : (C) 2003 by upi
email : upi@apocalypse.rulez.org
***************************************************************************/
#ifndef STATE_H
#define STATE_H
#include "SDL_mixer.h"
#include "SDL_keysym.h"
struct SState
{
enum TGameMode {
IN_DEMO,
IN_SINGLE,
IN_MULTI,
} m_enGameMode;
bool m_bQuitFlag; // true if quit event came
const char* m_pcArgv0; // Set by main to argv[0]
- // VARIABLES DURING GAMEPLAY (OR REPLAY)
-
- bool m_bGameOver; // true if the game is over
- bool m_bIsReplay; // true if in replay mode
- FILE* m_poReplayFile; // the file to load/save replay from/to, or NULL
-
-
+
// CONFIGURATION VARIABLES
int m_iGameTime; // Time of rounds in seconds.
int m_iHitPoints; // The initial number of hit points.
bool m_bFullscreen; // True in fullscreen mode.
int m_iChannels; // 1: mono, 2: stereo
int m_iMixingRate; // The mixing rate, in kHz
int m_iMixingBits; // 1: 8bit, 2: 16bit
int m_iMusicVolume; // Volume of music; 0: off, 100: max
int m_iSoundVolume; // Volume of sound effects; 0: off, 100: max
int m_aiPlayerKeys[2][9]; // Player keysyms
SState()
{
m_enGameMode = IN_DEMO;
m_bQuitFlag = false;
m_pcArgv0 = NULL;
- m_bGameOver = true;
- m_bIsReplay = false;
- m_poReplayFile = NULL;
-
m_iGameTime = 60;
m_iHitPoints = 100;
#ifdef _WINDOWS
#ifdef _DEBUG
m_bFullScreen = false;
#else
m_bFullscreen = true;
#endif
#else
m_bFullscreen = false;
#endif
m_iChannels = 2;
m_iMixingRate = MIX_DEFAULT_FREQUENCY;
m_iMixingBits = 2;
m_iMusicVolume = 50;
m_iSoundVolume = 100;
static const int aiDefaultKeys[2][9] = {
{ SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_PAGEDOWN,
SDLK_DELETE, SDLK_INSERT, SDLK_END, SDLK_HOME },
{ SDLK_w, SDLK_s, SDLK_a, SDLK_d, SDLK_x,
SDLK_f, SDLK_r, SDLK_g, SDLK_t }
};
for ( int i=0; i<2; ++i )
for ( int j=0; j<9; ++j )
m_aiPlayerKeys[i][j] = aiDefaultKeys[i][j];
};
void Load();
void Save();
void ToggleFullscreen();
};
extern SState g_oState;
#endif
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Wed, Feb 4, 2:15 PM (2 h, 13 s ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55651
Default Alt Text
(10 KB)
Attached To
Mode
R76 OpenMortal
Attached
Detach File
Event Timeline
Log In to Comment