hedgewars/uWorld.pas
changeset 3405 8fdb08497bf1
parent 3395 095273ad0e08
child 3407 dcc129c4352e
equal deleted inserted replaced
3404:d445798e5fe2 3405:8fdb08497bf1
    35     SkyOffset: LongInt;
    35     SkyOffset: LongInt;
    36     HorizontOffset: LongInt;
    36     HorizontOffset: LongInt;
    37 {$IFDEF COUNTTICKS}
    37 {$IFDEF COUNTTICKS}
    38     cntTicks: LongWord;
    38     cntTicks: LongWord;
    39 {$ENDIF}
    39 {$ENDIF}
    40 
    40     wScreen: LongInt;
       
    41     hScreen: LongInt;
       
    42     
    41 procedure initModule;
    43 procedure initModule;
    42 procedure freeModule;
    44 procedure freeModule;
    43 
    45 
    44 procedure InitWorld;
    46 procedure InitWorld;
    45 procedure DrawWorld(Lag: LongInt);
    47 procedure DrawWorld(Lag: LongInt);
    92         if (GameFlags and gf) <> 0 then
    94         if (GameFlags and gf) <> 0 then
    93             s:= s + trgoal[si] + '|';
    95             s:= s + trgoal[si] + '|';
    94         AddGoal:= s;
    96         AddGoal:= s;
    95     end;
    97     end;
    96 begin
    98 begin
    97 missionTimer:= 0;
    99     missionTimer:= 0;
       
   100     // initialized here because when initModule is called cScreenWidth/Height are not yet set
       
   101     if (uWorld.wScreen = 0) and (uWorld.hScreen = 0) then
       
   102     begin
       
   103         uWorld.wScreen:= cScreenWidth; 
       
   104         uWorld.hScreen:= cScreenHeight;
       
   105     end;
    98 
   106 
    99 if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
   107 if (GameFlags and gfRandomOrder) <> 0 then  // shuffle them up a bit
   100    begin
   108    begin
   101    for i:= 0 to ClansCount * 4 do
   109    for i:= 0 to ClansCount * 4 do
   102       begin
   110       begin
   168 AMxShift:= 210;
   176 AMxShift:= 210;
   169 SkyOffset:= 0;
   177 SkyOffset:= 0;
   170 HorizontOffset:= 0;
   178 HorizontOffset:= 0;
   171 end;
   179 end;
   172 
   180 
       
   181 
   173 procedure ShowAmmoMenu;
   182 procedure ShowAmmoMenu;
   174 const MENUSPEED = 15;
   183 const MENUSPEED = 15;
   175 {$IFDEF IPHONEOS}
   184 {$IFDEF IPHONEOS}
   176 const MENUWIDTH = 210;
   185 const MENUWIDTH = 210;
   177 {$ELSE}
   186 {$ELSE}
   179 {$ENDIF}
   188 {$ENDIF}
   180 var x, y, i, t, l, g: LongInt;
   189 var x, y, i, t, l, g: LongInt;
   181     Slot, Pos: LongInt;
   190     Slot, Pos: LongInt;
   182     Ammo: PHHAmmo;
   191     Ammo: PHHAmmo;
   183 begin
   192 begin
   184 if  (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then bShowAmmoMenu:= false;
   193     if (TurnTimeLeft = 0) or (not CurrentTeam^.ExtDriven and (((CurAmmoGear = nil) or 
   185 if bShowAmmoMenu then
   194        ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) = 0)) and hideAmmoMenu)) then
   186    begin
   195             bShowAmmoMenu:= false;
   187    FollowGear:= nil;
   196     if bShowAmmoMenu then
   188    if AMxShift = MENUWIDTH then prevPoint.X:= 0;
   197     begin
   189    if cReducedQuality then
   198         FollowGear:= nil;
   190        AMxShift:= 0
   199         if AMxShift = MENUWIDTH then 
   191    else
   200             prevPoint.X:= 0;
   192        if AMxShift > 0 then dec(AMxShift, MENUSPEED);
   201         if cReducedQuality then
   193    end else
   202             AMxShift:= 0
   194    begin
   203         else
   195    if AMxShift = 0 then
   204             if AMxShift > 0 then 
   196       begin
   205                 dec(AMxShift, MENUSPEED);
   197       CursorPoint.X:= cScreenWidth shr 1;
   206     end
   198       CursorPoint.Y:= cScreenHeight shr 1;
   207     else
   199       prevPoint:= CursorPoint;
   208     begin
   200       SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
   209         if AMxShift = 0 then
   201       end;
   210         begin
   202    if cReducedQuality then
   211             CursorPoint.X:= cScreenWidth shr 1;
   203        AMxShift:= MENUWIDTH
   212             CursorPoint.Y:= cScreenHeight shr 1;
   204    else
   213             prevPoint:= CursorPoint;
   205        if AMxShift < MENUWIDTH then inc(AMxShift, MENUSPEED);
   214             SDL_WarpMouse(CursorPoint.X  + cScreenWidth div 2, cScreenHeight - CursorPoint.Y)
   206    end;
   215         end;
   207 Ammo:= nil;
   216         if cReducedQuality then
   208 if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then
   217             AMxShift:= MENUWIDTH
   209    Ammo:= CurrentHedgehog^.Ammo
   218     else
   210 else if (LocalAmmo <> -1) then
   219         if AMxShift < MENUWIDTH then
   211    Ammo:= GetAmmoByNum(LocalAmmo);
   220             inc(AMxShift, MENUSPEED);
   212 Slot:= 0;
   221     end;
   213 Pos:= -1;
   222    
   214 if Ammo = nil then
   223     Ammo:= nil;
   215     begin
   224     if (CurrentTeam <> nil) and (CurrentHedgehog <> nil) and (not CurrentTeam^.ExtDriven) and
   216     bShowAmmoMenu:= false;
   225        (CurrentHedgehog^.BotLevel = 0) then
   217     exit
   226         Ammo:= CurrentHedgehog^.Ammo
   218     end;
   227     else
   219 SlotsNum:= 0;
   228         if (LocalAmmo <> -1) then
   220 x:= (cScreenWidth shr 1) - MENUWIDTH + AMxShift;
   229             Ammo:= GetAmmoByNum(LocalAmmo);
   221 y:= cScreenHeight - 40;
   230         Slot:= 0;
       
   231         Pos:= -1;
       
   232         if Ammo = nil then
       
   233         begin
       
   234             bShowAmmoMenu:= false;
       
   235             exit
       
   236         end;
       
   237         SlotsNum:= 0;
       
   238         x:= (cScreenWidth shr 1) - MENUWIDTH + AMxShift;
       
   239         y:= cScreenHeight - 40;
   222 
   240 
   223 {$IFDEF IPHONEOS}
   241 {$IFDEF IPHONEOS}
   224 dec(y);
   242         dec(y);
   225 DrawSprite(sprAMBordersIPhone, x, y, 0);
   243         DrawSprite(sprAMBordersIPhone, x, y, 0);
   226 dec(y);
   244         dec(y);
   227 DrawSprite(sprAMBordersIPhone, x, y, 1);
   245         DrawSprite(sprAMBordersIPhone, x, y, 1);
   228 dec(y, 33);
   246         dec(y, 33);
   229 DrawSprite(sprAMSlotNameIPhone, x, y, 0);
   247         DrawSprite(sprAMSlotNameIPhone, x, y, 0);
   230 {$ELSE}
   248 {$ELSE}
   231 dec(y);
   249         dec(y);
   232 DrawSprite(sprAMBorders, x, y, 0);
   250         DrawSprite(sprAMBorders, x, y, 0);
   233 dec(y);
   251         dec(y);
   234 DrawSprite(sprAMBorders, x, y, 1);
   252         DrawSprite(sprAMBorders, x, y, 1);
   235 dec(y, 33);
   253         dec(y, 33);
   236 DrawSprite(sprAMSlotName, x, y, 0);
   254         DrawSprite(sprAMSlotName, x, y, 0);
   237 {$ENDIF}
   255 {$ENDIF}
   238 
   256 
   239 for i:= cMaxSlotIndex downto 0 do
   257         for i:= cMaxSlotIndex downto 0 do
   240     if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   258             if ((i = 0) and (Ammo^[i, 1].Count > 0)) or ((i <> 0) and (Ammo^[i, 0].Count > 0)) then
   241         begin
       
   242         if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then Slot:= i;
       
   243         dec(y, 33);
       
   244         inc(SlotsNum);
       
   245         {$IFDEF IPHONEOS}
       
   246         DrawSprite(sprAMSlotIPhone, x, y, 0);
       
   247         {$ELSE}
       
   248         DrawSprite(sprAMSlot, x, y, 0);
       
   249         DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
       
   250         {$ENDIF}
       
   251         t:= 0;
       
   252         {$IFDEF IPHONEOS}
       
   253         g:= -1;
       
   254         {$ELSE}
       
   255         g:= 0;
       
   256         {$ENDIF}
       
   257         while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
       
   258             begin
   259             begin
   259             if (Ammo^[i, t].AmmoType <> amNothing) then
   260                 if (cScreenHeight - CursorPoint.Y >= y - 33) and (cScreenHeight - CursorPoint.Y < y) then 
       
   261                     Slot:= i;
       
   262                 dec(y, 33);
       
   263                 inc(SlotsNum);
       
   264 {$IFDEF IPHONEOS}
       
   265                 DrawSprite(sprAMSlotIPhone, x, y, 0);
       
   266                 g:= -1;
       
   267 {$ELSE}
       
   268                 DrawSprite(sprAMSlot, x, y, 0);
       
   269                 DrawSprite(sprAMSlotKeys, x + 2, y + 1, i);
       
   270                 g:= 0;
       
   271 {$ENDIF}
       
   272                 t:= 0;
       
   273 
       
   274                 while (t <= cMaxSlotAmmoIndex) and (Ammo^[i, t].Count > 0) do
   260                 begin
   275                 begin
   261                 l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   276                     if (Ammo^[i, t].AmmoType <> amNothing) then
   262 
       
   263                 if l >= 0 then
       
   264                     begin
   277                     begin
   265                     DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   278                         l:= Ammoz[Ammo^[i, t].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber;
   266                     if l < 100 then DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l);
   279 
   267                     end else
   280                         if l >= 0 then
   268                     DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   281                         begin
   269                 if (Slot = i)
   282                             DrawSprite(sprAMAmmosBW, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
   270                 and (CursorPoint.X >= x + g * 33 + 35)
   283                             if l < 100 then
   271                 and (CursorPoint.X < x + g * 33 + 68) then
   284                                 DrawSprite(sprTurnsLeft, x + g * 33 + 51, y + 17, l);
   272                     begin
   285                         end
   273                     if (l < 0) then DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0);
   286                         else
   274                     Pos:= t;
   287                             DrawSprite(sprAMAmmos, x + g * 33 + 35, y + 1, LongInt(Ammo^[i, t].AmmoType)-1);
       
   288                         if (Slot = i) and (CursorPoint.X >= x + g * 33 + 35) and (CursorPoint.X < x + g * 33 + 68) then
       
   289                         begin
       
   290                             if (l < 0) then 
       
   291                                 DrawSprite(sprAMSelection, x + g * 33 + 35, y + 1, 0);
       
   292                             Pos:= t;
       
   293                         end;
       
   294                         inc(g);
   275                     end;
   295                     end;
   276                 inc(g)
   296                     inc(t);
   277                 end;
   297                 end;
   278                 inc(t)
   298             end;
   279             end
   299     dec(y, 1);
   280         end;
       
   281 dec(y, 1);
       
   282 {$IFDEF IPHONEOS}
   300 {$IFDEF IPHONEOS}
   283 DrawSprite(sprAMBordersIPhone, x, y, 0);
   301     DrawSprite(sprAMBordersIPhone, x, y, 0);
   284 {$ELSE}
   302 {$ELSE}
   285 DrawSprite(sprAMBorders, x, y, 0);
   303     DrawSprite(sprAMBorders, x, y, 0);
   286 {$ENDIF}
   304 {$ENDIF}
   287 
   305 
   288 if (Pos >= 0) then
   306     if (Pos >= 0) then
   289     begin
   307     begin
   290     if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   308         if (Ammo^[Slot, Pos].Count > 0) and (Ammo^[Slot, Pos].AmmoType <> amNothing) then
   291         if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
   309             if (amSel <> Ammo^[Slot, Pos].AmmoType) or (WeaponTooltipTex = nil) then
   292             begin
   310             begin
   293             amSel:= Ammo^[Slot, Pos].AmmoType;
   311                 amSel:= Ammo^[Slot, Pos].AmmoType;
   294             RenderWeaponTooltip(amSel)
   312                 RenderWeaponTooltip(amSel)
   295             end;
   313             end;
   296         
   314         
   297         DrawTexture(cScreenWidth div 2 - (MENUWIDTH - 10) + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   315             DrawTexture(cScreenWidth div 2 - (MENUWIDTH - 10) + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   298 
   316 
   299         if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   317             if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   300             DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   318                 DrawTexture(cScreenWidth div 2 + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   301 
   319 
   302         if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   320             if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   303             begin
   321             begin
   304             bShowAmmoMenu:= false;
   322                 bShowAmmoMenu:= false;
   305             SetWeapon(Ammo^[Slot, Pos].AmmoType);
   323                 SetWeapon(Ammo^[Slot, Pos].AmmoType);
   306             bSelected:= false;
   324                 bSelected:= false;
   307             FreeWeaponTooltip;
   325                 FreeWeaponTooltip;
   308             exit
   326                 exit();
   309             end;
   327             end;
   310     end
   328     end
   311 else
   329     else
   312     FreeWeaponTooltip;
   330         FreeWeaponTooltip;
   313 
   331 
   314 if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
   332     if (WeaponTooltipTex <> nil) and (AMxShift = 0) then
   315     ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, min(y, cScreenHeight - WeaponTooltipTex^.h - 40));
   333         ShowWeaponTooltip(x - WeaponTooltipTex^.w - 3, min(y, cScreenHeight - WeaponTooltipTex^.h - 40));
   316 
   334 
   317 bSelected:= false;
   335     bSelected:= false;
   318 if AMxShift = 0 then DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   336     if AMxShift = 0 then 
       
   337         DrawSprite(sprArrow, CursorPoint.X, cScreenHeight - CursorPoint.Y, (RealTicks shr 6) mod 8)
   319 end;
   338 end;
   320 
   339 
   321 procedure MoveCamera; forward;
   340 procedure MoveCamera; forward;
   322 
   341 
   323 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   342 procedure DrawWater(Alpha: byte; OffsetY: LongInt);
   324 var VertexBuffer: array [0..3] of TVertex2f;
   343 var VertexBuffer: array [0..3] of TVertex2f;
   325     r: TSDL_Rect;
   344     r: TSDL_Rect;
   326     lw, lh: GLfloat;
   345     lw, lh: GLfloat;
   327 begin
   346 begin
   328 WaterColorArray[0].a := Alpha;
   347     WaterColorArray[0].a := Alpha;
   329 WaterColorArray[1].a := Alpha;
   348     WaterColorArray[1].a := Alpha;
   330 WaterColorArray[2].a := Alpha;
   349     WaterColorArray[2].a := Alpha;
   331 WaterColorArray[3].a := Alpha;
   350     WaterColorArray[3].a := Alpha;
   332 
   351 
   333 lw:= cScreenWidth / cScaleFactor;
   352     lw:= wScreen / cScaleFactor;
   334 lh:= trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 + 16;
   353     lh:= trunc(hScreen / cScaleFactor) + hScreen div 2 + 16;
   335 // Water
   354     
   336 r.y:= OffsetY + WorldDy + cWaterLine;
   355     // Water
   337 if WorldDy < trunc(cScreenHeight / cScaleFactor) + cScreenHeight div 2 - cWaterLine then
   356     r.y:= OffsetY + WorldDy + cWaterLine;
   338     begin
   357     if WorldDy < trunc(hScreen / cScaleFactor) + hScreen div 2 - cWaterLine then
   339     if r.y < 0 then r.y:= 0;
   358     begin
   340 
   359         if r.y < 0 then
   341     glDisable(GL_TEXTURE_2D);
   360             r.y:= 0;
   342     VertexBuffer[0].X:= -lw;
   361 
   343     VertexBuffer[0].Y:= r.y;
   362         glDisable(GL_TEXTURE_2D);
   344     VertexBuffer[1].X:= lw;
   363         VertexBuffer[0].X:= -lw;
   345     VertexBuffer[1].Y:= r.y;
   364         VertexBuffer[0].Y:= r.y;
   346     VertexBuffer[2].X:= lw;
   365         VertexBuffer[1].X:= lw;
   347     VertexBuffer[2].Y:= lh;
   366         VertexBuffer[1].Y:= r.y;
   348     VertexBuffer[3].X:= -lw;
   367         VertexBuffer[2].X:= lw;
   349     VertexBuffer[3].Y:= lh;
   368         VertexBuffer[2].Y:= lh;
   350 
   369         VertexBuffer[3].X:= -lw;
   351     glEnableClientState (GL_COLOR_ARRAY);
   370         VertexBuffer[3].Y:= lh;
   352     glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
   371 
   353 
   372         glEnableClientState (GL_COLOR_ARRAY);
   354     glEnableClientState(GL_VERTEX_ARRAY);
   373         glColorPointer(4, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
   355     glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   374 
   356 
   375         glEnableClientState(GL_VERTEX_ARRAY);
   357     glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   376         glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]);
   358 
   377 
   359     glDisableClientState(GL_VERTEX_ARRAY);
   378         glDrawArrays(GL_TRIANGLE_FAN, 0, Length(VertexBuffer));
   360     glDisableClientState(GL_COLOR_ARRAY);
   379 
   361 
   380         glDisableClientState(GL_VERTEX_ARRAY);
   362     glColor4ub($FF, $FF, $FF, $FF); // disable coloring
   381         glDisableClientState(GL_COLOR_ARRAY);
   363     glEnable(GL_TEXTURE_2D)
   382 
   364     end
   383         Tint($FF, $FF, $FF, $FF); // disable coloring
       
   384         glEnable(GL_TEXTURE_2D);
       
   385     end;
   365 end;
   386 end;
   366 
   387 
   367 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte);
   388 procedure DrawWaves(Dir, dX, dY: LongInt; tnt: Byte);
   368 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   389 var VertexBuffer, TextureBuffer: array [0..3] of TVertex2f;
   369     lw, waves, shift: GLfloat;
   390     lw, waves, shift: GLfloat;
   370 begin
   391 begin
   371 lw:= cScreenWidth / cScaleFactor;
   392 lw:= wScreen / cScaleFactor;
   372 waves:= lw * 2 / cWaveWidth;
   393 waves:= lw * 2 / cWaveWidth;
   373 
   394 
   374 Tint(
   395 Tint((tnt * WaterColorArray[2].r div 255) + (255-tnt),
   375       (tnt * WaterColorArray[2].r div 255) + (255-tnt)
   396      (tnt * WaterColorArray[2].g div 255) + (255-tnt),
   376     , (tnt * WaterColorArray[2].g div 255) + (255-tnt)
   397      (tnt * WaterColorArray[2].b div 255) + (255-tnt),
   377     , (tnt * WaterColorArray[2].b div 255) + (255-tnt)
   398       255
   378     , 255
       
   379 );
   399 );
   380 
   400 
   381 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id);
   401 glBindTexture(GL_TEXTURE_2D, SpritesData[sprWater].Texture^.id);
   382 
   402 
   383 VertexBuffer[0].X:= -lw;
   403 VertexBuffer[0].X:= -lw;
   418 end;
   438 end;
   419 
   439 
   420 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt);
   440 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift, OffsetY: LongInt);
   421 var i, w, sw: LongInt;
   441 var i, w, sw: LongInt;
   422 begin
   442 begin
   423 sw:= round(cScreenWidth / cScaleFactor);
       
   424 if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then
       
   425     begin
       
   426     w:= SpritesData[spr].Width;
       
   427     i:= Shift mod w;
       
   428     if i > 0 then dec(i, w);
       
   429     dec(i, w * (sw div w + 1));
       
   430     repeat
       
   431         DrawSprite(spr, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0);
       
   432         inc(i, w)
       
   433     until i > sw
       
   434     end else
       
   435     begin
       
   436     w:= SpritesData[spr].Width;
       
   437     dec(Shift, w div 2);
       
   438     DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0);
       
   439 
       
   440     sw:= round(cScreenWidth / cScaleFactor);
   443     sw:= round(cScreenWidth / cScaleFactor);
       
   444     if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then
       
   445     begin
       
   446         w:= SpritesData[spr].Width;
       
   447         i:= Shift mod w;
       
   448         if i > 0 then dec(i, w);
       
   449         dec(i, w * (sw div w + 1));
       
   450         repeat
       
   451             DrawSprite(spr, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0);
       
   452             inc(i, w)
       
   453         until i > sw
       
   454     end
       
   455     else
       
   456     begin
       
   457         w:= SpritesData[spr].Width;
       
   458         dec(Shift, w div 2);
       
   459         DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[spr].Height, 0);
   441     
   460     
   442     i:= Shift - SpritesData[sprL].Width;
   461         i:= Shift - SpritesData[sprL].Width;
   443     while i >= -sw - SpritesData[sprL].Width do
   462         while i >= -sw - SpritesData[sprL].Width do
   444         begin
   463         begin
   445         DrawSprite(sprL, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprL].Height, 0);
   464             DrawSprite(sprL, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprL].Height, 0);
   446         dec(i, SpritesData[sprL].Width);
   465             dec(i, SpritesData[sprL].Width);
   447         end;
   466         end;
   448         
   467         
   449     i:= Shift + w;
   468         i:= Shift + w;
   450     while i <= sw do
   469         while i <= sw do
   451         begin
   470         begin
   452         DrawSprite(sprR, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprR].Height, 0);
   471             DrawSprite(sprR, i, WorldDy + LAND_HEIGHT + OffsetY - SpritesData[sprR].Height, 0);
   453         inc(i, SpritesData[sprR].Width)
   472             inc(i, SpritesData[sprR].Width)
   454         end
   473         end
   455     end
   474     end
   456 end;
   475 end;
   457 
   476 
   458 
   477 
   725 // Lag alert
   744 // Lag alert
   726 if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
   745 if isInLag then DrawSprite(sprLag, 32 - (cScreenWidth shr 1), 32, (RealTicks shr 7) mod 12);
   727 
   746 
   728 // Wind bar
   747 // Wind bar
   729 {$IFDEF IPHONEOS}
   748 {$IFDEF IPHONEOS}
   730 offsetX:= cScreenHeight - 13;
   749     offsetX:= cScreenHeight - 13;
   731 offsetY:= (cScreenWidth shr 1) + 74;
   750     offsetY:= (cScreenWidth shr 1) + 74;
   732 {$ELSE}
   751 {$ELSE}
   733 offsetX:= 30;
   752     offsetX:= 30;
   734 offsetY:= 180;
   753     offsetY:= 180;
   735 {$ENDIF}
   754 {$ENDIF}
   736 DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0);
   755     DrawSprite(sprWindBar, (cScreenWidth shr 1) - offsetY, cScreenHeight - offsetX, 0);
   737 if WindBarWidth > 0 then
   756     if WindBarWidth > 0 then
   738    begin
   757     begin
   739    {$WARNINGS OFF}
   758         {$WARNINGS OFF}
   740    r.x:= 8 - (RealTicks shr 6) mod 8;
   759         r.x:= 8 - (RealTicks shr 6) mod 8;
   741    {$WARNINGS ON}
   760         {$WARNINGS ON}
   742    r.y:= 0;
   761         r.y:= 0;
   743    r.w:= WindBarWidth;
   762         r.w:= WindBarWidth;
   744    r.h:= 13;
   763         r.h:= 13;
   745    DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0);
   764         DrawSpriteFromRect(sprWindR, r, (cScreenWidth shr 1) - offsetY + 77, cScreenHeight - offsetX + 2, 13, 0);
   746    end else
   765     end
   747  if WindBarWidth < 0 then
   766     else
   748    begin
   767         if WindBarWidth < 0 then
   749    {$WARNINGS OFF}
   768         begin
   750    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   769             {$WARNINGS OFF}
   751    {$WARNINGS ON}
   770             r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   752    r.y:= 0;
   771             {$WARNINGS ON}
   753    r.w:= - WindBarWidth;
   772             r.y:= 0;
   754    r.h:= 13;
   773             r.w:= - WindBarWidth;
   755    DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0);
   774             r.h:= 13;
   756    end;
   775             DrawSpriteFromRect(sprWindL, r, (cScreenWidth shr 1) - offsetY + 74 + WindBarWidth, cScreenHeight - offsetX + 2, 13, 0);
       
   776         end;
   757 
   777 
   758 // AmmoMenu
   778 // AmmoMenu
   759 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   779 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   760 
   780 
   761 // Cursor
   781 // Cursor
  1049     bShowFinger:= false;
  1069     bShowFinger:= false;
  1050     Frames:= 0;
  1070     Frames:= 0;
  1051     WorldDx:= -512;
  1071     WorldDx:= -512;
  1052     WorldDy:= -256;
  1072     WorldDy:= -256;
  1053     
  1073     
       
  1074     // really initalized in initWorld
       
  1075     uWorld.wScreen:= 0; 
       
  1076     uWorld.hScreen:= 0;
       
  1077     
  1054     FPS:= 0;
  1078     FPS:= 0;
  1055     CountTicks:= 0;
  1079     CountTicks:= 0;
  1056     SoundTimerTicks:= 0;
  1080     SoundTimerTicks:= 0;
  1057     prevPoint.X:= 0;
  1081     prevPoint.X:= 0;
  1058     prevPoint.Y:= 0;
  1082     prevPoint.Y:= 0;