Rev 89 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 89 | Rev 90 | ||
---|---|---|---|
Line 190... | Line 190... | ||
190 | strict protected |
190 | strict protected |
191 | procedure DoMove(MoveCount: Integer); override; |
191 | procedure DoMove(MoveCount: Integer); override; |
192 | procedure HitEnemy(ADead: Boolean); override; |
192 | procedure HitEnemy(ADead: Boolean); override; |
193 | public |
193 | public |
194 | constructor Create(AParent: TSprite; ALifes: integer); override; |
194 | constructor Create(AParent: TSprite; ALifes: integer); override; |
- | 195 | destructor Destroy; override; |
|
195 | end; |
196 | end; |
196 | 197 | ||
197 | TItemClass = class of TItem; |
198 | TItemClass = class of TItem; |
198 | TItem = class abstract (TPlayerOrEnemyOrItem) |
199 | TItem = class abstract (TPlayerOrEnemyOrItem) |
199 | strict protected |
200 | strict protected |
Line 293... | Line 294... | ||
293 | procedure LevelNeuStarten; |
294 | procedure LevelNeuStarten; |
294 | private |
295 | private |
295 | { Diverse temporäre Variablen } |
296 | { Diverse temporäre Variablen } |
296 | Crash2: integer; |
297 | Crash2: integer; |
297 | EnemyCounter: integer; |
298 | EnemyCounter: integer; |
298 | FBoss: TEnemyBoss; |
- | |
299 | Crash: boolean; |
299 | Crash: boolean; |
300 | crashsound: boolean; |
300 | crashsound: boolean; |
301 | public |
301 | public |
302 | FNextScene: TGameScene; |
302 | FNextScene: TGameScene; |
303 | FScore: Integer; |
303 | FScore: Integer; |
- | 304 | FBoss: TEnemyBoss; |
|
304 | FNotSave: boolean; |
305 | FNotSave: boolean; |
305 | FLife: integer; |
306 | FLife: integer; |
306 | FLevel: integer; |
307 | FLevel: integer; |
307 | FGameMode: TGameMode; |
308 | FGameMode: TGameMode; |
308 | FLifeAtLevelStart: integer; |
309 | FLifeAtLevelStart: integer; |
Line 1112... | Line 1113... | ||
1112 | begin |
1113 | begin |
1113 | Inc(MainForm.FScore, 100); |
1114 | Inc(MainForm.FScore, 100); |
1114 | end; |
1115 | end; |
1115 | end; |
1116 | end; |
1116 | 1117 | ||
- | 1118 | destructor TEnemyBoss.Destroy; |
|
- | 1119 | begin |
|
- | 1120 | MainForm.FBoss := nil; |
|
- | 1121 | inherited; |
|
- | 1122 | end; |
|
- | 1123 | ||
1117 | procedure TEnemyBoss.DoMove(MoveCount: Integer); |
1124 | procedure TEnemyBoss.DoMove(MoveCount: Integer); |
1118 | begin |
1125 | begin |
1119 | inherited DoMove(MoveCount); |
1126 | inherited DoMove(MoveCount); |
1120 | if State = pesEntering then |
1127 | if State = pesEntering then |
1121 | begin |
1128 | begin |
Line 1185... | Line 1192... | ||
1185 | else if State = pesDead then |
1192 | else if State = pesDead then |
1186 | begin |
1193 | begin |
1187 | if FCounter>4000 then |
1194 | if FCounter>4000 then |
1188 | begin |
1195 | begin |
1189 | FState := pesDeadVanished; |
1196 | FState := pesDeadVanished; |
1190 | MainForm.FBoss := nil; // important because Dead will Free the object, so we cannot rely on FState |
- | |
1191 | Dead; |
1197 | Dead; |
1192 | end; |
1198 | end; |
1193 | end; |
1199 | end; |
1194 | inc(FCounter, MoveCount); |
1200 | inc(FCounter, MoveCount); |
1195 | end; |
1201 | end; |
Line 1854... | Line 1860... | ||
1854 | FRestEnemies := 0; |
1860 | FRestEnemies := 0; |
1855 | end; |
1861 | end; |
1856 | 1862 | ||
1857 | procedure TMainForm.NewLevel(lev: integer); |
1863 | procedure TMainForm.NewLevel(lev: integer); |
1858 | resourcestring |
1864 | resourcestring |
1859 | SLevelInvalid = 'Das Level Nr. %d ist ungültig!'+#13#10+'Das Programm wird beendet.'; |
1865 | SLevelInvalid = 'Die Datei für Level %d ist ungültig. Level wird übersprungen!'; |
1860 | var |
1866 | var |
1861 | act: integer; |
1867 | act: integer; |
1862 | Enemies: array[1..32] of TEnemyType; |
1868 | Enemies: array[1..32] of TEnemyType; |
1863 | numEnemies: integer; |
1869 | numEnemies: integer; |
1864 | e: TEnemyAdvent; |
1870 | e: TEnemyAdvent; |
Line 1980... | Line 1986... | ||
1980 | try |
1986 | try |
1981 | LevelData.RasterErzwingen := false; |
1987 | LevelData.RasterErzwingen := false; |
1982 | LevelData.LoadFromFile(levFile.fileLocation); |
1988 | LevelData.LoadFromFile(levFile.fileLocation); |
1983 | except |
1989 | except |
1984 | showmessage(Format(SLevelInvalid, [lev])); |
1990 | showmessage(Format(SLevelInvalid, [lev])); |
1985 | ResetLevelData; |
1991 | ResetLevelData; // empty level = the player will continue with the next level |
1986 | end; |
1992 | end; |
1987 | end; |
1993 | end; |
1988 | {$ENDREGION} |
1994 | {$ENDREGION} |
1989 | end; |
1995 | end; |
1990 | FLevelDataAlreadyLoaded := true; // nicht nochmal NewLevel() aufrufen. Erst wieder wenn man gewonnen hat. |
1996 | FLevelDataAlreadyLoaded := true; // nicht nochmal NewLevel() aufrufen. Erst wieder wenn man gewonnen hat. |
Line 1992... | Line 1998... | ||
1992 | 1998 | ||
1993 | var |
1999 | var |
1994 | TitleWasPressed: TDxInputState = isButton32; |
2000 | TitleWasPressed: TDxInputState = isButton32; |
1995 | 2001 | ||
1996 | procedure TMainForm.SceneTitle; |
2002 | procedure TMainForm.SceneTitle; |
- | 2003 | resourcestring |
|
- | 2004 | SNormalGame = 'Normales Spiel'; |
|
- | 2005 | SRandomGame = 'Zufalls-Level'; |
|
- | 2006 | SLevelEditor = 'Level-Editor'; |
|
1997 | var |
2007 | var |
1998 | Logo: TPictureCollectionItem; |
2008 | Logo: TPictureCollectionItem; |
1999 | colo1, colo2: TColor; |
2009 | colo1, colo2: TColor; |
2000 | begin |
2010 | begin |
2001 | DXDraw.Surface.Fill(0); |
2011 | DXDraw.Surface.Fill(0); |
Line 2037... | Line 2047... | ||
2037 | begin |
2047 | begin |
2038 | colo1 := clOlive; |
2048 | colo1 := clOlive; |
2039 | colo2 := clYellow; |
2049 | colo2 := clYellow; |
2040 | end; |
2050 | end; |
2041 | DXDraw.Surface.Canvas.Font.Color := colo1; |
2051 | DXDraw.Surface.Canvas.Font.Color := colo1; |
2042 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-52, 'Normales Spiel'); |
2052 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-52, SNormalGame); |
2043 | if FGameMode = gmLevels then |
2053 | if FGameMode = gmLevels then |
2044 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)-52, '>'); |
2054 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)-52, '>'); |
2045 | DXDraw.Surface.Canvas.Font.Color := colo2; |
2055 | DXDraw.Surface.Canvas.Font.Color := colo2; |
2046 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2)-50, 'Normales Spiel'); |
2056 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2)-50, SNormalGame); |
2047 | if FGameMode = gmLevels then |
2057 | if FGameMode = gmLevels then |
2048 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)-50, '>'); |
2058 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)-50, '>'); |
2049 | {$ENDREGION} |
2059 | {$ENDREGION} |
2050 | 2060 | ||
2051 | {$REGION 'Menu point: Random Level'} |
2061 | {$REGION 'Menu point: Random Level'} |
Line 2058... | Line 2068... | ||
2058 | begin |
2068 | begin |
2059 | colo1 := clOlive; |
2069 | colo1 := clOlive; |
2060 | colo2 := clYellow; |
2070 | colo2 := clYellow; |
2061 | end; |
2071 | end; |
2062 | DXDraw.Surface.Canvas.Font.Color := colo1; |
2072 | DXDraw.Surface.Canvas.Font.Color := colo1; |
2063 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-2, 'Zufallslevel'); |
2073 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)-2, SRandomGame); |
2064 | if FGameMode = gmRandom then |
2074 | if FGameMode = gmRandom then |
2065 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-187, (dxdraw.surfaceheight div 2)-2, '>'); |
2075 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-187, (dxdraw.surfaceheight div 2)-2, '>'); |
2066 | DXDraw.Surface.Canvas.Font.Color := colo2; |
2076 | DXDraw.Surface.Canvas.Font.Color := colo2; |
2067 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2), 'Zufallslevel'); |
2077 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2), SRandomGame); |
2068 | if FGameMode = gmRandom then |
2078 | if FGameMode = gmRandom then |
2069 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2), '>'); |
2079 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2), '>'); |
2070 | {$ENDREGION} |
2080 | {$ENDREGION} |
2071 | 2081 | ||
2072 | {$REGION 'Menu point: Level Editor'} |
2082 | {$REGION 'Menu point: Level Editor'} |
Line 2079... | Line 2089... | ||
2079 | begin |
2089 | begin |
2080 | colo1 := clOlive; |
2090 | colo1 := clOlive; |
2081 | colo2 := clYellow; |
2091 | colo2 := clYellow; |
2082 | end; |
2092 | end; |
2083 | DXDraw.Surface.Canvas.Font.Color := colo1; |
2093 | DXDraw.Surface.Canvas.Font.Color := colo1; |
2084 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)+48, 'Level-Editor'); |
2094 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-152, (dxdraw.surfaceheight div 2)+48, SLevelEditor); |
2085 | if FGameMode = gmEditor then |
2095 | if FGameMode = gmEditor then |
2086 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)+48, '>'); |
2096 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)+48, '>'); |
2087 | DXDraw.Surface.Canvas.Font.Color := colo2; |
2097 | DXDraw.Surface.Canvas.Font.Color := colo2; |
2088 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2)+50, 'Level-Editor'); |
2098 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-150, (dxdraw.surfaceheight div 2)+50, SLevelEditor); |
2089 | if FGameMode = gmEditor then |
2099 | if FGameMode = gmEditor then |
2090 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)+50, '>'); |
2100 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, (dxdraw.surfaceheight div 2)+50, '>'); |
2091 | {$ENDREGION} |
2101 | {$ENDREGION} |
2092 | 2102 | ||
2093 | { if (FBlink div 300) mod 2=0 then |
2103 | { if (FBlink div 300) mod 2=0 then |
2094 | begin |
2104 | begin |
2095 | DXDraw.Surface.Canvas.Font.Color := clGreen; |
2105 | DXDraw.Surface.Canvas.Font.Color := clGreen; |
2096 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, 'Weiter mit Leertaste'); |
2106 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, SWeiterMitLeertaste); |
2097 | DXDraw.Surface.Canvas.Font.Color := clLime; |
2107 | DXDraw.Surface.Canvas.Font.Color := clLime; |
2098 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, 'Weiter mit Leertaste'); |
2108 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, SWeiterMitLeertaste); |
2099 | end; } |
2109 | end; } |
2100 | BlinkUpdate; |
2110 | BlinkUpdate; |
2101 | DXDraw.Surface.Canvas.Release; |
2111 | DXDraw.Surface.Canvas.Release; |
2102 | 2112 | ||
2103 | // Weiter mit Leertaste oder Enter |
2113 | // Weiter mit Leertaste oder Enter |
Line 2225... | Line 2235... | ||
2225 | {$ENDREGION} |
2235 | {$ENDREGION} |
2226 | 2236 | ||
2227 | {$REGION 'Anzeige Einheiten und Boss Leben'} |
2237 | {$REGION 'Anzeige Einheiten und Boss Leben'} |
2228 | 2238 | ||
2229 | tmpEnemyAnzeige := EnemyCounter{Auf Bildschirm} + FRestEnemies{In der Warteschlange}; |
2239 | tmpEnemyAnzeige := EnemyCounter{Auf Bildschirm} + FRestEnemies{In der Warteschlange}; |
2230 | if Assigned(FBoss) then Dec(tmpEnemyAnzeige); |
2240 | if Assigned(FBoss) and (FBoss.State<>pesDeadVanished) then Dec(tmpEnemyAnzeige); |
2231 | 2241 | ||
2232 | if Assigned(FBoss) and (FBoss.Life>0) then |
2242 | if Assigned(FBoss) and (FBoss.Life>0) then |
2233 | begin |
2243 | begin |
2234 | if (tmpEnemyAnzeige>0) then |
2244 | if (tmpEnemyAnzeige>0) then |
2235 | begin |
2245 | begin |
Line 2384... | Line 2394... | ||
2384 | begin |
2394 | begin |
2385 | { Ende NewLevel } |
2395 | { Ende NewLevel } |
2386 | end; |
2396 | end; |
2387 | 2397 | ||
2388 | procedure TMainForm.SceneNewLevel; |
2398 | procedure TMainForm.SceneNewLevel; |
- | 2399 | resourcestring |
|
- | 2400 | SLevelScene = 'Level %d'; |
|
2389 | begin |
2401 | begin |
2390 | DXDraw.Surface.Fill(0); |
2402 | DXDraw.Surface.Fill(0); |
2391 | 2403 | ||
2392 | DXDraw.Surface.Canvas.Brush.Style := bsClear; |
2404 | DXDraw.Surface.Canvas.Brush.Style := bsClear; |
2393 | DXDraw.Surface.Canvas.Font.Size := 40; |
2405 | DXDraw.Surface.Canvas.Font.Size := 40; |
2394 | DXDraw.Surface.Canvas.Font.Color := clMaroon; |
2406 | DXDraw.Surface.Canvas.Font.Color := clMaroon; |
2395 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-(83+(length(inttostr(flevel))*22)), 98, 'Level '+inttostr(flevel)); |
2407 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-(83+(length(inttostr(flevel))*22)), 98, Format(SLevelScene, [flevel])); |
2396 | DXDraw.Surface.Canvas.Font.Color := clRed; |
2408 | DXDraw.Surface.Canvas.Font.Color := clRed; |
2397 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-(81+(length(inttostr(flevel))*22)), 100, 'Level '+inttostr(flevel)); |
2409 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-(81+(length(inttostr(flevel))*22)), 100, Format(SLevelScene, [flevel])); |
2398 | if (FBlink div 300) mod 2=0 then |
2410 | if (FBlink div 300) mod 2=0 then |
2399 | begin |
2411 | begin |
2400 | DXDraw.Surface.Canvas.Font.Size := 30; |
2412 | DXDraw.Surface.Canvas.Font.Size := 30; |
2401 | DXDraw.Surface.Canvas.Font.Color := clOlive; |
2413 | DXDraw.Surface.Canvas.Font.Color := clOlive; |
2402 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, 'Weiter mit Leertaste'); |
2414 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-187, dxdraw.surfaceheight-117, SWeiterMitLeertaste); |
2403 | DXDraw.Surface.Canvas.Font.Color := clYellow; |
2415 | DXDraw.Surface.Canvas.Font.Color := clYellow; |
2404 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, 'Weiter mit Leertaste'); |
2416 | DXDraw.Surface.Canvas.Textout((dxdraw.surfaceWidth div 2)-185, dxdraw.surfaceheight-115, SWeiterMitLeertaste); |
2405 | end; |
2417 | end; |
2406 | BlinkUpdate; |
2418 | BlinkUpdate; |
2407 | DXDraw.Surface.Canvas.Release; |
2419 | DXDraw.Surface.Canvas.Release; |
2408 | 2420 | ||
2409 | // Weiter mit Leertaste oder Enter |
2421 | // Weiter mit Leertaste oder Enter |