Calculator Community > TI-BASIC
Collision Detection Explained
cooliojazz:
@Meishe91: It's While This Is True, and Repeat Until This Is True, that's why one's zero and the other's one. Other than that, great tutorial. :) I really learned something.
Radical Pi:
What if you want to traverse more than just spaces? If you tested each individually with sub(), things would get big fast, so for this case I would recommend a string of characters you can move over and check the inString("characters","where-you're-moving-to")
(or a string of characters you can't move over, if there's less of those. Just use not(inString(... instead)
For example,
--- Code: ---:"
XX XXXXXXXXXXX
X X
X ....... X
. . X
. .. .
X . ...
X .
XXXXXXXXXXX →Str1
:Output(1,1,Ans
:4→R
:8→C
:Output(4,8,"π
:Repeat K=45
:Repeat max(Ans={24,25,26,34,45
:getKey→K
:End
:If K=45
:Return
:Output(R,C,sub(Str1,16R-16+C,1
:min(8,max(1,R+(K=34)-(K=25
:If inString(" .",sub(Str1,16Ans-16+C,1
:Ans→R
:min(16,max(1,C+(K=26)-(K=24
:If inString(" .",sub(Str1,16R-16+Ans,1
:Ans→C
:Output(R,C,"π
:End
--- End code ---
meishe91:
--- Quote from: Nyrax on March 11, 2010, 07:36:39 pm ---What if you want to traverse more than just spaces? If you tested each individually with sub(), things would get big fast, so for this case I would recommend a string of characters you can move over and check the inString("characters","where-you're-moving-to")
(or a string of characters you can't move over, if there's less of those. Just use not(inString(... instead)
For example,
--- Code: ---:"
XX XXXXXXXXXXX
X X
X ....... X
. . X
. .. .
X . ...
X .
XXXXXXXXXXX →Str1
:Output(1,1,Ans
:4→R
:8→C
:Output(4,8,"π
:Repeat K=45
:Repeat max(Ans={24,25,26,34,45
:getKey→K
:End
:If K=45
:Return
:Output(R,C,sub(Str1,16R-16+C,1
:min(8,max(1,R+(K=34)-(K=25
:If inString(" .",sub(Str1,16Ans-16+C,1
:Ans→R
:min(16,max(1,C+(K=26)-(K=24
:If inString(" .",sub(Str1,16R-16+Ans,1
:Ans→C
:Output(R,C,"π
:End
--- End code ---
--- End quote ---
Well like I said, this is just a really basic version of it. This is also no where near as efficient as it could be and I know. This was meant to just give the basic idea :) Thanks though, maybe I'll go over that sometime soon.
--- Quote from: cooliojazz on March 11, 2010, 07:09:19 pm ---@Meishe91: It's While This Is True, and Repeat Until This Is True, that's why one's zero and the other's one. Other than that, great tutorial. :) I really learned something.
--- End quote ---
Thanks! That makes a lot of sense. I shall add that in when I get the chance to do it. O0
By the way, how many people would find a String to Matrix, Matrix to String, String to list, etc. for converting tile based maps?
ztrumpet:
--- Quote from: meishe91 on March 11, 2010, 09:09:26 pm ---By the way, how many people would find a String to Matrix, Matrix to String, String to list, etc. for converting tile based maps?
--- End quote ---
That sounds pretty neat. :)
I can't wait to see what you come up with! ;)
meishe91:
Well I already have one that goes from String to Matrix and back :) (All you have to do is have Matrix [A] and Str1 open and you're good to go...as long as you know the dimentions :P)(This is also only for maps who have two different tiles though, which is the downside.)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version