TGC Codebase Backup



Make Pyramid by Hacktank

28th Jun 2009 4:29
Summary

Makes a pyramid of cubes



Description

This function makes a pyramid of cubes. Paramiters:
x# as float : starting x of the pyramid
y# as float : starting y of the pyramid
z# as float : starting z of the pyramid
perx as integer : rows of cubes on the x axis
pery as integer : columbs of cubes on the y axis
cubesize# as float : size of the cubes

example useage: makepyramid(0,1,0,10,10,1)

REQUIRES MATRIX DLLS FOR FIND FREE OBJECT



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    function makepyramid(x# as float,y# as float,z# as float,perx as integer,pery as integer,cubesize# as float)
   for teir = 1 to max(perx,pery)
      for i = 1 to pery
           for ii = 1 to max(perx,pery)
            if (teir < i+1) and (teir < ii+1)
               id = find free object()
               if teir > 1 then xmod# = i*(cubesize#/2) else xmod# = 0
               make object cube id,cubesize#
               position object id,x#+(i*(cubesize#)-(teir*(cubesize#/2))),y#-(cubesize#/2)+(cubesize#*teir)-0.5,z#+(ii*cubesize#)-(teir*(cubesize#/2))
               set object id,1,0,1
               color object id,rgb(rnd(255),rnd(255),rnd(255))
               endif
            next ii
         next i
      next teir
   endfunction