I'm experimenting with my own little mining game, I figured i'd make an array/grid, and at the moment am simply trying to throw some random colouring into the grid. The following code creates a small grid, and using for loops and rnd() it should make certain blocks a different colour from the others.
The point - essentially- will be to have different soil textures every now and then to avoid the monotony of a single texture!. (im using 'color object' instead of 'texture object' here for more clarity in the beta testing stage)
the variable 'flipidi' or whatever, just refers to the reference of the array. It seemed as good a name as any!
Anyway: The bug is a runtime error, it creates a coloured 'line'(so to speak) along the x axis of the boxes, instead of individual boxes. Halp plz!
`random
randomize timer()
`resolution
sync on : sync rate 0
if check display mode(1024,768,32)=1
set display mode 1024,768,32
endif
`camera
make camera 1
set current camera 1
`vars
tankSize = 10
flippidi = 1
`array
`it is 11 across and 11 down
dim grid(10,10) as boolean `note this boolean designation will cause bugs later on, but for now lets save some mem
`Puts either a 1 or 0 in each spot just for varying the dirt texture
for x= 1 to tankSize
for y= 1 to tankSize
grid(x,y) = rnd(1)
next y
next x
`Draws a brown box if the grid spot is 1
for x=1 to tankSize step 1
for y=1 to tankSize step 1
//if grid(x,y)=1
make object box flippidi, (x-1),(y-1), 10
//color object flippidi, RGB(255,0,0)
if grid(x,y)=1
color object flippidi, RGB(255,0,0)
endif
inc flippidi, 1
//endif
next y
next x
do
objInQuestion = pick object(mousex(),mousey(),1,tankSize)
text 0,100,str$(objInQuestion)
`Updates the screen
sync : sync
loop