TGC Codebase Backup



Dynamic Box Function by sneaky smith12

25th Jan 2007 17:02
Summary

Allows you to set up boxes with a random color etc with the following syntax: MakeRandomizedBoxes(AmountOfBoxes,XStart,YStart,XEnd,YEnd)



Description

Allows you to set up dynamic(ability to change) boxes with a random color etc with the following syntax: MakeRandomizedBoxes(AmountOfBoxes,XStart,YStart,XEnd,YEnd)

This can be called several times over, and can be used to create a static effect such as when your TV loses connection.



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    Global White
White = RGB(255,255,255)
Global Gray
Gray = RGB(128,128,128)
Global Black
Black = RGB(0,0,0)
Do
MakeRandomizedBoxes(200,0,400,600,Screen Height())
Sleep 50
Loop

Function MakeRandomizedBoxes(AmountOfBoxes,Xstart,Ystart,Xend,Yend)

`Box Width
BoxSizeX = (Xend / AmountOfBoxes)
`Box Hieght
BoxSizeY = (Yend / AmountOfBoxes)

For Column = 1 to AmountOfBoxes
    For Row = 1 to AmountOfBoxes

`Randomized Color Of Box
        Color = (RND(3)+1)
            If color = 1 then Ink Black,Black
            If color = 2 then Ink White,Black
            If color = 3 then Ink Gray,Black
`Actual Box
        Box (Xstart+XCurrent),(Ystart+YCurrent),(XCurrent+BoxSizeX+Xstart),(YCurrent+BoxSizeY+Ystart)
`Set X Cordinet
        XCurrent = XCurrent + BoxSizeX
    Next Row
YCurrent = YCurrent + BoxSizeY
XCurrent = 0
Next Column

EndFunction