hedgewars/uWorld.pas
changeset 4393 883b979697e4
parent 4380 b78638b36b89
child 4482 34393349f96e
equal deleted inserted replaced
4392:95e27e12d0e9 4393:883b979697e4
    25 procedure initModule;
    25 procedure initModule;
    26 procedure freeModule;
    26 procedure freeModule;
    27 
    27 
    28 procedure InitWorld;
    28 procedure InitWorld;
    29 procedure DrawWorld(Lag: LongInt);
    29 procedure DrawWorld(Lag: LongInt);
    30 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
       
    31 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    30 procedure ShowMission(caption, subcaption, text: ansistring; icon, time : LongInt);
    32 procedure HideMission;
    31 procedure HideMission;
    33 procedure ShakeCamera(amount: LongWord);
    32 procedure ShakeCamera(amount: LongWord);
    34 procedure MoveCamera;
    33 procedure MoveCamera;
    35 
    34 
    47     GLunit,
    46     GLunit,
    48     uVariables,
    47     uVariables,
    49     uUtils,
    48     uUtils,
    50     uTextures,
    49     uTextures,
    51     uRender,
    50     uRender,
    52     uRenderUtils
    51     uCaptions
    53     ;
    52     ;
    54 
    53 
    55 type TCaptionStr = record
       
    56                    Tex: PTexture;
       
    57                    EndTime: LongWord;
       
    58                    end;
       
    59 
       
    60 var cWaveWidth, cWaveHeight: LongInt;
    54 var cWaveWidth, cWaveHeight: LongInt;
    61     Captions: array[TCapGroup] of TCaptionStr;
       
    62     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    55     AMSlotSize, AMxOffset, AMyOffset, AMWidth, AMxShift, SlotsNum: LongInt;
    63     tmpSurface: PSDL_Surface;
    56     tmpSurface: PSDL_Surface;
    64     fpsTexture: PTexture;
    57     fpsTexture: PTexture;
    65     timeTexture: PTexture;
    58     timeTexture: PTexture;
    66     FPS: Longword;
    59     FPS: Longword;
   535 
   528 
   536 procedure DrawWorld(Lag: LongInt);
   529 procedure DrawWorld(Lag: LongInt);
   537 var i, t: LongInt;
   530 var i, t: LongInt;
   538     r: TSDL_Rect;
   531     r: TSDL_Rect;
   539     tdx, tdy: Double;
   532     tdx, tdy: Double;
   540     grp: TCapGroup;
       
   541     s: string[15];
   533     s: string[15];
   542     highlight: Boolean;
   534     highlight: Boolean;
   543     offset, offsetX, offsetY, ScreenBottom: LongInt;
   535     offsetX, offsetY, ScreenBottom: LongInt;
   544     VertexBuffer: array [0..3] of TVertex2f;
   536     VertexBuffer: array [0..3] of TVertex2f;
   545 begin
   537 begin
   546     if not isPaused then
   538     if not isPaused then
   547     begin
   539     begin
   548         if ZoomValue < zoom then
   540         if ZoomValue < zoom then
   739     DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0);
   731     DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0);
   740     end;
   732     end;
   741 {$ENDIF}
   733 {$ENDIF}
   742 
   734 
   743 // Captions
   735 // Captions
   744 {$IFDEF IPHONEOS}
   736 DrawCaptions;
   745 offset:= 40;
       
   746 {$ELSE}
       
   747 if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then offset:= 48
       
   748 else offset:= 8;
       
   749 {$ENDIF}
       
   750 
       
   751     for grp:= Low(TCapGroup) to High(TCapGroup) do
       
   752         with Captions[grp] do
       
   753             if Tex <> nil then
       
   754             begin
       
   755                 DrawCentered(0, offset, Tex);
       
   756                 inc(offset, Tex^.h + 2);
       
   757                 if EndTime <= RealTicks then
       
   758                 begin
       
   759                     FreeTexture(Tex);
       
   760                     Tex:= nil;
       
   761                     EndTime:= 0
       
   762                 end;
       
   763             end;
       
   764 
   737 
   765 // Teams Healths
   738 // Teams Healths
   766 for t:= 0 to Pred(TeamsCount) do
   739 for t:= 0 to Pred(TeamsCount) do
   767    with TeamsArray[t]^ do
   740    with TeamsArray[t]^ do
   768       begin
   741       begin
  1002      end
   975      end
  1003    end;
   976    end;
  1004 isFirstFrame:= false
   977 isFirstFrame:= false
  1005 end;
   978 end;
  1006 
   979 
  1007 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
       
  1008 begin
       
  1009 //if Group in [capgrpGameState] then WriteLnToConsole(s);
       
  1010     if Captions[Group].Tex <> nil then
       
  1011         FreeTexture(Captions[Group].Tex);
       
  1012     Captions[Group].Tex:= nil;
       
  1013 
       
  1014     Captions[Group].Tex:= RenderStringTex(s, Color, fntBig);
       
  1015 
       
  1016     case Group of
       
  1017         capgrpGameState: Captions[Group].EndTime:= RealTicks + 2200
       
  1018     else
       
  1019         Captions[Group].EndTime:= RealTicks + 1400 + LongWord(Captions[Group].Tex^.w) * 3;
       
  1020     end;
       
  1021 end;
       
  1022 
       
  1023 procedure MoveCamera;
   980 procedure MoveCamera;
  1024 var EdgesDist,  wdy: LongInt;
   981 var EdgesDist,  wdy: LongInt;
  1025     PrevSentPointTime: LongWord = 0;
   982     PrevSentPointTime: LongWord = 0;
  1026 begin
   983 begin
  1027 {$IFNDEF IPHONEOS}
   984 {$IFNDEF IPHONEOS}
  1182     prevPoint.X:= 0;
  1139     prevPoint.X:= 0;
  1183     prevPoint.Y:= 0;
  1140     prevPoint.Y:= 0;
  1184     missionTimer:= 0;
  1141     missionTimer:= 0;
  1185     missionTex:= nil;
  1142     missionTex:= nil;
  1186     cOffsetY:= 0;
  1143     cOffsetY:= 0;
  1187 
       
  1188     FillChar(Captions, sizeof(Captions), 0)
       
  1189 end;
  1144 end;
  1190 
  1145 
  1191 procedure freeModule;
  1146 procedure freeModule;
  1192 begin
  1147 begin
  1193 end;
  1148 end;