Computer Science Canada

two subsctipts? eg. q(x)(y)

Author:  Saad85 [ Sun Dec 11, 2005 5:59 pm ]
Post subject:  two subsctipts? eg. q(x)(y)

yea, im sure its not possible but is there any way to mimmic the effect? because for the racing game i'm working on, i need a collision system(obviously) but the map is really big. 1000x1500, actually. i COULD split the usable path and non-usable part and then use whatdotcolor collision but that takesway too much processing power and makes it slow. i decided that it would be way easier if i drew the path once, and used whatdotcolor to declare whether collision=true or false. the thing is.. i cant figure out a way to assign an x and y value to each of the pixels. could anyone help me out? if im just being retarded then plz tell me a better way to do it.

Author:  Cervantes [ Sun Dec 11, 2005 6:12 pm ]
Post subject: 

Do you know about 2D arrays?

code:

var map : array 1 .. 1000, 1 .. 1500 of int


The only time I've ever seen something like q (x)(y) is when I have an array of strings:
code:

var q : array 1 .. 2 of string := init ("compsci", ".ca")
put q (1) (3)  %puts 'm'

Author:  [Gandalf] [ Sun Dec 11, 2005 6:22 pm ]
Post subject: 

You might be talking about arrays, in which case you need a 2d array. Look up multidimensional arrays in the tutorials section.

code:
var pixel : array 1 .. 10, 1 .. 10 of int
pixel (1, 1) := brightblue


If not, you are most likely talking about records:

code:
var pixel : array 1 .. 100 of
    record
        x, y : int
    end record

pixel (1).x := 1
pixel (1).y := 1

Author:  Saad85 [ Sun Dec 11, 2005 6:23 pm ]
Post subject: 

thx, i had completely forgotten about those. you are now my god

Author:  Tony [ Sun Dec 11, 2005 6:35 pm ]
Post subject: 

Cervantes wrote:
The only time I've ever seen something like q (x)(y) is when I have an array of strings

Actually if you declear an array of arrays (2D array, but decleared as)
code:

var arr:array 1..2 of array 1..2 of int

Then you'd have to access that as (1)(2), instead of (1,2)


: