hedgewars/uWorld.pas
changeset 2426 9d674c5c828d
parent 2413 d921d13a8546
child 2428 6800f8aa0184
equal deleted inserted replaced
2425:a4af95e6382c 2426:9d674c5c828d
   272 		i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2),
   272 		i * cWaveWidth + ((WorldDx + (RealTicks shr 6) * Dir + dX) mod cWaveWidth) - (cScreenWidth div 2),
   273 		cWaterLine + WorldDy + dY,
   273 		cWaterLine + WorldDy + dY,
   274 		0)}
   274 		0)}
   275 end;
   275 end;
   276 
   276 
       
   277 procedure DrawRepeated(spr, sprL, sprR: TSprite; Shift: LongInt);
       
   278 var i, w, sw: LongInt;
       
   279 begin
       
   280 sw:= round(cScreenWidth / cScaleFactor);
       
   281 if (SpritesData[sprL].Texture = nil) or (SpritesData[sprR].Texture = nil) then
       
   282 	begin
       
   283 	w:= SpritesData[spr].Width;
       
   284 	i:= Shift mod w;
       
   285 	if i > 0 then dec(i, w);
       
   286 	dec(i, w * (sw div w + 1));
       
   287 	repeat
       
   288 		DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
       
   289 		inc(i, w)
       
   290 	until i > sw
       
   291 	end else
       
   292 	begin
       
   293 	w:= SpritesData[spr].Width;
       
   294 	dec(Shift, w div 2);
       
   295 	DrawSprite(spr, Shift, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
       
   296 
       
   297 	sw:= round(cScreenWidth / cScaleFactor);
       
   298 	
       
   299 	i:= Shift - SpritesData[sprL].Width;
       
   300 	while i >= -sw - SpritesData[sprL].Width do
       
   301 		begin
       
   302 		DrawSprite(sprL, i, WorldDy + LAND_HEIGHT - SpritesData[sprL].Height, 0);
       
   303 		dec(i, SpritesData[sprL].Width);
       
   304 		end;
       
   305 		
       
   306 	i:= Shift + w;
       
   307 	while i <= sw do
       
   308 		begin
       
   309 		DrawSprite(sprR, i, WorldDy + LAND_HEIGHT - SpritesData[sprR].Height, 0);
       
   310 		inc(i, SpritesData[sprR].Width)
       
   311 		end
       
   312 	end
       
   313 end;
       
   314 
       
   315 
   277 procedure DrawWorld(Lag: LongInt);
   316 procedure DrawWorld(Lag: LongInt);
   278 var i, t: LongInt;
   317 var i, t: LongInt;
   279     r: TSDL_Rect;
   318     r: TSDL_Rect;
   280     tdx, tdy: Double;
   319     tdx, tdy: Double;
   281     grp: TCapGroup;
   320     grp: TCapGroup;
   282     s: string[15];
   321     s: string[15];
   283 
       
   284     procedure DrawRepeated(spr: TSprite; Shift: LongInt);
       
   285     var i, w, sw: LongInt;
       
   286     begin
       
   287     sw:= round(cScreenWidth / cScaleFactor);
       
   288     w:= SpritesData[spr].Width;
       
   289     i:= Shift mod w;
       
   290     if i > 0 then dec(i, w);
       
   291     dec(i, w * (sw div w + 1));
       
   292     repeat
       
   293       DrawSprite(spr, i, WorldDy + LAND_HEIGHT - SpritesData[spr].Height, 0);
       
   294       inc(i, w)
       
   295     until i > sw
       
   296     end;
       
   297 
       
   298 begin
   322 begin
   299 if ZoomValue < zoom then
   323 if ZoomValue < zoom then
   300 	begin
   324 	begin
   301 	zoom:= zoom - 0.002 * Lag;
   325 	zoom:= zoom - 0.002 * Lag;
   302 	if ZoomValue > zoom then zoom:= ZoomValue
   326 	if ZoomValue > zoom then zoom:= ZoomValue
   317 if not isPaused then MoveCamera;
   341 if not isPaused then MoveCamera;
   318 
   342 
   319 if not cReducedQuality then
   343 if not cReducedQuality then
   320     begin
   344     begin
   321     // background
   345     // background
   322     DrawRepeated(sprSky, WorldDx * 3 div 8);
   346     DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8);
   323     DrawRepeated(sprHorizont, WorldDx * 3 div 5);
   347     DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5);
   324 
   348 
   325     DrawVisualGears(0);
   349     DrawVisualGears(0);
   326     end;
   350     end;
   327 
   351 
   328 // Waves
   352 // Waves
   625 
   649 
   626 prevPoint:= CursorPoint;
   650 prevPoint:= CursorPoint;
   627 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
   651 if cHasFocus then SDL_WarpMouse(CursorPoint.X + cScreenWidth div 2, cScreenHeight - CursorPoint.Y);
   628 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
   652 if WorldDy > LAND_HEIGHT + 1024 then WorldDy:= LAND_HEIGHT + 1024;
   629 if WorldDy < wdy then WorldDy:= wdy;
   653 if WorldDy < wdy then WorldDy:= wdy;
   630 if WorldDx < -round(LAND_WIDTH * 2 / cScaleFactor) then WorldDx:= -round(LAND_WIDTH * 2 / cScaleFactor);
   654 if WorldDx < - LAND_WIDTH - 1024 then WorldDx:= - LAND_WIDTH - 1024;
   631 if WorldDx > cw then WorldDx:= cw;
   655 if WorldDx > 1024 then WorldDx:= 1024;
   632 end;
   656 end;
   633 
   657 
   634 initialization
   658 initialization
   635 FillChar(Captions, sizeof(Captions), 0)
   659 FillChar(Captions, sizeof(Captions), 0)
   636 
   660