TGC Codebase Backup



Horizontal and Vertical Matrix Gradient Tiling by OSX Using Happy Dude

25th Jan 2004 17:05
Summary

This will create smooth horizontal and vertical slopes on matricies.



Description

Creates slopes of a given angle either horizontally or vertically.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function gradYTiles(mat as DWORD,x as DWORD,startY as DWORD,_
						 endY as DWORD,start# as float,incA# as float)
local l as DWORD
local st as integer
local d as integer

	st=startY-endY
	if st<0 then d=1 else d=-1
	for l=startY to endY step d
		set matrix height mat,x,l,start#
		set matrix height mat,x+1,l,start#
		inc start#,incA#
		set matrix height mat,x,l+d,start#
		set matrix height mat,x+1,l+d,start#
		inc start#,incA#
	next l
	update matrix mat
endfunction

function gradXTiles(mat as DWORD,y as DWORD,startX as DWORD,_
						 endX as DWORD,start# as float,incA# as float)
local l as DWORD
local st as integer
local d as integer

	st=startX-endX
	if st<0 then d=1 else d=-1
	for l=startX to endX step d
		set matrix height mat,l,y,start#
		set matrix height mat,l,y+1,start#
		inc start#,incA#
		set matrix height mat,l+1,y,start#
		set matrix height mat,l+1,y+1,start#
		inc start#,incA#
	next l
	update matrix mat
endfunction