Re: A85: Matrices


[Prev][Next][Index][Thread]

Re: A85: Matrices



John Koch wrote:
> 
> What is the ebst way to do matrices!  I have an 8X8 grid draw and I have
> 4 different sprites.  At the bottom of the game I have all of the
> sprites and the board in .db's.  But how can I read the board and move
> to the left and up and down and so forth.  Also, how do I then let it
> see which sprite should be there.  Can someone help me, or write a
> routine and explains how it works, thanks
> 
> JOhn

a common problem, the maxtrix is two dimensions, but your data is one
dimension. easy solution

result = (y-1) * max_x + X

so basically if you had an array like this:


1 2 3 4 5 6 7 8
9 0 1 2 3 4 5 6
7 8 9 0 1 2 3 4
5 6 7 8 9 0 1 2


(aka .db 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2)

and you wanted to find the item in (2,3) it would be the (3-1) * 8 + 2
item (the 18th .db)


Follow-Ups: References: