--- a/hedgewars/uConsts.pas Sun Dec 30 15:24:02 2007 +0000
+++ b/hedgewars/uConsts.pas Sun Dec 30 16:19:41 2007 +0000
@@ -21,8 +21,7 @@
uses SDLh, uLocale;
{$INCLUDE options.inc}
{$INCLUDE proto.inc}
-type TStuff = (sPowerBar, sWindBar,
- sWindL, sWindR);
+type
TGameState = (gsLandGen, gsStart, gsGame, gsConsole, gsExit);
@@ -41,7 +40,8 @@
sprAMSlotKeys, sprAMSelection, sprFinger, sprAirBomb,
sprAirplane, sprAmAirplane, sprAmGirder, sprHHTelepMask,
sprSwitch, sprParachute, sprTarget, sprRopeNode, sprConsoleBG,
- sprQuestion);
+ sprQuestion, sprPowerBar, sprWindBar,
+ sprWindL, sprWindR);
TGearType = (gtCloud, gtAmmo_Bomb, gtHedgehog, gtAmmo_Grenade, gtHealthTag,
gtGrave, gtUFO, gtShotgunShot, gtPickHammer, gtRope,
@@ -230,21 +230,6 @@
'Graphics/AmmoMenu' // ptAmmoMenu
);
- StuffLoadData: array[TStuff] of record
- FileName: String[31];
- Path : TPathType;
- end = (
- (FileName: 'PowerBar'; Path: ptGraphics ), // sPowerBar
- (FileName: 'WindBar'; Path: ptGraphics ), // sWindBar
- (FileName: 'WindL'; Path: ptGraphics ), // sWindL
- (FileName: 'WindR'; Path: ptGraphics ) // sWindR
- );
- StuffPoz: array[TStuff] of TSDL_Rect = (
- (x: 256; y: 768; w: 256; h: 32), // sPowerBar
- (x: 256; y: 800; w: 151; h: 17), // sWindBar
- (x: 256; y: 817; w: 80; h: 13), // sWindL
- (x: 336; y: 817; w: 80; h: 13) // sWindR
- );
SpritesData: array[TSprite] of record
FileName: String[31];
Path, AltPath: TPathType;
@@ -335,7 +320,15 @@
(FileName: 'Console'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
Width: 256; Height:256; hasAlpha:false),// sprConsoleBG
(FileName: 'thinking'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
- Width: 32; Height: 32; hasAlpha:false) // sprQuestion
+ Width: 32; Height: 32; hasAlpha:false),// sprQuestion
+ (FileName: 'PowerBar'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 256; Height: 32; hasAlpha:false),// sprPowerBar
+ (FileName: 'WindBar'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 151; Height: 17; hasAlpha:false),// sprWindBar
+ (FileName: 'WindL'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 80; Height: 13; hasAlpha:false),// sprWindL
+ (FileName: 'WindR'; Path: ptGraphics; AltPath: ptNone; Surface: nil;
+ Width: 80; Height: 13; hasAlpha:false) // sprWindR
);
Soundz: array[TSound] of record
--- a/hedgewars/uGears.pas Sun Dec 30 15:24:02 2007 +0000
+++ b/hedgewars/uGears.pas Sun Dec 30 16:19:41 2007 +0000
@@ -578,7 +578,7 @@
gtAmmo_Grenade: DrawSprite(sprGrenade , hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, DxDy2Angle32(Gear^.dY, Gear^.dX), Surface);
gtHealthTag,
gtSmallDamage: if Gear^.Surf <> nil then DrawCentered(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Surf, Surface);
- gtGrave: DrawSpriteFromRect(PHedgehog(Gear^.Hedgehog)^.Team^.GraveRect, hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, Surface);
+ gtGrave: DrawSurfSprite(hwRound(Gear^.X) + WorldDx - 16, hwRound(Gear^.Y) + WorldDy - 16, 32, (GameTicks shr 7) and 7, PHedgehog(Gear^.Hedgehog)^.Team^.GraveSurf, Surface);
gtUFO: DrawSprite(sprUFO, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, (GameTicks shr 7) mod 4, Surface);
gtRope: begin
roplen:= 0;
--- a/hedgewars/uStore.pas Sun Dec 30 15:24:02 2007 +0000
+++ b/hedgewars/uStore.pas Sun Dec 30 16:19:41 2007 +0000
@@ -24,8 +24,7 @@
procedure StoreInit;
procedure StoreLoad;
procedure StoreRelease;
-procedure DrawGear(Stuff : TStuff; X, Y: LongInt; Surface: PSDL_Surface);
-procedure DrawSpriteFromRect(r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
+procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface);
procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface);
procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source, Surface: PSDL_Surface);
@@ -60,17 +59,6 @@
TryDo(SDL_SetColorKey( StoreSurface, SDL_SRCCOLORKEY or SDL_RLEACCEL, 0) = 0, errmsgTransparentSet, true);
end;
-procedure LoadToSurface(Filename: String; Surface: PSDL_Surface; X, Y: LongInt);
-var tmpsurf: PSDL_Surface;
- rr: TSDL_Rect;
-begin
- tmpsurf:= LoadImage(Filename, false, true, false);
- rr.x:= X;
- rr.y:= Y;
- SDL_UpperBlit(tmpsurf, nil, Surface, @rr);
- SDL_FreeSurface(tmpsurf);
-end;
-
procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
var r: TSDL_Rect;
begin
@@ -125,8 +113,7 @@
end;
procedure StoreLoad;
-var i: TStuff;
- ii: TSprite;
+var ii: TSprite;
fi: THWFont;
s: string;
tmpsurf: PSDL_Surface;
@@ -197,20 +184,14 @@
end;
procedure LoadGraves;
- var t, l: LongInt;
+ var t: LongInt;
begin
- l:= 512;
for t:= 0 to Pred(TeamsCount) do
if TeamsArray[t] <> nil then
with TeamsArray[t]^ do
begin
- dec(l, 32);
if GraveName = '' then GraveName:= 'Simple';
- LoadToSurface(Pathz[ptGraves] + '/' + GraveName, StoreSurface, l, 512);
- GraveRect.x:= l;
- GraveRect.y:= 512;
- GraveRect.w:= 32;
- GraveRect.h:= 256;
+ GraveSurf:= LoadImage(Pathz[ptGraves] + '/' + GraveName, false, true, true);
end
end;
@@ -276,10 +257,6 @@
GetExplosionBorderColor;
AddProgress;
-for i:= Low(TStuff) to High(TStuff) do
- LoadToSurface(Pathz[StuffLoadData[i].Path] + '/' + StuffLoadData[i].FileName, StoreSurface, StuffPoz[i].x, StuffPoz[i].y);
-
-AddProgress;
WriteNames(fnt16);
MakeCrossHairs;
LoadGraves;
@@ -329,16 +306,11 @@
end;
end;
-procedure DrawGear(Stuff: TStuff; X, Y: LongInt; Surface: PSDL_Surface);
-begin
-DrawFromRect(X, Y, @StuffPoz[Stuff], StoreSurface, Surface)
-end;
-
-procedure DrawSpriteFromRect(r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
+procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
begin
r.y:= r.y + Height * Position;
r.h:= Height;
-DrawFromRect(X, Y, @r, StoreSurface, Surface)
+DrawFromRect(X, Y, @r, SpritesData[Sprite].Surface, Surface)
end;
procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface);
--- a/hedgewars/uTeams.pas Sun Dec 30 15:24:02 2007 +0000
+++ b/hedgewars/uTeams.pas Sun Dec 30 16:19:41 2007 +0000
@@ -50,8 +50,9 @@
Hedgehogs: array[0..cMaxHHIndex] of THedgehog;
CurrHedgehog: LongWord;
NameTag: PSDL_Surface;
- CrosshairSurf: PSDL_Surface;
- GraveRect, HealthRect: TSDL_Rect;
+ CrosshairSurf,
+ GraveSurf: PSDL_Surface;
+ HealthRect: TSDL_Rect;
GraveName: string;
FortName: string;
TeamHealth: LongInt;
--- a/hedgewars/uWorld.pas Sun Dec 30 15:24:02 2007 +0000
+++ b/hedgewars/uWorld.pas Sun Dec 30 16:19:41 2007 +0000
@@ -232,14 +232,14 @@
// Attack bar
if CurrentTeam <> nil then
case AttackBar of
- 1: begin
+(* 1: begin
r:= StuffPoz[sPowerBar];
{$WARNINGS OFF}
r.w:= (CurrentHedgehog^.Gear^.Power * 256) div cPowerDivisor;
{$WARNINGS ON}
DrawSpriteFromRect(r, cScreenWidth - 272, cScreenHeight - 48, 16, 0, Surface);
end;
- 2: with CurrentHedgehog^ do
+*) 2: with CurrentHedgehog^ do
begin
tdx:= hwSign(Gear^.dX) * Sin(Gear^.Angle * Pi / cMaxAngle);
tdy:= - Cos(Gear^.Angle * Pi / cMaxAngle);
@@ -294,32 +294,26 @@
if isInLag then DrawSprite(sprLag, 32, 32 + cConsoleYAdd, (RealTicks shr 7) mod 12, Surface);
// Wind bar
-DrawGear(sWindBar, cScreenWidth - 180, cScreenHeight - 30, Surface);
+DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0, Surface);
if WindBarWidth > 0 then
begin
- with StuffPoz[sWindR] do
- begin
- {$WARNINGS OFF}
- r.x:= x + 8 - (RealTicks shr 6) mod 8;
- {$WARNINGS ON}
- r.y:= y;
- r.w:= WindBarWidth;
- r.h:= 13;
- end;
- DrawSpriteFromRect(r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
+ {$WARNINGS OFF}
+ r.x:= 8 - (RealTicks shr 6) mod 8;
+ {$WARNINGS ON}
+ r.y:= 0;
+ r.w:= WindBarWidth;
+ r.h:= 13;
+ DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0, Surface);
end else
if WindBarWidth < 0 then
begin
- with StuffPoz[sWindL] do
- begin
- {$WARNINGS OFF}
- r.x:= x + (WindBarWidth + RealTicks shr 6) mod 8;
- {$WARNINGS ON}
- r.y:= y;
- r.w:= - WindBarWidth;
- r.h:= 13;
- end;
- DrawSpriteFromRect(r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
+ {$WARNINGS OFF}
+ r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
+ {$WARNINGS ON}
+ r.y:= 0;
+ r.w:= - WindBarWidth;
+ r.h:= 13;
+ DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0, Surface);
end;
// AmmoMenu