Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 two subsctipts? eg. q(x)(y)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Saad85




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sun Dec 11, 2005 6:12 pm   Post subject: (No 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'
[Gandalf]




PostPosted: Sun Dec 11, 2005 6:22 pm   Post subject: (No 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
Saad85




PostPosted: Sun Dec 11, 2005 6:23 pm   Post subject: (No subject)

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




PostPosted: Sun Dec 11, 2005 6:35 pm   Post subject: (No 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)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: