hedgewars/uStore.pas
changeset 841 0700e3d3474d
parent 840 3c0028245ff3
child 842 fae2fae2fe8d
equal deleted inserted replaced
840:3c0028245ff3 841:0700e3d3474d
    22 {$INCLUDE options.inc}
    22 {$INCLUDE options.inc}
    23 
    23 
    24 procedure StoreInit;
    24 procedure StoreInit;
    25 procedure StoreLoad;
    25 procedure StoreLoad;
    26 procedure StoreRelease;
    26 procedure StoreRelease;
    27 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
    27 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
    28 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface);
    28 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt);
    29 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface);
    29 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
    30 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture; Surface: PSDL_Surface);
    30 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture);
    31 procedure DrawLand (X, Y: LongInt);
    31 procedure DrawLand (X, Y: LongInt);
    32 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
    32 procedure DrawTexture(X, Y: LongInt; Texture: PTexture);
    33 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
    33 procedure DrawRotated(Sprite: TSprite; X, Y, Dir: LongInt; Angle: real);
    34 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame: LongInt; Angle: real);
    34 procedure DrawRotatedF(Sprite: TSprite; X, Y, Frame: LongInt; Angle: real);
    35 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
    35 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
    36 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    36 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
    37 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
    37 procedure DrawCentered(X, Top: LongInt; Source: PTexture);
    38 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
    38 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
    39 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    39 procedure DrawHedgehog(X, Y: LongInt; Dir: LongInt; Pos, Step: LongWord; Angle: real);
    40 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
    40 function  RenderStringTex(s: string; Color: Longword; font: THWFont): PTexture;
    41 procedure RenderHealth(var Hedgehog: THedgehog);
    41 procedure RenderHealth(var Hedgehog: THedgehog);
    42 procedure AddProgress;
    42 procedure AddProgress;
    43 procedure FinishProgress;
    43 procedure FinishProgress;
   300 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
   300 SDL_SaveBMP_RW(LandSurface, SDL_RWFromFile('LandSurface.bmp', 'wb'), 1);
   301 SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
   301 SDL_SaveBMP_RW(StoreSurface, SDL_RWFromFile('StoreSurface.bmp', 'wb'), 1);
   302 {$ENDIF}
   302 {$ENDIF}
   303 end;
   303 end;
   304 
   304 
   305 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture; DestSurface: PSDL_Surface);
   305 procedure DrawFromRect(X, Y: LongInt; r: PSDL_Rect; SourceTexture: PTexture);
   306 var rr: TSDL_Rect;
   306 var rr: TSDL_Rect;
   307     _l, _r, _t, _b: real;
   307     _l, _r, _t, _b: real;
   308 begin
   308 begin
   309 if SourceTexture^.h = 0 then exit;
   309 if SourceTexture^.h = 0 then exit;
   310 rr.x:= X;
   310 rr.x:= X;
   369 begin
   369 begin
   370 glPushMatrix;
   370 glPushMatrix;
   371 glTranslatef(X, Y, 0);
   371 glTranslatef(X, Y, 0);
   372 glRotatef(Angle, 0, 0, 1);
   372 glRotatef(Angle, 0, 0, 1);
   373 
   373 
   374 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Width div 2, Frame, nil);
   374 DrawSprite(Sprite, -SpritesData[Sprite].Width div 2, -SpritesData[Sprite].Width div 2, Frame);
   375 
   375 
   376 glPopMatrix
   376 glPopMatrix
   377 end;
   377 end;
   378 
   378 
   379 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
   379 procedure DrawRotatedTex(Tex: PTexture; hw, hh, X, Y, Dir: LongInt; Angle: real);
   408 glEnd();
   408 glEnd();
   409 
   409 
   410 glPopMatrix
   410 glPopMatrix
   411 end;
   411 end;
   412 
   412 
   413 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt; Surface: PSDL_Surface);
   413 procedure DrawSpriteFromRect(Sprite: TSprite; r: TSDL_Rect; X, Y, Height, Position: LongInt);
   414 begin
   414 begin
   415 r.y:= r.y + Height * Position;
   415 r.y:= r.y + Height * Position;
   416 r.h:= Height;
   416 r.h:= Height;
   417 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture, Surface)
   417 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture)
   418 end;
   418 end;
   419 
   419 
   420 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt; Surface: PSDL_Surface);
   420 procedure DrawSprite (Sprite: TSprite; X, Y, Frame: LongInt);
   421 var r: TSDL_Rect;
   421 var r: TSDL_Rect;
   422 begin
   422 begin
   423 r.x:= 0;
   423 r.x:= 0;
   424 r.w:= SpritesData[Sprite].Width;
   424 r.w:= SpritesData[Sprite].Width;
   425 r.y:= Frame * SpritesData[Sprite].Height;
   425 r.y:= Frame * SpritesData[Sprite].Height;
   426 r.h:= SpritesData[Sprite].Height;
   426 r.h:= SpritesData[Sprite].Height;
   427 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture, Surface)
   427 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture)
   428 end;
   428 end;
   429 
   429 
   430 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt; Surface: PSDL_Surface);
   430 procedure DrawSprite2(Sprite: TSprite; X, Y, FrameX, FrameY: LongInt);
   431 var r: TSDL_Rect;
   431 var r: TSDL_Rect;
   432 begin
   432 begin
   433 r.x:= FrameX * SpritesData[Sprite].Width;
   433 r.x:= FrameX * SpritesData[Sprite].Width;
   434 r.w:= SpritesData[Sprite].Width;
   434 r.w:= SpritesData[Sprite].Width;
   435 r.y:= FrameY * SpritesData[Sprite].Height;
   435 r.y:= FrameY * SpritesData[Sprite].Height;
   436 r.h:= SpritesData[Sprite].Height;
   436 r.h:= SpritesData[Sprite].Height;
   437 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture, Surface)
   437 DrawFromRect(X, Y, @r, SpritesData[Sprite].Texture)
   438 end;
   438 end;
   439 
   439 
   440 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture; Surface: PSDL_Surface);
   440 procedure DrawSurfSprite(X, Y, Height, Frame: LongInt; Source: PTexture);
   441 var r: TSDL_Rect;
   441 var r: TSDL_Rect;
   442 begin
   442 begin
   443 r.x:= 0;
   443 r.x:= 0;
   444 r.w:= Source^.w;
   444 r.w:= Source^.w;
   445 r.y:= Frame * Height;
   445 r.y:= Frame * Height;
   446 r.h:= Height;
   446 r.h:= Height;
   447 DrawFromRect(X, Y, @r, Source, Surface)
   447 DrawFromRect(X, Y, @r, Source)
   448 end;
   448 end;
   449 
   449 
   450 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
   450 procedure DXOutText(X, Y: LongInt; Font: THWFont; s: string; Surface: PSDL_Surface);
   451 var clr: TSDL_Color;
   451 var clr: TSDL_Color;
   452     tmpsurf: PSDL_Surface;
   452     tmpsurf: PSDL_Surface;
   623 r.x:= 0;
   623 r.x:= 0;
   624 r.w:= ProgrTex^.w;
   624 r.w:= ProgrTex^.w;
   625 r.h:= ProgrTex^.w;
   625 r.h:= ProgrTex^.w;
   626 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w;
   626 r.y:= (Step mod (ProgrTex^.h div ProgrTex^.w)) * ProgrTex^.w;
   627 DrawFromRect((cScreenWidth - ProgrTex^.w) div 2,
   627 DrawFromRect((cScreenWidth - ProgrTex^.w) div 2,
   628              (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex, SDLPrimSurface);
   628              (cScreenHeight - ProgrTex^.w) div 2, @r, ProgrTex);
   629 glDisable(GL_TEXTURE_2D);
   629 glDisable(GL_TEXTURE_2D);
   630 SDL_GL_SwapBuffers();
   630 SDL_GL_SwapBuffers();
   631 inc(Step);
   631 inc(Step);
   632 end;
   632 end;
   633 
   633