16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 *) |
17 *) |
18 |
18 |
19 unit uLand; |
19 unit uLand; |
20 interface |
20 interface |
21 uses SDLh, uLandTemplates, uFloat, |
21 uses SDLh, uLandTemplates, uFloat, |
22 {$IFDEF GLES11} |
22 {$IFDEF GLES11} |
23 gles11, |
23 gles11, |
24 {$ELSE} |
24 {$ELSE} |
25 GL, |
25 GL, |
26 {$ENDIF} |
26 {$ENDIF} |
331 for x:= 0 to LAND_WIDTH - 1 do |
331 for x:= 0 to LAND_WIDTH - 1 do |
332 begin |
332 begin |
333 yd:= LAND_HEIGHT - 1; |
333 yd:= LAND_HEIGHT - 1; |
334 repeat |
334 repeat |
335 while (yd > 0) and (Land[yd, x] = 0) do dec(yd); |
335 while (yd > 0) and (Land[yd, x] = 0) do dec(yd); |
336 |
336 |
337 if (yd < 0) then yd:= 0; |
337 if (yd < 0) then yd:= 0; |
338 |
338 |
339 while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd); |
339 while (yd < LAND_HEIGHT) and (Land[yd, x] <> 0) do inc(yd); |
340 dec(yd); |
340 dec(yd); |
341 yu:= yd; |
341 yu:= yd; |
342 |
342 |
343 while (yu > 0 ) and (Land[yu, x] <> 0) do dec(yu); |
343 while (yu > 0 ) and (Land[yu, x] <> 0) do dec(yu); |
344 while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); |
344 while (yu < yd ) and (Land[yu, x] = 0) do inc(yu); |
345 |
345 |
346 if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
346 if (yd < LAND_HEIGHT - 1) and ((yd - yu) >= 16) then |
347 begin |
347 begin |
348 rr.x:= x; |
348 rr.x:= x; |
349 rr.y:= yd - 15; |
349 rr.y:= yd - 15; |
350 r.x:= x mod tmpsurf^.w; |
350 r.x:= x mod tmpsurf^.w; |
391 for i:= 0 to pred(FillPointsCount) do |
391 for i:= 0 to pred(FillPointsCount) do |
392 FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x; |
392 FillPoints^[i].x:= LAND_WIDTH - 1 - FillPoints^[i].x; |
393 end; |
393 end; |
394 |
394 |
395 (* Experiment in making this option more useful |
395 (* Experiment in making this option more useful |
396 if ((not isNegative) and (cTemplateFilter = 4)) or |
396 if ((not isNegative) and (cTemplateFilter = 4)) or |
397 (canFlip and (getrandom(2) = 0)) then |
397 (canFlip and (getrandom(2) = 0)) then |
398 begin |
398 begin |
399 for i:= 0 to pred(BasePointsCount) do |
399 for i:= 0 to pred(BasePointsCount) do |
400 begin |
400 begin |
401 pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y + (LAND_HEIGHT - TemplateHeight) * 2; |
401 pa.ar[i].y:= LAND_HEIGHT - 1 - pa.ar[i].y + (LAND_HEIGHT - TemplateHeight) * 2; |
407 FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y + (LAND_HEIGHT - TemplateHeight) * 2; |
407 FillPoints^[i].y:= LAND_HEIGHT - 1 - FillPoints^[i].y + (LAND_HEIGHT - TemplateHeight) * 2; |
408 if FillPoints^[i].y > LAND_HEIGHT - 1 then |
408 if FillPoints^[i].y > LAND_HEIGHT - 1 then |
409 FillPoints^[i].y:= LAND_HEIGHT - 1; |
409 FillPoints^[i].y:= LAND_HEIGHT - 1; |
410 end; |
410 end; |
411 end; |
411 end; |
412 end |
412 end |
413 *) |
413 *) |
414 // template recycling. Pull these off the floor a bit |
414 // template recycling. Pull these off the floor a bit |
415 if (not isNegative) and (cTemplateFilter = 4) then |
415 if (not isNegative) and (cTemplateFilter = 4) then |
416 begin |
416 begin |
417 for i:= 0 to pred(BasePointsCount) do |
417 for i:= 0 to pred(BasePointsCount) do |
550 leftX:= ((LAND_WIDTH - playWidth) div 2); |
550 leftX:= ((LAND_WIDTH - playWidth) div 2); |
551 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
551 rightX:= (playWidth + ((LAND_WIDTH - playWidth) div 2)) - 1; |
552 topY:= LAND_HEIGHT - playHeight; |
552 topY:= LAND_HEIGHT - playHeight; |
553 |
553 |
554 // force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
554 // force to only cavern even if a cavern map is invertable if cTemplateFilter = 4 ? |
555 if (cTemplateFilter = 4) or |
555 if (cTemplateFilter = 4) or |
556 (Template.canInvert and (getrandom(2) = 0)) or |
556 (Template.canInvert and (getrandom(2) = 0)) or |
557 (not Template.canInvert and Template.isNegative) then |
557 (not Template.canInvert and Template.isNegative) then |
558 begin |
558 begin |
559 hasBorder:= true; |
559 hasBorder:= true; |
560 for y:= 0 to LAND_HEIGHT - 1 do |
560 for y:= 0 to LAND_HEIGHT - 1 do |
561 for x:= 0 to LAND_WIDTH - 1 do |
561 for x:= 0 to LAND_WIDTH - 1 do |
562 if (y < topY) or (x < leftX) or (x > rightX) then |
562 if (y < topY) or (x < leftX) or (x > rightX) then |
608 p:= Surface^.pixels; |
608 p:= Surface^.pixels; |
609 for y:= 0 to LAND_HEIGHT - 1 do |
609 for y:= 0 to LAND_HEIGHT - 1 do |
610 begin |
610 begin |
611 for x:= 0 to LAND_WIDTH - 1 do |
611 for x:= 0 to LAND_WIDTH - 1 do |
612 if Land[y, x] <> 0 then LandPixels[y, x]:= p^[x] or $FF000000; |
612 if Land[y, x] <> 0 then LandPixels[y, x]:= p^[x] or $FF000000; |
613 |
613 |
614 p:= @(p^[Surface^.pitch div 4]); |
614 p:= @(p^[Surface^.pitch div 4]); |
615 end; |
615 end; |
616 |
616 |
617 if SDL_MustLock(Surface) then |
617 if SDL_MustLock(Surface) then |
618 SDL_UnlockSurface(Surface); |
618 SDL_UnlockSurface(Surface); |
677 begin |
677 begin |
678 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
678 cpX:= (LAND_WIDTH - tmpsurf^.w) div 2; |
679 cpY:= LAND_HEIGHT - tmpsurf^.h; |
679 cpY:= LAND_HEIGHT - tmpsurf^.h; |
680 if SDL_MustLock(tmpsurf) then |
680 if SDL_MustLock(tmpsurf) then |
681 SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
681 SDLTry(SDL_LockSurface(tmpsurf) >= 0, true); |
682 |
682 |
683 p:= tmpsurf^.pixels; |
683 p:= tmpsurf^.pixels; |
684 for y:= 0 to Pred(tmpsurf^.h) do |
684 for y:= 0 to Pred(tmpsurf^.h) do |
685 begin |
685 begin |
686 for x:= 0 to Pred(tmpsurf^.w) do |
686 for x:= 0 to Pred(tmpsurf^.w) do |
687 begin |
687 begin |
688 if (($FF000000 and p^[x]) = 0) then // Tiy was having trouble generating transparent black |
688 if (($FF000000 and p^[x]) = 0) then // Tiy was having trouble generating transparent black |
689 Land[cpY + y, cpX + x]:= 0 |
689 Land[cpY + y, cpX + x]:= 0 |
690 else if p^[x] = $FF0000FF then |
690 else if p^[x] = $FF0000FF then |
691 Land[cpY + y, cpX + x]:= COLOR_INDESTRUCTIBLE |
691 Land[cpY + y, cpX + x]:= COLOR_INDESTRUCTIBLE |
692 else if p^[x] = $FFFFFFFF then |
692 else if p^[x] = $FFFFFFFF then |
693 Land[cpY + y, cpX + x]:= COLOR_LAND; |
693 Land[cpY + y, cpX + x]:= COLOR_LAND; |
694 |
694 |
695 end; |
695 end; |
696 p:= @(p^[tmpsurf^.pitch div 4]); |
696 p:= @(p^[tmpsurf^.pitch div 4]); |
697 end; |
697 end; |
698 |
698 |
699 if SDL_MustLock(tmpsurf) then |
699 if SDL_MustLock(tmpsurf) then |
700 SDL_UnlockSurface(tmpsurf); |
700 SDL_UnlockSurface(tmpsurf); |
701 SDL_FreeSurface(tmpsurf); |
701 SDL_FreeSurface(tmpsurf); |
702 end; |
702 end; |
703 end; |
703 end; |