hedgewars/uWorld.pas
changeset 2567 02ff5f9510b5
parent 2553 7d8d62a5566e
child 2569 6f77dd38294a
equal deleted inserted replaced
2565:54296af65fe9 2567:02ff5f9510b5
   317 var i, t: LongInt;
   317 var i, t: LongInt;
   318     r: TSDL_Rect;
   318     r: TSDL_Rect;
   319     tdx, tdy: Double;
   319     tdx, tdy: Double;
   320     grp: TCapGroup;
   320     grp: TCapGroup;
   321     s: string[15];
   321     s: string[15];
       
   322     x,y: LongInt;
       
   323     offset: LongInt;
   322 begin
   324 begin
   323 if ZoomValue < zoom then
   325 if ZoomValue < zoom then
   324 	begin
   326 	begin
   325 	zoom:= zoom - 0.002 * Lag;
   327 	zoom:= zoom - 0.002 * Lag;
   326 	if ZoomValue > zoom then zoom:= ZoomValue
   328 	if ZoomValue > zoom then zoom:= ZoomValue
   336 glEnable(GL_BLEND);
   338 glEnable(GL_BLEND);
   337 glEnable(GL_TEXTURE_2D);
   339 glEnable(GL_TEXTURE_2D);
   338 //glPushMatrix;
   340 //glPushMatrix;
   339 //glScalef(1.0, 1.0, 1.0);
   341 //glScalef(1.0, 1.0, 1.0);
   340 
   342 
       
   343 {$IFDEF IPHONEOS}
       
   344 {* see the code in MainLoop *}
       
   345 SDL_GetMouseState(0, @x, @y);
       
   346 if (x > 100) and (x < 220) and (y > 200) and (y < 280) then
       
   347 {$ENDIF}
   341 if not isPaused then MoveCamera;
   348 if not isPaused then MoveCamera;
   342 
   349 
   343 if not cReducedQuality then
   350 if not cReducedQuality then
   344     begin
   351     begin
   345     // background
   352     // background
   386 
   393 
   387 DrawWater(cWaterOpacity);
   394 DrawWater(cWaterOpacity);
   388 
   395 
   389 // Waves
   396 // Waves
   390 DrawWaves( 1, 25, - cWaveHeight);
   397 DrawWaves( 1, 25, - cWaveHeight);
   391 DrawWaves(-1, 50, - (cWaveHeight div 2));
   398 DrawWaves(-1, 50, - (cWaveHeight shr 1));
   392 DrawWaves( 1, 75, 0);
   399 DrawWaves( 1, 75, 0);
   393 
   400 
   394 
   401 
   395 {$WARNINGS OFF}
   402 {$WARNINGS OFF}
   396 // Target
   403 // Target
   397 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0);
   404 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0);
   398 
   405 
   399 {$WARNINGS ON}
   406 {$WARNINGS ON}
   400 SetScale(2.0);
   407 SetScale(2.0);
   401 
   408 
       
   409 {$IFDEF IPHONEOS}
       
   410 offset:= 465;
       
   411 {$ELSE}
       
   412 offset:= 48;
       
   413 {$ENDIF}
   402 // Turn time
   414 // Turn time
   403 if TurnTimeLeft <> 0 then
   415 if TurnTimeLeft <> 0 then
   404    begin
   416    begin
   405    i:= Succ(Pred(TurnTimeLeft) div 1000);
   417    i:= Succ(Pred(TurnTimeLeft) div 1000);
   406    if i>99 then t:= 112
   418    if i>99 then t:= 112
   407       else if i>9 then t:= 96
   419       else if i>9 then t:= 96
   408                   else t:= 80;
   420                   else t:= 80;
   409    DrawSprite(sprFrame, -cScreenWidth div 2 + t, cScreenHeight - 48, 1);
   421    DrawSprite(sprFrame, -cScreenWidth div 2 + t, cScreenHeight - offset, 1);
   410    while i > 0 do
   422    while i > 0 do
   411          begin
   423          begin
   412          dec(t, 32);
   424          dec(t, 32);
   413          DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, cScreenHeight - 48, i mod 10);
   425          DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, cScreenHeight - offset, i mod 10);
   414          i:= i div 10
   426          i:= i div 10
   415          end;
   427          end;
   416    DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, cScreenHeight - 48, 0);
   428    DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, cScreenHeight - offset, 0);
   417    end;
   429    end;
   418 
   430 
       
   431 {$IFNDEF IPHONEOS}
   419 // Timetrial
   432 // Timetrial
   420 if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then
   433 if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then
   421 	begin
   434 	begin
   422 	if TimeTrialStopTime = 0 then i:= RealTicks - TimeTrialStartTime else i:= TimeTrialStopTime - TimeTrialStartTime;
   435 	if TimeTrialStopTime = 0 then i:= RealTicks - TimeTrialStartTime else i:= TimeTrialStopTime - TimeTrialStartTime;
   423 	t:= 272;
   436 	t:= 272;
   457 	// 10 m
   470 	// 10 m
   458     DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
   471     DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, 8, i mod 10);
   459 	// left frame
   472 	// left frame
   460 	DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0);
   473 	DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, 8, 0);
   461 	end;
   474 	end;
   462    
   475 {$ENDIF}
       
   476 
   463 // Captions
   477 // Captions
       
   478 {$IFDEF IPHONEOS}
       
   479 i:= 53;
       
   480 {$ELSE}
   464 if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then i:= 48 else i:= 8;
   481 if ((TrainingFlags and tfTimeTrial) <> 0) and (TimeTrialStartTime > 0) then i:= 48 else i:= 8;
       
   482 {$ENDIF}
   465 
   483 
   466 for grp:= Low(TCapGroup) to High(TCapGroup) do
   484 for grp:= Low(TCapGroup) to High(TCapGroup) do
   467     with Captions[grp] do
   485     with Captions[grp] do
   468          if Tex <> nil then
   486          if Tex <> nil then
   469             begin
   487             begin
   495 
   513 
   496       DrawFromRect(TeamHealthBarWidth + 2, cScreenHeight + DrawHealthY, @r, HealthTex);
   514       DrawFromRect(TeamHealthBarWidth + 2, cScreenHeight + DrawHealthY, @r, HealthTex);
   497       end;
   515       end;
   498 
   516 
   499 // Lag alert
   517 // Lag alert
   500 if isInLag then DrawSprite(sprLag, 32 - cScreenWidth div 2, 32, (RealTicks shr 7) mod 12);
   518 if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
   501 
   519 
   502 // Wind bar
   520 // Wind bar
   503 DrawSprite(sprWindBar, cScreenWidth div 2 - 180, cScreenHeight - 30, 0);
   521 {$IFDEF IPHONEOS}
       
   522 offset:= 450;
       
   523 {$ELSE}
       
   524 offset:= 30;
       
   525 {$ENDIF}
       
   526 DrawSprite(sprWindBar, (cScreenWidth shr 1) - 180, cScreenHeight - offset, 0);
   504 if WindBarWidth > 0 then
   527 if WindBarWidth > 0 then
   505    begin
   528    begin
   506    {$WARNINGS OFF}
   529    {$WARNINGS OFF}
   507    r.x:= 8 - (RealTicks shr 6) mod 8;
   530    r.x:= 8 - (RealTicks shr 6) mod 8;
   508    {$WARNINGS ON}
   531    {$WARNINGS ON}
   509    r.y:= 0;
   532    r.y:= 0;
   510    r.w:= WindBarWidth;
   533    r.w:= WindBarWidth;
   511    r.h:= 13;
   534    r.h:= 13;
   512    DrawSpriteFromRect(sprWindR, r, cScreenWidth div 2 - 103, cScreenHeight - 28, 13, 0);
   535    DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - 103, cScreenHeight - offset - 2, 13, 0);
   513    end else
   536    end else
   514  if WindBarWidth < 0 then
   537  if WindBarWidth < 0 then
   515    begin
   538    begin
   516    {$WARNINGS OFF}
   539    {$WARNINGS OFF}
   517    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   540    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   518    {$WARNINGS ON}
   541    {$WARNINGS ON}
   519    r.y:= 0;
   542    r.y:= 0;
   520    r.w:= - WindBarWidth;
   543    r.w:= - WindBarWidth;
   521    r.h:= 13;
   544    r.h:= 13;
   522    DrawSpriteFromRect(sprWindL, r, cScreenWidth div 2 - 106 + WindBarWidth, cScreenHeight - 28, 13, 0);
   545    DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - 106 + WindBarWidth, cScreenHeight - offset - 2, 13, 0);
   523    end;
   546    end;
   524 
   547 
   525 // AmmoMenu
   548 // AmmoMenu
   526 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   549 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   527 
   550 
   528 // Cursor
   551 // Cursor
   529 if isCursorVisible and bShowAmmoMenu then
   552 if isCursorVisible and bShowAmmoMenu then
   530    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
   553    DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8);
   531 
   554 
       
   555 {$IFNDEF IPHONEOS}
       
   556 {* do not draw the chat because a) no input b) too little space*}
   532 DrawChat;
   557 DrawChat;
   533 
   558 {$ENDIF}
   534 if fastUntilLag then DrawCentered(0, cScreenHeight div 2, SyncTexture);
   559 
   535 if isPaused then DrawCentered(0, cScreenHeight div 2, PauseTexture);
   560 if fastUntilLag then DrawCentered(0, (cScreenHeight shr 1), SyncTexture);
       
   561 if isPaused then DrawCentered(0, (cScreenHeight shr 1), PauseTexture);
   536 
   562 
   537 inc(Frames);
   563 inc(Frames);
   538 if cShowFPS then
   564 if cShowFPS then
   539    begin
   565    begin
   540    inc(CountTicks, Lag);
   566    inc(CountTicks, Lag);
   548       tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
   574       tmpSurface:= TTF_RenderUTF8_Blended(Fontz[fnt16].Handle, Str2PChar(s), $FFFFFF);
   549       fpsTexture:= Surface2Tex(tmpSurface, false);
   575       fpsTexture:= Surface2Tex(tmpSurface, false);
   550       SDL_FreeSurface(tmpSurface)
   576       SDL_FreeSurface(tmpSurface)
   551       end;
   577       end;
   552    if fpsTexture <> nil then
   578    if fpsTexture <> nil then
   553       DrawTexture(cScreenWidth div 2 - 50, 10, fpsTexture);
   579       DrawTexture((cScreenWidth shr 1) - 50, 10, fpsTexture);
   554    end;
   580    end;
   555 
   581 
   556 inc(SoundTimerTicks, Lag);
   582 inc(SoundTimerTicks, Lag);
   557 if SoundTimerTicks >= 50 then
   583 if SoundTimerTicks >= 50 then
   558    begin
   584    begin
   613 {$IFDEF SDL13}
   639 {$IFDEF SDL13}
   614 	SDL_GetMouseState(0, @CursorPoint.X, @CursorPoint.Y);
   640 	SDL_GetMouseState(0, @CursorPoint.X, @CursorPoint.Y);
   615 {$ELSE}
   641 {$ELSE}
   616 	SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   642 	SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   617 {$ENDIF}
   643 {$ENDIF}
   618 	CursorPoint.X:= CursorPoint.X - cScreenWidth div 2;
   644 	CursorPoint.X:= CursorPoint.X - (cScreenWidth shr 1);
   619 	CursorPoint.Y:= cScreenHeight - CursorPoint.Y;
   645 	CursorPoint.Y:= cScreenHeight - CursorPoint.Y;
   620 	end;
   646 	end;
   621 
   647 
   622 if (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
   648 if (FollowGear <> nil) and (not isCursorVisible) and (not fastUntilLag) then
   623 	if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   649 	if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   688       CursorPoint.X:= 0;
   714       CursorPoint.X:= 0;
   689       CursorPoint.Y:= cScreenHeight div 2;
   715       CursorPoint.Y:= cScreenHeight div 2;
   690       end;
   716       end;
   691 
   717 
   692 prevPoint:= CursorPoint;
   718 prevPoint:= CursorPoint;
   693 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
   719 if cHasFocus then SDL_WarpMouse(CursorPoint.X + (cScreenWidth shr 1), cScreenHeight - CursorPoint.Y);
   694 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
   720 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
   695 if WorldDy < wdy then WorldDy:= wdy;
   721 if WorldDy < wdy then WorldDy:= wdy;
   696 if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
   722 if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
   697 if WorldDx > 1024 then WorldDx:= 1024;
   723 if WorldDx > 1024 then WorldDx:= 1024;
   698 end;
   724 end;