Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
triangular array (or something)
#1
how would i set up an that is a triangle and each length of each side is 9? (the spaces can be there i need them for collision detection)
so it's a 9x9 array with a triangle with each edge beeing 9 long.
thanks
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#2
Quote:how would i set up an that is a triangle and each length of each side is 9? (the spaces can be there i need them for collision detection)
so it's a 9x9 array with a triangle with each edge beeing 9 long.
thanks

There's no 'ragged' arrays or anything built into QB... you either have to use half of a square array, or else have an array with the correct number of elements and your own addressing system.
Reply
#3
excuse me? it has to be an eqalateral (sp?) triangle. =/
and i have no clue where to start.
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#4
Quote:excuse me? it has to be an eqalateral (sp?) triangle. =/
and i have no clue where to start.

Well, there's a number of different ways you could tackle the problem -- it really depends what the purpose is. Are the elements addressed by row and inset, or something else? Does each element need to 'know' what the adjacent 6 are? Details, details.


Basically, I'd say if you need a 9x9 triangular array, define a linear array with 9+8+7+6+5+4+3+2+1=45 elements, indexed 0..44. Then just have a second array that stores the values { 0, 1, 3, 6, 10, 15, 21, 28, 36 }. There's some formula for it, but it's faster to just do lookups... anyways, when you want to access a value in the 'triangular' array, use mytriangle(rowstarts(row) + inset).
Reply
#5
Never mind.

We figured it out.

The answer is completely not what you'd expect. Reason: the question is completely different than what you think.

I don't have the code anymore..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)