Array syntax

BlitzPlus Forums/BlitzPlus Beginners Area/Array syntax

Hello peeps, I'm new here and to programming pretty much, having only done some basic lingo stuff, I'm trying to get to grips with "proper" code :)

Ok, so I've got a question about arrays. I have a 3 dimensional array and I want to define the array in the shape of a 2D grid so I can see what I'm doing better. I'd heard from a friend that you can do this, so I've started thus:

Dim Grid(12,06,3)


grid = (1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1
1,1,1,1,1,1,1,1,1,1,1,1)

This doesn't appear to work, I get an error saying I didn't put an end bracket on the first line. So what I guess I'm asking is, can I do this?

Cheers guys! :)

no..

use for-loop(s) to fill an array..

think thats a c command, but it's beena long time since i used c.

try something like this, printed it to screen to show you.

comment the 'text' statement and uncomment the 'if statement for a different view.

Graphics 800, 600, 16, 2

Dim test(20, 20)

; load data into array
Restore testdata ; use restore to make sure the program reads the correct data
For y = 1 To 10
	For x = 1 To 10
		Read d
		test(x, y) = d
	Next
Next

; plot info to screeen as an example
For y = 1 To 10
	For x = 1 To 10
		Text x * 15, y * 15, Str test(x, y)
                ;If test (x, y) = 1 Then Rect x * 15, y * 15, 15, 15, True
	Next
Next

WaitKey

.testdata
Data 1,1,1,1,1,1,1,1,1,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,0,1,1,1,1,1,1,0,1
Data 1,0,1,1,1,1,1,1,0,1
Data 1,0,0,0,0,0,1,1,0,1
Data 1,0,1,1,0,0,0,0,0,1
Data 1,0,1,1,1,1,1,1,0,1
Data 1,0,1,1,1,1,1,1,0,1
Data 1,0,0,0,0,0,0,0,0,1
Data 1,1,1,1,1,1,1,1,1,1



Hello, thanks for the response. That all seems to make sense, so thankyou very much.

One hurdle down, a thousand more left :)

Sorry, one more thing.

Is this an efficient way of displaying graphics on screen? I'm planning to be doing this with alot of sprites; potentially over 100. Is this practical, and is there any way of optomizing the code for drawing the sprites so it speeds things up. I've done a quick test and I'm currently running at around 76 fps at 1024x768 with only a few 48x48 pixels wide sprites on screen; how will it handle with over 100?

thanks in advance

easiest way: draw images of those sprites, with 'DrawImage'

regarding performance: trial&error will tell you.