diff --git a/applications/tappytux/mod_tappywords.pas b/applications/tappytux/mod_tappywords.pas new file mode 100644 index 000000000..50eb0a01f --- /dev/null +++ b/applications/tappytux/mod_tappywords.pas @@ -0,0 +1,19 @@ +unit mod_tappywords; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, + tappymodules; + +type + TTappyWords = class(TTappyModule) + public + end; + +implementation + +end. + diff --git a/applications/tappytux/tappytuxconfig.pas b/applications/tappytux/tappyconfig.pas similarity index 95% rename from applications/tappytux/tappytuxconfig.pas rename to applications/tappytux/tappyconfig.pas index 38d0700d2..499b791ae 100644 --- a/applications/tappytux/tappytuxconfig.pas +++ b/applications/tappytux/tappyconfig.pas @@ -1,11 +1,11 @@ -unit tappytuxconfig; +unit tappyconfig; {$mode objfpc}{$H+} interface uses - Classes, SysUtils, Forms; + Classes, SysUtils, Forms, Graphics; type diff --git a/applications/tappytux/tappytuxdrawer.pas b/applications/tappytux/tappydrawer.pas similarity index 85% rename from applications/tappytux/tappytuxdrawer.pas rename to applications/tappytux/tappydrawer.pas index 1ad5b2fcb..128abddf8 100644 --- a/applications/tappytux/tappytuxdrawer.pas +++ b/applications/tappytux/tappydrawer.pas @@ -1,4 +1,4 @@ -unit tappytuxdrawer; +unit tappydrawer; {$mode objfpc}{$H+} @@ -7,7 +7,7 @@ interface uses Classes, SysUtils, Controls, Graphics, LCLType, IntfGraphics, fpimage, Math, - tappytuxgamedata, tappytuxconfig; + tappygamedata, tappyconfig, tappymodules; type @@ -41,8 +41,7 @@ type procedure DrawImageWithTransparentColor( ADest: TLazIntfImage; const ADestX, ADestY: Integer; AColor: TFPColor; AImage: TFPImageBitmap); - function GetChessTileImage(ATile: TChessTile): TPortableNetworkGraphic; - procedure LoadImages(); + //function GetImage(ATile: TChessTile): TPortableNetworkGraphic; procedure HandleMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure HandleMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); @@ -65,7 +64,7 @@ var X, Y, SourceX, SourceY, DestX, DestY: integer; dx, dy: Integer; t: Double; - lTile: TChessTile; + //lTile: TChessTile; begin { // Draw the moving tile //WriteLn(Format('[TChessMoveAnimation.DrawToIntfImg] Afrom=%d,%d', [AFrom.X, AFrom.Y])); @@ -86,7 +85,7 @@ end; procedure TFireAnimation.ExecuteFinal; begin - vChessGame.MovePiece(AFrom, ATo); + //vChessGame.MovePiece(AFrom, ATo); end; { TTappyTuxAnimation } @@ -155,16 +154,19 @@ var col, row: integer; lIntfImage: TLazIntfImage; lTmpBmp: TBitmap; - lTileBmp: TPortableNetworkGraphic; X, Y: integer; begin lIntfImage := TLazIntfImage.Create(0, 0); lTmpBmp := TBitmap.Create; try - // First draw the board - lIntfImage.LoadFromBitmap(imgBoard.Handle, 0{bmpBoard.MaskHandle}); + // First draw the background + lIntfImage.LoadFromBitmap(GetCurrentModule().imgBackground.Handle, 0{bmpBoard.MaskHandle}); - // Now all pieces + // Now the module should draw itself + + // Draw all animations + +{ // Now all pieces for col := 1 to 8 do for row := 1 to 8 do begin @@ -181,7 +183,7 @@ begin end; // Now animations - if Assigned(FAnimation) then FAnimation.DrawToIntfImg(lIntfImage); + if Assigned(FAnimation) then FAnimation.DrawToIntfImg(lIntfImage);} lTmpBmp.LoadFromIntfImage(lIntfImage); ACanvas.Draw(0, 0, lTmpBmp); @@ -229,9 +231,9 @@ begin end; end; -function TTappyTuxDrawer.GetChessTileImage(ATile: TChessTile): TPortableNetworkGraphic; +{function TTappyTuxDrawer.GetChessTileImage(ATile: TChessTile): TPortableNetworkGraphic; begin -{ case ATile of + case ATile of ctWPawn: Result := imgWPawn; ctWKnight: Result := imgWKnight; ctWBishop: Result := imgWBishop; @@ -246,29 +248,8 @@ begin ctBKing: Result := imgBKing; else Result := nil; - end;} -end; - -procedure TTappyTuxDrawer.LoadImages(); -var - lDir: string; -begin - lDir := vChessConfig.GetCurrentSkinDir(); - -{ imgBoard.LoadFromFile(lDir + 'base.png'); - imgWPawn.LoadFromFile(lDir + 'wpawn.png'); - imgWKnight.LoadFromFile(lDir + 'wknight.png'); - imgWBishop.LoadFromFile(lDir + 'wbishop.png'); - imgWRook.LoadFromFile(lDir + 'wrook.png'); - imgWQueen.LoadFromFile(lDir + 'wqueen.png'); - imgWKing.LoadFromFile(lDir + 'wking.png'); - imgBPawn.LoadFromFile(lDir + 'bpawn.png'); - imgBKnight.LoadFromFile(lDir + 'bknight.png'); - imgBBishop.LoadFromFile(lDir + 'bbishop.png'); - imgBRook.LoadFromFile(lDir + 'brook.png'); - imgBQueen.LoadFromFile(lDir + 'bqueen.png'); - imgBKing.LoadFromFile(lDir + 'bking.png');} -end; + end; +end;} procedure TTappyTuxDrawer.HandleMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); @@ -307,7 +288,7 @@ begin end;} end; -procedure TTappyTuxDrawer.AddAnimation(AAnimation: TChessAnimation); +procedure TTappyTuxDrawer.AddAnimation(AAnimation: TTappyTuxAnimation); begin { FDrawerState := dsRunningAnimation; FAnimation := AAnimation;} diff --git a/applications/tappytux/tappytuxgamedata.pas b/applications/tappytux/tappygamedata.pas similarity index 80% rename from applications/tappytux/tappytuxgamedata.pas rename to applications/tappytux/tappygamedata.pas index ea3b5d55b..ae900c392 100644 --- a/applications/tappytux/tappytuxgamedata.pas +++ b/applications/tappytux/tappygamedata.pas @@ -1,40 +1,44 @@ -unit GameData; +unit tappygamedata; {$mode objfpc}{$H} interface uses - Classes, Forms, SysUtils, process, SynRegExpr, - LCLPRoc, tappywords, util, tappytuxconfig; + Classes, Forms, SysUtils, process; +// SynRegExpr, +// LCLProc, +// tappywords, +// util, +// tappyconfig; Type - TTappyGameData = object - SndFX : Boolean; - SndMusic: Boolean; - ModuleName : String; - Option : String; - Level : Integer; - NextLevel : Integer; - NextLife : Integer; - Speed : Integer; - Score : Integer; - Lives : Integer; - SongList : TStringList; - QuestionList :TStringList; - Procedure Create; - Function GetQuestion:String; - Function CheckAnswer(Question,Answer:String):Integer; - Procedure ScoreUp(ScorInc:Integer); - Procedure LevelUp; - Procedure LoseLife; - Function NextSong: String; - BGS : TStringList; - BG : Integer; - Function NextBG:String; - end; + TTappyGameData = object + SndFX : Boolean; + SndMusic: Boolean; + ModuleName : String; + Option : String; + Level : Integer; + NextLevel : Integer; + NextLife : Integer; + Speed : Integer; + Score : Integer; + Lives : Integer; + SongList : TStringList; + QuestionList :TStringList; + BGS : TStringList; + BG : Integer; +(* Procedure Create; + Function GetQuestion:String; + Function CheckAnswer(Question,Answer:String):Integer; + Procedure ScoreUp(ScorInc:Integer); + Procedure LevelUp; + Procedure LoseLife; + Function NextSong: String; + Function NextBG:String;*) + end; -Type HammerQue = Object +(* HammerQue = Object Target : Array [1..10] of Integer; Function addTarget(newTarget : Integer):Boolean; Procedure delTarget; @@ -58,18 +62,17 @@ Type HammerQue = Object Constructor Create(isSuspended : boolean); published property terminated; - end; + end;*) -Var - ThisGame: TTappyGameData; - - Question : TQuestion; - Scale : Integer; - TPTDIR: string; +var + gGameData: TTappyGameData; + //Question : TQuestion; + //Scale : Integer; + //TPTDIR: string; implementation -constructor TQuestion.Create(isSuspended : boolean); +(*constructor TQuestion.Create(isSuspended : boolean); begin S := TSTringlist.Create; FreeOnTerminate := True; @@ -241,8 +244,6 @@ Begin end; - - Function HammerQue.addTarget(newTarget : Integer):Boolean; Var I : Integer; New : Boolean; @@ -270,6 +271,6 @@ Begin Target[X] := Target[X 1]; Dec(Count); -end; +end;*) end. diff --git a/applications/tappytux/tappymodules.pas b/applications/tappytux/tappymodules.pas new file mode 100644 index 000000000..06616ff72 --- /dev/null +++ b/applications/tappytux/tappymodules.pas @@ -0,0 +1,99 @@ +unit tappymodules; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Graphics; + +type + + { TTappyModule } + + TTappyModule = class + public + imgBackground: TPortableNetworkGraphic; + constructor Create; virtual; + destructor Destroy; override; + procedure LoadImages; virtual; + end; + +procedure AddModule(AModule: TTappyModule); +function GetCurrentModule: TTappyModule; +function GetModule(AIndex: Integer): TTappyModule; +function GetModuleCount: Integer; +procedure SetCurrentModule(AIndex: Integer); + +implementation + +var + gTappyModules: TFPList; + gCurrentTappyModule: Integer = -1; + +procedure AddModule(AModule: TTappyModule); +begin + gTappyModules.Add(Pointer(AModule)); +end; + +function GetCurrentModule: TTappyModule; +begin + Result := GetModule(gCurrentTappyModule); +end; + +function GetModule(AIndex: Integer): TTappyModule; +begin + Result := TTappyModule(gTappyModules.Items[AIndex]); +end; + +function GetModuleCount: Integer; +begin + Result := gTappyModules.Count; +end; + +procedure SetCurrentModule(AIndex: Integer); +begin + gCurrentTappyModule := AIndex; +end; + +{ TTappyModule } + +constructor TTappyModule.Create; +begin + inherited Create; +end; + +destructor TTappyModule.Destroy; +begin + inherited Destroy; +end; + +procedure TTappyModule.LoadImages; +begin +{ var + lDir: string; + begin + lDir := vChessConfig.GetCurrentSkinDir();} + + { imgBoard.LoadFromFile(lDir + 'base.png'); + imgWPawn.LoadFromFile(lDir + 'wpawn.png'); + imgWKnight.LoadFromFile(lDir + 'wknight.png'); + imgWBishop.LoadFromFile(lDir + 'wbishop.png'); + imgWRook.LoadFromFile(lDir + 'wrook.png'); + imgWQueen.LoadFromFile(lDir + 'wqueen.png'); + imgWKing.LoadFromFile(lDir + 'wking.png'); + imgBPawn.LoadFromFile(lDir + 'bpawn.png'); + imgBKnight.LoadFromFile(lDir + 'bknight.png'); + imgBBishop.LoadFromFile(lDir + 'bbishop.png'); + imgBRook.LoadFromFile(lDir + 'brook.png'); + imgBQueen.LoadFromFile(lDir + 'bqueen.png'); + imgBKing.LoadFromFile(lDir + 'bking.png');} + +end; + +initialization + gTappyModules := TFPList.Create; +finalization + gTappyModules.Free; +end. + diff --git a/applications/tappytux/tappytux.lpi b/applications/tappytux/tappytux.lpi index 64bc72d60..0e7afe5ac 100644 --- a/applications/tappytux/tappytux.lpi +++ b/applications/tappytux/tappytux.lpi @@ -34,12 +34,12 @@ - + - + @@ -47,13 +47,12 @@ - - - - - + + + + @@ -65,133 +64,189 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + diff --git a/applications/tappytux/tappytux.lpr b/applications/tappytux/tappytux.lpr index 59b2f4cd2..d2943b24b 100644 --- a/applications/tappytux/tappytux.lpr +++ b/applications/tappytux/tappytux.lpr @@ -7,7 +7,8 @@ uses cthreads, {$ENDIF}{$ENDIF} Interfaces, // this includes the LCL widgetset - Forms, gameconfigform, gameplayform + Forms, gameconfigform, gameplayform, tappyconfig, tappydrawer, + tappygamedata, mod_tappywords, tappymodules { you can add units after this }; {$R *.res}