[ Pobierz całość w formacie PDF ]
.htm (19 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Engines{if ((Shift.Contains(ssAlt)) && (Key=='X')){if (Hermes1->Exclusive)Hermes1->EndExclusive();Close();}else if ((Shift.Contains(ssAlt)) && (Key=='A')){ByzGame->CurrentScene = mrIntroMap;Run();}else if ((Shift.Contains(ssAlt)) && (Key=='B')){ByzGame->CurrentScene = mrWorldMap;Run();}else if (ByzGame)dynamic_cast(ByzGame->Hero)->Move(Key);}void __fastcall TGameForm::HermesChart1DrawScene(TObject *Sender){AnsiString S;S = "Col: " + IntToStr(ByzGame->Hero->Col);// S = S + " Scr Col: " + IntToStr(ByzGame->Hero->Creature->ScreenCol);// S = S + " Map Col: " + IntToStr(Hermes1->CreatureList->MapCol);S = S + "Hit Points: " + dynamic_cast(ByzGame->Hero)->HitPoints;HermesChart1->WriteXY(370, 410, S);S = "Row: " + IntToStr(ByzGame->Hero->Row);// S = S + " Scr Row: " + IntToStr(ByzGame->Hero->Creature->ScreenRow);file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (20 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Engines// S = S + " Map Row: " + IntToStr(Hermes1->CreatureList->MapRow);S = S + " Hunger: " + dynamic_cast(ByzGame->Hero)->Hunger;HermesChart1->WriteXY(370, 430, S);}void __fastcall TGameForm::SpriteScene1SetupSurfaces(TObject *Sender){SpriteScene1->AddSprite(Hero1);SpriteScene1->AddSprite(BadQueen1);}void __fastcall TGameForm::FormMouseMove(TObject *Sender, TShiftState Shift,int X, int Y){if (ByzGame->CurrentScene == mrFightMap){if (BadQueen1->IsHit(X, Y))Screen->Cursor = crCross;elseScreen->Cursor = crDefault;}}void __fastcall TGameForm::SpriteScene1DrawScene(TObject *Sender){if (FFightClass)FFightClass->ShowData();}file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (21 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Enginesvoid __fastcall TGameForm::FormMouseDown(TObject *Sender, TMouseButton Button,TShiftState Shift, int X, int Y){if (ByzGame->CurrentScene == mrFightMap){if (BadQueen1->IsHit(X, Y))FFightClass->PerformHit(this);}}void __fastcall TGameForm::Scene1DrawScene(TObject *Sender){Scene1->WriteXY(375, 405, "Press Alt-B to Start");Scene1->WriteXY(375, 430, "Press Alt-X to Exit");}void __fastcall TGameForm::HermesChart1HeroMove(TObject *Sender,const tagPOINT &NewPos, int NewType, bool &MoveOk){switch (TMapType(NewType)){case mtGrass:MoveOk = True;break;case mtCreature:MoveOk = False;ByzGame->BadGuy->Creature =ByzGame->CreatureList->CreatureFromLocation(NewPos.x, NewPos.y);if (ByzGame->BadGuy->Creature->Kind == "Food")file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (22 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Engines{dynamic_cast(ByzGame->Hero)->Hunger += 3;dynamic_cast(ByzGame->BadGuy)->SetVisible(False);}else if (ByzGame->BadGuy->Creature->Kind == "Medicine"){dynamic_cast(ByzGame->Hero)->HitPoints += 3;dynamic_cast(ByzGame->BadGuy)->SetVisible(False);}else{ByzGame->CurrentScene = mrFightMap;Run();}break;default:MoveOk = False;}}Listing 29.7.A header file containing some global declarations.///////////////////////////////////////// Globals.h// Byzantium Project// Copyright (c) 1997 by Charlie Calvert//#ifndef GlobalsH#define GlobalsH#define mrHitCreature 0x5001file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (23 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Engines#define mrGameOver 0x5002#define mrWorldMap 0x6001#define mrFightMap 0x6002#define mrIntroMap 0x6003#define WM_NEXTSCENE WM_USER + 1#define WM_STARTSHOW WM_USER + 2enum TMapType {mtGrass, mtWater, mtMountain, mtRoad, mtWater2,mtFootHill, mtNorthShore, mtWestShore, mtSouthShore, mtEastShore,mtSWShore, mtSEShore, mtNWShore, mtNEShore,mtWNWShore, mtWSEShore, mtESEShore, mtENEShore,mtBlank1, mtBlank2, mtBlank3, mtBlank4, mtAllSnow,mtSnowyMountain, mtSouthMtn, mtWestMtn, mtNorthMtn, mtEastMtn,mtSEMtn, mtSWMtn, mtNWMtn, mtNEMtn, mtNWFootHill,mtNEFootHill, mtSEFootHill, mtSWFootHill,mtNorthFootHill, mtEastFootHill, mtSouthFootHill,mtWestFootHill, mtNEDiagShore, mtSEDiagShore,mtSWDiagShore, mtNWDiagShore, mtSWBendShore, mtSEBendShore,mtNWBendShore, mtNEBendShore, mtENBendShore, mtWNBendShore,mtWSBendShore, mtESBendShore, mtCity, mtCreature};#endifListing 29.8.The header file for the fight class.///////////////////////////////////////// Fightclass.h// Project: Byzantium// Copyright (c) 1997 by Charlie Calvertfile:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (24 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Engines//#ifndef FightClass1H#define FightClass1H#include "Mercury1.hpp"class TFightClass{private:AnsiString FBadGuyName;AnsiString FDisplayString;HWND FHandle;TScene *FScene;bool FHitInProcess;void Button1Click(void);bool BadGuyAttacks(void);bool CheckCharacters(void);bool HeroAttacks(void);void DisplayData(AnsiString S);public:TFightClass(HWND AHandle, TScene *AScene);void PerformHit(TObject *Sender);void ShowData();__property AnsiString BadGuyName={read=FBadGuyName};};#endifListing 29.9.The main source file for the fight class.///////////////////////////////////////// Fightclass.cppfile:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (25 of 40) [10/10/2000 1:16:18 AM] Ch 29 -- Game Engines// Project: Byzantium// Copyright (c) 1997 by Charlie Calvert//#include#include#pragma hdrstop#include "Creatures1.hpp"#include "FightClass1.h"#include "ByzEngine1.h"#include "Mercury2.h"TFightClass::TFightClass(HWND AHandle, TScene *AScene){FHandle = AHandle;FHitInProcess = False;FScene = AScene;FBadGuyName = ByzGame->BadGuy->Name;}void TFightClass::DisplayData(AnsiString S){TCustomValue *CustomValue;AnsiString DisplayValue;CustomValue = ByzGame->Hero->Creature->FindCustomByName("Hit Points");DisplayValue = CustomValue->CurrentValue;FScene->WriteXY(270, 405, DisplayValue);CustomValue = ByzGame->BadGuy->Creature->FindCustomByName("Hit Points");DisplayValue = CustomValue->CurrentValue;file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29.htm (26 of 40) [10/10/2000 1:16:19 AM] Ch 29 -- Game EnginesFScene->WriteXY(270, 440, DisplayValue);FScene->WriteXY(375, 410, FDisplayString);}void TFightClass::ShowData(){DisplayData("Hit Points");if (ByzGame->BadGuy->Creature)DisplayData("Hit Points");}void TFightClass::Button1Click(){ShowMessage(ByzGame->Hero->Name + " retreats.Receives 5 points damage.");dynamic_cast(ByzGame->Hero)->HitPoints -= 5;if (CheckCharacters());}void WaitTime(int Delay){time_t t1, t2;t1 = time(NULL);while (True){Application->ProcessMessages();t2 = time(NULL);if (t2 - t1 >= Delay)file:///D|/DOWNLOAD/charlie_calvert's_borland_c++_builder_unleashed/ch29 [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • personata.xlx.pl