Some semi-random thoughts on terrain generation
Btw this is the (Delphi) code used to generate one such line:
procedure SubdivideLine(bmp: TBitmap; pt1, pt2: TPoint; Color: TColor);
var
	MidPt: TPoint;
	dx, dy: integer;
begin
	MidPt.X := (pt1.X + pt2.X) div 2;
	MidPt.Y := (pt1.Y + pt2.Y) div 2;
	dx := pt2.x - pt1.x;
	dy := pt2.Y - pt1.Y;
	MidPt.X := MidPt.x + dy div 5;
	MidPt.y := MidPt.Y - dx div 5;
	bmp.Canvas.Pixels[MidPt.x, MidPt.Y] := Color;
	if ((abs(dx) > 2) or (abs(dy) > 2)) then
	begin
		if (((random(255)) mod 2) = 0) then
			SubdivideLine(bmp, pt1, MidPt, Color)
		else
			SubdivideLine(bmp, MidPt, pt1, Color);
		SubdivideLine(bmp, pt2, MidPt, Color);
	end
end;

SubdivideLine(bmp, Point(100, 150), Point(800, 150), $ff);
Reply
Thanks given by:


Messages In This Thread
RE: Some semi-random thoughts on terrain generation - by xoft - 07-25-2014, 11:31 PM



Users browsing this thread: 29 Guest(s)