--- a/hedgewars/uGears.pas Mon Jan 28 19:05:29 2008 +0000
+++ b/hedgewars/uGears.pas Mon Jan 28 22:21:47 2008 +0000
@@ -495,10 +495,13 @@
DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0, Surface)
else
if ShowCrosshair and ((Gear^.State and gstAttacked) = 0) then
- DrawSurfSprite(Round(hwRound(Gear^.X) + hwSign(Gear^.dX) * Sin(Gear^.Angle*pi/cMaxAngle)*60) + WorldDx - 11,
- Round(hwRound(Gear^.Y) - Cos(Gear^.Angle*pi/cMaxAngle)*60) + WorldDy - 12,
- 24, (18 + hwSign(Gear^.dX) * LongInt(((Gear^.Angle * 72 div cMaxAngle) + 1) div 2) mod 18) mod 18,
- Team^.CrosshairTex, Surface);
+ DrawRotatedTex(Team^.CrosshairTex,
+ 12, 12,
+ Round(hwRound(Gear^.X) +
+ hwSign(Gear^.dX) * Sin(Gear^.Angle*pi/cMaxAngle)*60) + WorldDx,
+ Round(hwRound(Gear^.Y) -
+ Cos(Gear^.Angle*pi/cMaxAngle)*60) + WorldDy,
+ hwSign(Gear^.dX) * Gear^.Angle * 180 / cMaxAngle)
end;
end;
--- a/hedgewars/uStore.pas Mon Jan 28 19:05:29 2008 +0000
+++ b/hedgewars/uStore.pas Mon Jan 28 22:21:47 2008 +0000
@@ -31,6 +31,7 @@
procedure DrawLand (X, Y: LongInt);
procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
procedure DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
+procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y: LongInt; Angle: real);
procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
procedure DrawCentered(X, Top: LongInt; Source: PTexture);
procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
@@ -162,7 +163,7 @@
var t: LongInt;
tmpsurf, texsurf: PSDL_Surface;
s: string;
- Color: Longword;
+ Color, i: Longword;
begin
s:= Pathz[ptGraphics] + '/' + cCHFileName;
tmpsurf:= LoadImage(s, true, true, false);
@@ -178,7 +179,18 @@
SDL_FillRect(texsurf, nil, Color);
SDL_UpperBlit(tmpsurf, nil, texsurf, nil);
- TryDo(SDL_SetColorKey(texsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true);
+
+ TryDo(tmpsurf^.format^.BytesPerPixel = 4, 'Ooops', true);
+
+ if SDL_MustLock(texsurf) then
+ SDLTry(SDL_LockSurface(texsurf) >= 0, true);
+
+ // make black pixel be alpha-transparent
+ for i:= 0 to texsurf^.w * texsurf^.h - 1 do
+ if PLongwordArray(texsurf^.pixels)^[i] = $FF000000 then PLongwordArray(texsurf^.pixels)^[i]:= 0;
+
+ if SDL_MustLock(texsurf) then
+ SDL_UnlockSurface(texsurf);
CrosshairTex:= Surface2Tex(texsurf);
SDL_FreeSurface(texsurf)
@@ -369,14 +381,19 @@
procedure DrawRotated(Sprite: TSprite; X, Y: LongInt; Angle: real);
var hw, hh: LongInt;
begin
+DrawRotatedTex(SpritesData[Sprite].Texture,
+ SpritesData[Sprite].Width,
+ SpritesData[Sprite].Height,
+ X, Y, Angle)
+end;
+
+procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y: LongInt; Angle: real);
+begin
glPushMatrix;
glTranslatef(X, Y, 0);
glRotatef(Angle, 0, 0, 1);
-hw:= SpritesData[Sprite].Width;
-hh:= SpritesData[Sprite].Height;
-
-glBindTexture(GL_TEXTURE_2D, SpritesData[Sprite].Texture^.id);
+glBindTexture(GL_TEXTURE_2D, Tex^.id);
glBegin(GL_QUADS);
--- a/hedgewars/uWorld.pas Mon Jan 28 19:05:29 2008 +0000
+++ b/hedgewars/uWorld.pas Mon Jan 28 22:21:47 2008 +0000
@@ -174,6 +174,8 @@
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
+//glPushMatrix;
+//glScalef(1.0, 1.0, 1.0);
if not isPaused then MoveCamera;
@@ -249,6 +251,8 @@
// Target
if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0, Surface);
+//glPopMatrix;
+
// Captions
i:= 8;
for grp:= Low(TCapGroup) to High(TCapGroup) do
Binary file share/hedgewars/Data/Graphics/Crosshair.png has changed