hedgewars/uWorld.pas
changeset 2161 0c8634241fa4
parent 2152 a2811690da1b
child 2162 2bce91404d49
equal deleted inserted replaced
2160:c83e8608dfd7 2161:0c8634241fa4
    35 	bShowAmmoMenu: boolean = false;
    35 	bShowAmmoMenu: boolean = false;
    36 	bSelected: boolean = false;
    36 	bSelected: boolean = false;
    37 	bShowFinger: boolean = false;
    37 	bShowFinger: boolean = false;
    38 	Frames: Longword = 0;
    38 	Frames: Longword = 0;
    39 	WaterColor, DeepWaterColor: TSDL_Color;
    39 	WaterColor, DeepWaterColor: TSDL_Color;
       
    40 	cWaterSprCount: LongInt;
    40 
    41 
    41 implementation
    42 implementation
    42 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound,
    43 uses uStore, uMisc, uTeams, uIO, uConsole, uKeys, uLocale, uSound,
    43 {$IFDEF GLES11}
    44 {$IFDEF GLES11}
    44 	gles11,
    45 	gles11,
    55 type TCaptionStr = record
    56 type TCaptionStr = record
    56                    Tex: PTexture;
    57                    Tex: PTexture;
    57                    EndTime: LongWord;
    58                    EndTime: LongWord;
    58                    end;
    59                    end;
    59 
    60 
    60 var cWaterSprCount, cWaveWidth, cWaveHeight: LongInt;
    61 var cWaveWidth, cWaveHeight: LongInt;
    61 	Captions: array[TCapGroup] of TCaptionStr;
    62 	Captions: array[TCapGroup] of TCaptionStr;
    62 	AMxShift, SlotsNum: LongInt;
    63 	AMxShift, SlotsNum: LongInt;
    63 	tmpSurface: PSDL_Surface;
    64 	tmpSurface: PSDL_Surface;
    64 	fpsTexture: PTexture = nil;
    65 	fpsTexture: PTexture = nil;
    65 
    66 
    66 procedure InitWorld;
    67 procedure InitWorld;
    67 begin
    68 begin
    68 cWaveWidth:= SpritesData[sprWater].Width;
    69 cWaveWidth:= SpritesData[sprWater].Width;
    69 cWaveHeight:= SpritesData[sprWater].Height;
    70 cWaveHeight:= SpritesData[sprWater].Height;
    70 cWaterSprCount:= 1 + cScreenWidth div cWaveWidth;
       
    71 cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50);
    71 cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50);
    72 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    72 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    73 prevPoint.X:= cScreenWidth div 2;
    73 prevPoint.X:= cScreenWidth div 2;
    74 prevPoint.Y:= cScreenHeight div 2;
    74 prevPoint.Y:= cScreenHeight div 2;
    75 WorldDx:=  - (LAND_WIDTH div 2) + cScreenWidth div 2;
    75 WorldDx:=  - (LAND_WIDTH div 2) + cScreenWidth div 2;
   111 Pos:= -1;
   111 Pos:= -1;
   112 with CurrentHedgehog^ do
   112 with CurrentHedgehog^ do
   113 	begin
   113 	begin
   114 	if Ammo = nil then exit;
   114 	if Ammo = nil then exit;
   115 	SlotsNum:= 0;
   115 	SlotsNum:= 0;
   116 	x:= cScreenWidth - 210 + AMxShift;
   116 	x:= cScreenWidth div 2 - 210 + AMxShift;
   117 	y:= cScreenHeight - 40;
   117 	y:= cScreenHeight - 40;
   118 	dec(y);
   118 	dec(y);
   119 	DrawSprite(sprAMBorders, x, y, 0);
   119 	DrawSprite(sprAMBorders, x, y, 0);
   120 	dec(y);
   120 	dec(y);
   121 	DrawSprite(sprAMBorders, x, y, 1);
   121 	DrawSprite(sprAMBorders, x, y, 1);
   155 	DrawSprite(sprAMBorders, x, y, 0);
   155 	DrawSprite(sprAMBorders, x, y, 0);
   156 
   156 
   157 	if (Pos >= 0) then
   157 	if (Pos >= 0) then
   158 		if Ammo^[Slot, Pos].Count > 0 then
   158 		if Ammo^[Slot, Pos].Count > 0 then
   159 		begin
   159 		begin
   160 		DrawTexture(cScreenWidth - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   160 		DrawTexture(cScreenWidth div 2 - 200 + AMxShift, cScreenHeight - 68, Ammoz[Ammo^[Slot, Pos].AmmoType].NameTex);
   161 		
   161 		
   162 		if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   162 		if Ammo^[Slot, Pos].Count < AMMO_INFINITE then
   163 			DrawTexture(cScreenWidth + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   163 			DrawTexture(cScreenWidth + AMxShift - 35, cScreenHeight - 68, CountTexz[Ammo^[Slot, Pos].Count]);
   164 		
   164 		
   165 		if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   165 		if bSelected and (Ammoz[Ammo^[Slot, Pos].AmmoType].SkipTurns - CurrentTeam^.Clan^.TurnNumber < 0) then
   179 procedure MoveCamera; forward;
   179 procedure MoveCamera; forward;
   180 
   180 
   181 procedure DrawWater;
   181 procedure DrawWater;
   182 var VertexBuffer: array [0..3] of TVertex2f;
   182 var VertexBuffer: array [0..3] of TVertex2f;
   183     r: TSDL_Rect;
   183     r: TSDL_Rect;
       
   184     lw, lh: GLfloat;
   184 begin
   185 begin
       
   186 lw:= cScreenWidth / cScaleFactor;
       
   187 lh:= cScreenHeight * 2 / cScaleFactor;
   185 // Water
   188 // Water
   186 r.y:= WorldDy + cWaterLine + 32;
   189 r.y:= WorldDy + cWaterLine + 32;
   187 if r.y < cScreenHeight then
   190 if r.y < cScreenHeight * 2 / cScaleFactor then
   188 	begin
   191 	begin
   189 	if r.y < 0 then r.y:= 0;
   192 	if r.y < 0 then r.y:= 0;
   190 
   193 
   191 	glDisable(GL_TEXTURE_2D);
   194 	glDisable(GL_TEXTURE_2D);
   192 	VertexBuffer[0].X:= 0;
   195 	VertexBuffer[0].X:= -lw;
   193 	VertexBuffer[0].Y:= r.y;
   196 	VertexBuffer[0].Y:= r.y;
   194 	VertexBuffer[1].X:= cScreenWidth;
   197 	VertexBuffer[1].X:= lw;
   195 	VertexBuffer[1].Y:= r.y;
   198 	VertexBuffer[1].Y:= r.y;
   196 	VertexBuffer[2].X:= cScreenWidth;
   199 	VertexBuffer[2].X:= lw;
   197 	VertexBuffer[2].Y:= cScreenHeight;
   200 	VertexBuffer[2].Y:= lh;
   198 	VertexBuffer[3].X:= 0;
   201 	VertexBuffer[3].X:= -lw;
   199 	VertexBuffer[3].Y:= cScreenHeight;
   202 	VertexBuffer[3].Y:= lh;
   200 
   203 
   201 	glEnableClientState (GL_COLOR_ARRAY);
   204 	glEnableClientState (GL_COLOR_ARRAY);
   202 	glColorPointer(3, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
   205 	glColorPointer(3, GL_UNSIGNED_BYTE, 0, @WaterColorArray[0]);
   203 
   206 
   204 	glEnableClientState(GL_VERTEX_ARRAY);
   207 	glEnableClientState(GL_VERTEX_ARRAY);
   220     tdx, tdy: Double;
   223     tdx, tdy: Double;
   221     grp: TCapGroup;
   224     grp: TCapGroup;
   222     s: string[15];
   225     s: string[15];
   223 
   226 
   224     procedure DrawRepeated(spr: TSprite; Shift: LongInt);
   227     procedure DrawRepeated(spr: TSprite; Shift: LongInt);
   225     var i, w: LongInt;
   228     var i, w, sw: LongInt;
   226     begin
   229     begin
       
   230     sw:= round(cScreenWidth / cScaleFactor);
   227     w:= SpritesData[spr].Width;
   231     w:= SpritesData[spr].Width;
   228     i:= Shift mod w;
   232     i:= Shift mod w;
   229     if i > 0 then dec(i, w);
   233     if i > 0 then dec(i, w);
       
   234     dec(i, sw);
       
   235     //addfilelog(inttostr(sw));
   230     repeat
   236     repeat
   231       DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
   237       DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
   232       inc(i, w)
   238       inc(i, w)
   233     until i > cScreenWidth
   239     until i > sw
   234     end;
   240     end;
   235 
   241 
   236 begin
   242 begin
   237 // Sky
   243 // Sky
   238 glClear(GL_COLOR_BUFFER_BIT);
   244 glClear(GL_COLOR_BUFFER_BIT);
   251 
   257 
   252     DrawVisualGears(0);
   258     DrawVisualGears(0);
   253 
   259 
   254     // Waves
   260     // Waves
   255     {$WARNINGS OFF}
   261     {$WARNINGS OFF}
   256     for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6)      ) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight*2), 0);
   262 //    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6)      ) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight*2), 0);
   257     for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth + ((WorldDx - (RealTicks shr 6) + 100) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight + cWaveHeight div 2), 0);
   263 //    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth + ((WorldDx - (RealTicks shr 6) + 100) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight + cWaveHeight div 2), 0);
   258     {$WARNINGS ON}
   264     {$WARNINGS ON}
   259     end;
   265     end;
   260 
   266 
   261 
   267 
   262 DrawLand(WorldDx, WorldDy);
   268 DrawLand(WorldDx, WorldDy);
   289 
   295 
   290 DrawVisualGears(1);
   296 DrawVisualGears(1);
   291 
   297 
   292 // Waves
   298 // Waves
   293 {$WARNINGS OFF}
   299 {$WARNINGS OFF}
   294 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6) +  25) mod cWaveWidth), cWaterLine + WorldDy - cWaveHeight, 0);
   300 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6) +  25) mod cWaveWidth), cWaterLine + WorldDy - cWaveHeight, 0);
   295 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx - (RealTicks shr 6) +  50) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight div 2), 0);
   301 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx - (RealTicks shr 6) +  50) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight div 2), 0);
   296 for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6) +  75) mod cWaveWidth), cWaterLine + WorldDy     , 0);
   302 //for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6) +  75) mod cWaveWidth), cWaterLine + WorldDy     , 0);
       
   303 
       
   304 
       
   305 // Target
       
   306 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0);
       
   307 
   297 {$WARNINGS ON}
   308 {$WARNINGS ON}
       
   309 SetScale(2.0);
       
   310 
   298 // Turn time
   311 // Turn time
   299 if TurnTimeLeft <> 0 then
   312 if TurnTimeLeft <> 0 then
   300    begin
   313    begin
   301    i:= Succ(Pred(TurnTimeLeft) div 1000);
   314    i:= Succ(Pred(TurnTimeLeft) div 1000);
   302    if i>99 then t:= 112
   315    if i>99 then t:= 112
   303       else if i>9 then t:= 96
   316       else if i>9 then t:= 96
   304                   else t:= 80;
   317                   else t:= 80;
   305    DrawSprite(sprFrame, t, cScreenHeight - 48, 1);
   318    DrawSprite(sprFrame, -cScreenWidth div 2 + t, cScreenHeight - 48, 1);
   306    while i > 0 do
   319    while i > 0 do
   307          begin
   320          begin
   308          dec(t, 32);
   321          dec(t, 32);
   309          DrawSprite(sprBigDigit, t, cScreenHeight - 48, i mod 10);
   322          DrawSprite(sprBigDigit, -cScreenWidth div 2 + t, cScreenHeight - 48, i mod 10);
   310          i:= i div 10
   323          i:= i div 10
   311          end;
   324          end;
   312    DrawSprite(sprFrame, t - 4, cScreenHeight - 48, 0);
   325    DrawSprite(sprFrame, -cScreenWidth div 2 + t - 4, cScreenHeight - 48, 0);
   313    end;
   326    end;
   314 
       
   315 // Target
       
   316 if TargetPoint.X <> NoPointX then DrawSprite(sprTargetP, TargetPoint.X + WorldDx - 16, TargetPoint.Y + WorldDy - 16, 0);
       
   317 
       
   318 //glPopMatrix;
       
   319 
   327 
   320 // Captions
   328 // Captions
   321 i:= 8;
   329 i:= 8;
   322 for grp:= Low(TCapGroup) to High(TCapGroup) do
   330 for grp:= Low(TCapGroup) to High(TCapGroup) do
   323     with Captions[grp] do
   331     with Captions[grp] do
   324          if Tex <> nil then
   332          if Tex <> nil then
   325             begin
   333             begin
   326             DrawCentered(cScreenWidth div 2, i, Tex);
   334             DrawCentered(0, i, Tex);
   327             inc(i, Tex^.h + 2);
   335             inc(i, Tex^.h + 2);
   328             if EndTime <= RealTicks then
   336             if EndTime <= RealTicks then
   329                begin
   337                begin
   330                FreeTexture(Tex);
   338                FreeTexture(Tex);
   331                Tex:= nil;
   339                Tex:= nil;
   335 
   343 
   336 // Teams Healths
   344 // Teams Healths
   337 for t:= 0 to Pred(TeamsCount) do
   345 for t:= 0 to Pred(TeamsCount) do
   338    with TeamsArray[t]^ do
   346    with TeamsArray[t]^ do
   339       begin
   347       begin
   340       DrawTexture(cScreenWidth div 2 - NameTagTex^.w - 3, cScreenHeight + DrawHealthY, NameTagTex);
   348       DrawTexture(- NameTagTex^.w - 3, cScreenHeight + DrawHealthY, NameTagTex);
   341 
   349 
   342       r.x:= 0;
   350       r.x:= 0;
   343       r.y:= 0;
   351       r.y:= 0;
   344       r.w:= 2 + TeamHealthBarWidth;
   352       r.w:= 2 + TeamHealthBarWidth;
   345       r.h:= HealthTex^.h;
   353       r.h:= HealthTex^.h;
   346 
   354 
   347       DrawFromRect(cScreenWidth div 2,
   355       DrawFromRect(0,
   348                         cScreenHeight + DrawHealthY,
   356                         cScreenHeight + DrawHealthY,
   349                         @r, HealthTex);
   357                         @r, HealthTex);
   350 
   358 
   351       inc(r.x, cTeamHealthWidth + 2);
   359       inc(r.x, cTeamHealthWidth + 2);
   352       r.w:= 3;
   360       r.w:= 3;
   353 
   361 
   354       DrawFromRect(cScreenWidth div 2 + TeamHealthBarWidth + 2,
   362       DrawFromRect(TeamHealthBarWidth + 2,
   355                         cScreenHeight + DrawHealthY,
   363                         cScreenHeight + DrawHealthY,
   356                         @r, HealthTex);
   364                         @r, HealthTex);
   357       end;
   365       end;
   358 
   366 
   359 // Lag alert
   367 // Lag alert
   360 if isInLag then DrawSprite(sprLag, 32, 32, (RealTicks shr 7) mod 12);
   368 if isInLag then DrawSprite(sprLag, 32 - cScreenWidth div 2, 32, (RealTicks shr 7) mod 12);
   361 
   369 
   362 // Wind bar
   370 // Wind bar
   363 DrawSprite(sprWindBar, cScreenWidth - 180, cScreenHeight - 30, 0);
   371 DrawSprite(sprWindBar, cScreenWidth div 2 - 180, cScreenHeight - 30, 0);
   364 if WindBarWidth > 0 then
   372 if WindBarWidth > 0 then
   365    begin
   373    begin
   366    {$WARNINGS OFF}
   374    {$WARNINGS OFF}
   367    r.x:= 8 - (RealTicks shr 6) mod 8;
   375    r.x:= 8 - (RealTicks shr 6) mod 8;
   368    {$WARNINGS ON}
   376    {$WARNINGS ON}
   369    r.y:= 0;
   377    r.y:= 0;
   370    r.w:= WindBarWidth;
   378    r.w:= WindBarWidth;
   371    r.h:= 13;
   379    r.h:= 13;
   372    DrawSpriteFromRect(sprWindR, r, cScreenWidth - 103, cScreenHeight - 28, 13, 0);
   380    DrawSpriteFromRect(sprWindR, r, cScreenWidth div 2 - 103, cScreenHeight - 28, 13, 0);
   373    end else
   381    end else
   374  if WindBarWidth < 0 then
   382  if WindBarWidth < 0 then
   375    begin
   383    begin
   376    {$WARNINGS OFF}
   384    {$WARNINGS OFF}
   377    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   385    r.x:= (WindBarWidth + RealTicks shr 6) mod 8;
   378    {$WARNINGS ON}
   386    {$WARNINGS ON}
   379    r.y:= 0;
   387    r.y:= 0;
   380    r.w:= - WindBarWidth;
   388    r.w:= - WindBarWidth;
   381    r.h:= 13;
   389    r.h:= 13;
   382    DrawSpriteFromRect(sprWindL, r, cScreenWidth - 106 + WindBarWidth, cScreenHeight - 28, 13, 0);
   390    DrawSpriteFromRect(sprWindL, r, cScreenWidth div 2 - 106 + WindBarWidth, cScreenHeight - 28, 13, 0);
   383    end;
   391    end;
   384 
   392 
   385 // AmmoMenu
   393 // AmmoMenu
   386 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   394 if (AMxShift < 210) or bShowAmmoMenu then ShowAmmoMenu;
   387 
   395 
   422 {$ENDIF}
   430 {$ENDIF}
   423       fpsTexture:= Surface2Tex(tmpSurface);
   431       fpsTexture:= Surface2Tex(tmpSurface);
   424       SDL_FreeSurface(tmpSurface)
   432       SDL_FreeSurface(tmpSurface)
   425       end;
   433       end;
   426    if fpsTexture <> nil then
   434    if fpsTexture <> nil then
   427       DrawTexture(cScreenWidth - 50, 10, fpsTexture);
   435       DrawTexture(cScreenWidth div 2 - 50, 10, fpsTexture);
   428    end;
   436    end;
   429 
   437 
   430 inc(SoundTimerTicks, Lag);
   438 inc(SoundTimerTicks, Lag);
   431 if SoundTimerTicks >= 50 then
   439 if SoundTimerTicks >= 50 then
   432    begin
   440    begin
   436       str(ChangeVolume(cVolumeDelta), s);
   444       str(ChangeVolume(cVolumeDelta), s);
   437       AddCaption(Format(trmsg[sidVolume], s), $FFFFFF, capgrpVolume)
   445       AddCaption(Format(trmsg[sidVolume], s), $FFFFFF, capgrpVolume)
   438       end
   446       end
   439    end;
   447    end;
   440 
   448 
   441 if GameState = gsConfirm then DrawCentered(cScreenWidth div 2, cScreenHeight div 2, ConfirmTexture);
   449 if GameState = gsConfirm then DrawCentered(0, cScreenHeight div 2, ConfirmTexture);
       
   450 
       
   451 SetScale(1.5);
   442 
   452 
   443 glDisable(GL_TEXTURE_2D);
   453 glDisable(GL_TEXTURE_2D);
   444 glDisable(GL_BLEND)
   454 glDisable(GL_BLEND)
   445 end;
   455 end;
   446 
   456 
   458 	end;
   468 	end;
   459 end;
   469 end;
   460 
   470 
   461 procedure MoveCamera;
   471 procedure MoveCamera;
   462 const PrevSentPointTime: LongWord = 0;
   472 const PrevSentPointTime: LongWord = 0;
   463 var EdgesDist: LongInt;
   473 var EdgesDist, cw: LongInt;
   464 begin
   474 begin
       
   475 cw:= round(cScreenWidth / cScaleFactor);
       
   476 
       
   477 
   465 if (not (CurrentTeam^.ExtDriven and isCursorVisible))
   478 if (not (CurrentTeam^.ExtDriven and isCursorVisible))
   466 	and cHasFocus then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   479 	and cHasFocus then
       
   480 	begin
       
   481 	SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
       
   482 //	CursorPoint.X:= round((CursorPoint.X - cScreenWidth / 2) * 2 / cScaleFactor);
       
   483 //	CursorPoint.Y:= round(CursorPoint.Y * 2 / cScaleFactor);
       
   484 	end;
   467 
   485 
   468 if (FollowGear <> nil) and (not isCursorVisible) then
   486 if (FollowGear <> nil) and (not isCursorVisible) then
   469 	if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   487 	if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   470 		begin
   488 		begin
   471 		FollowGear:= nil;
   489 		FollowGear:= nil;
   502 
   520 
   503 if isCursorVisible or (FollowGear <> nil) then
   521 if isCursorVisible or (FollowGear <> nil) then
   504    begin
   522    begin
   505    if isCursorVisible then EdgesDist:= cCursorEdgesDist
   523    if isCursorVisible then EdgesDist:= cCursorEdgesDist
   506                       else EdgesDist:= cGearScrEdgesDist;
   524                       else EdgesDist:= cGearScrEdgesDist;
   507    if CursorPoint.X < EdgesDist then
   525    if CursorPoint.X < - cw + EdgesDist then
   508          begin
   526          begin
   509          WorldDx:= WorldDx - CursorPoint.X + EdgesDist;
   527          WorldDx:= WorldDx - CursorPoint.X - cw + EdgesDist;
   510          CursorPoint.X:= EdgesDist
   528          CursorPoint.X:= EdgesDist
   511          end else
   529          end else
   512       if CursorPoint.X > cScreenWidth - EdgesDist then
   530       if CursorPoint.X > cw - EdgesDist then
   513          begin
   531          begin
   514          WorldDx:= WorldDx - CursorPoint.X + cScreenWidth - EdgesDist;
   532          WorldDx:= WorldDx - CursorPoint.X + cw - EdgesDist;
   515          CursorPoint.X:= cScreenWidth - EdgesDist
   533          CursorPoint.X:= cScreenWidth - EdgesDist
   516          end;
   534          end;
   517       if CursorPoint.Y < EdgesDist then
   535       if CursorPoint.Y < EdgesDist then
   518          begin
   536          begin
   519          WorldDy:= WorldDy - CursorPoint.Y + EdgesDist;
   537          WorldDy:= WorldDy - CursorPoint.Y + EdgesDist;
   520          CursorPoint.Y:= EdgesDist
   538          CursorPoint.Y:= EdgesDist
   521          end else
   539          end else
   522       if CursorPoint.Y > cScreenHeight - EdgesDist then
   540       if CursorPoint.Y > cScreenHeight - EdgesDist then
   523          begin
   541          begin
   524          WorldDy:= WorldDy - CursorPoint.Y + cScreenHeight - EdgesDist;
   542          WorldDy:= WorldDy - CursorPoint.Y + round(cScreenHeight * 2 / cScaleFactor) - EdgesDist;
   525          CursorPoint.Y:= cScreenHeight - EdgesDist
   543          CursorPoint.Y:= cScreenHeight - EdgesDist
   526          end;
   544          end;
   527    end else
   545    end else
   528    if cHasFocus then
   546    if cHasFocus then
   529       begin
   547       begin
   535 
   553 
   536 if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
   554 if cHasFocus then SDL_WarpMouse(CursorPoint.X, CursorPoint.Y);
   537 prevPoint:= CursorPoint;
   555 prevPoint:= CursorPoint;
   538 if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater;
   556 if WorldDy < cScreenHeight - cWaterLine - cVisibleWater then WorldDy:= cScreenHeight - cWaterLine - cVisibleWater;
   539 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
   557 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
   540 if WorldDx < -LAND_WIDTH then WorldDx:= -LAND_WIDTH;
   558 if WorldDx < -round(LAND_WIDTH * 2 / cScaleFactor) then WorldDx:= -round(LAND_WIDTH * 2 / cScaleFactor);
   541 if WorldDx > cScreenWidth then WorldDx:= cScreenWidth;
   559 if WorldDx > cw then WorldDx:= cw;
   542 end;
   560 end;
   543 
   561 
   544 initialization
   562 initialization
   545 FillChar(Captions, sizeof(Captions), 0)
   563 FillChar(Captions, sizeof(Captions), 0)
   546 
   564