Page 1 of 2

Tile Matrix

PostPosted: Nov 13, 2004 @ 12:17am
by mmtbb
What we need is a tile matrix function where an image can hold the appropriate tile frames and they can be quickly rendered by passing a matrix or array to a TileMap() (or whatever you want to call it) function

Ex:

[0,0,0,0,1,1,1,1,1,0,0,0
0,0,0,0,1,0,0,0,1,0,0,0
0,0,0,0,1,0,0,0,1,0,0,0
0,0,0,0,1,1,1,1,1,0,0,0]

you get the idea.

PostPosted: Nov 13, 2004 @ 12:48am
by kornalius

PostPosted: Nov 13, 2004 @ 1:05am
by mmtbb
does this take a lot of fps to render constantly with so many sprites? Also with this would you be able to have certain tiles cause collision?

PostPosted: Nov 13, 2004 @ 1:47am
by sponge

PostPosted: Nov 13, 2004 @ 3:45am
by kornalius

PostPosted: Nov 13, 2004 @ 4:09am
by mmtbb

PostPosted: Nov 13, 2004 @ 4:32am
by kornalius
The @ converts an address into actual data in a variable.

Dim(d$, 10);
d$[0] = "THIS IS A STRING";

In PPL a lot of the string data is stored as an address value.

ShowMessage(d$[0]);

Will not print "THIS IS A STRING" but it's address value.

ShowMessage(@d$[0]);

Will convert the address value into it's actual content and print "THIS IS A STRING".

In the case of a matrix:

a$ = [10, 10];

a$ points to a memory location that holds the matrix elements 10, 10.

ShowMessage(a$);

Will print the address.

a$ = [[10,10]];

a$ still points to a memory location. But the first element of the matrix also point to another matrix (called a sub-matrix) that holds elements 10,10.

ShowMessage(a$[0]);

Will print the address pointed by element 0 of the matrix a$.

In order to get the actual data and process it, you need to transfer from an address to data.

ShowMessage(@a$[0][1]);

Converts a$[0] to data and then print matrix element of sub-matrix, which is 10.

The matrix is stored like this:

a$ = [10, 20, [30, 40]];

a$ : 10, 20, [address-1]
address-1 : 30, 40

-----------------------------------------------------

A sprite is just a set of values (including a surface pointer) for the engine to use. A sprite is not a surface in itself.

PostPosted: Nov 13, 2004 @ 6:16am
by mmtbb
tune in next week when we discuss chapter 14 of the latest release from Microsoft Press, "PPL, the early years" :wink:

Thanks for the explaination. I understood everything up to the part where a$=[[10,10]]. here is where you lost me. Is a matrix like an array? I don't understand the double brackets

So does a$[0][1,1]="wew" work?

PostPosted: Nov 13, 2004 @ 2:59pm
by kornalius

PostPosted: Nov 13, 2004 @ 3:31pm
by mmtbb
Ok, this whole time I have been confusing arrays with matrices.
Let's see if I understand right.

I create the following matrix:

a$ = [0,1,2,"You ",4,"Rock! ",["Big ","Time"]];

Now, if I would access these these are the values I would get:

a$[1] equals the number 1,
@a$[3] equals the string "You ",
a$[4] equals the number 4,
@a$[7][1] equals the string "Time ".

Is this correct?

PostPosted: Nov 13, 2004 @ 7:04pm
by kornalius
Correct, except:

@a$[7][1] equals the string "Time ".

should be:

@a$[6][1] equals the string "Time ".

PostPosted: Nov 13, 2004 @ 7:15pm
by sponge

PostPosted: Nov 13, 2004 @ 7:49pm
by mmtbb
sponge, I would like that. you can PM me. Thanks

kornalius, if this is the case, it seems that an array would serve better for a map because it can have, but more importantly be called be dimension

ex:
Sprite located at a$[1,1] = 3

Is there an advantage for making map grids that a matrix would have over this?

PostPosted: Nov 14, 2004 @ 5:49am
by kornalius

PostPosted: Nov 14, 2004 @ 7:32am
by mmtbb
how I have done maps in the past is:

dim(fakemap$,6);
dim(map$,6,6);

fakemap$[0] = "0,0,0,1,1,1";
fakemap$[1] = "0,0,0,1,0,1";
fakemap$[2] = "0,0,0,1,0,1";
fakemap$[3] = "0,0,0,1,0,1";
fakemap$[4] = "0,0,0,1,1,1";
fakemap$[5] = "0,0,0,0,0,0";

Then I use a split function to seperate the strings delimited by a comma and fill up the real map$ elements by processing with 2 FOR loops. This has worked fantastic for me in the past.