Well, im making a precursor to a big game, and decided to use raw Ti-Basic. only, i cant figure out how to properly check a space taken inside a string.
for displaying the level, i made a 128 character string, and is displayed with "Output(1,1 Str1".
My charecter is displayed with Output(Y,X,"A"
you move by arrow keys, which change X and Y (your basic moving codes)
My problem with hittesting is the change between X, Y, and the string charecter position (herein S). i put together a little table, but still cant figure how im going to put them together.
S X Y
1 1 1
2 2 1
...
16 16 1
17 1 2 ???
i cant figure out how to see where X & Y are in a single value, to see what character in the string that position holds.
Also, im trying to stay away from reconstructing the string every time a change occurs, because of how speed expencive that was last time i tried it.
http://tifreakware.net/tutorials/83p/b/tifw/les8.htm
You might look into this tutorial, see if that doesn't help?
wooh, that either calls in Matrices (which im NOT using for a map of greater detail (heh, even though its in ASCII)
or it calls on something that, unless i didnt read it right, is slower than my last routine, and much more size costly. if i add gravity, and other things.
its also a ton wrong: it made an up-down oriented program, where im using a platformer veiw. however, it did solve a different problem i was having. so your post was still very helpful.
LuxenD wrote:
its also a ton wrong: it made an up-down oriented program, where im using a platformer veiw.
It's not wrong, it's just for a different platform. That being said, there's no reason the general idea wouldn't transfer--you even said yourself you were able to fix it with knowledge gained from reading it.
nono, i fixed something else. i tried implementing this site's idea on my version, but to no avail. like i said, id like to try and keep my "double-Output" style, just find some way to find S with X and Y.
Well, you use the sub() command to get a substring out of a string, and sub(StrN,X,1) will pluck out the single character at position X from StrN. It's also a bit redundant to have S, X, and Y, as S is necessarily Y*width+X. Of course, if you have a scrolling game, then they're all relevant.
not scrolling. ive used Sub, but is the Y*width+x how you find where that one charecter is?
Imagine S as the postion of a character--its what im trying to find using X and Y.
About midway through the tutorial I linked, I showed how to do it in Strings, I just failed to label the sections properly.
If you are using a 128 character string, which is the entire screen, you don't need an x and y, you just need the s. Then you check s+/- 1 or 16, depending on the direction you are going to see if you are going to hit something. Unless I'm still missing what you are asking for help on.
yeah, thats my super slow way i tried before. ill be insistent on the X and Y; like i said, i just cant figure out a mathematical way to figure out S.
Just curious, was it slower than this:
LuxenD wrote:
yeah, thats my super slow way i tried before. ill be insistent on the X and Y; like i said, i just cant figure out a mathematical way to figure out S.
Isn't that exactly what I said about 5 posts ago, Y*width+X? The width is 16, and Y starts from 1, not 0, so it's 16(Y-1)+X.
yeah, maybe 1/6 a sec or so difference.waiting a half sec to move, sure this is better than my 2-sec version. like i said, it had to rebuild the entire string every time you moved. it retreived the original string, substringed twice to make the space for you if nothing was there, and built the string back together. that was the up-down veiw game that the tutorial fixed.
what your saying is that, right? or did i miss what you said?
(kinda like a spanish guy speaking to a russian--no conceptual communication 0x5)
You don't put the moving X in the string; the string is just the game level. You output the level string at 1,1, then output the X at (Y,X).
Before you get too terribly far into a platformer, it's my advice to reconsider a matrix or list from the sheer speed difference. Which a sub() command can be fast, it can also be wildly inconsistent ( especially if you get into anything over 128 characters, it slows down rather quickly, even under 128 it's noticeable )
However, like Kerm said, you need to output the string as a sort of "background" and use the player character as a "foreground" where the former doesn't move or get adjusted in the main movement loop, but the latter does.
Yup. spent all night trying to figure it out, and something kerm posted above helped.
KermMartian wrote:
...Y*width+x...
with a small edit, the proper way to find S would be ((Y*16)-16)+X.
this lets me get S.
I said 16(Y-1)+X. another five posts ago, which is equivalent to and smaller than ((Y*16)-16)+X = (16*(Y-1))+X = 16(Y-1)+X. I am glad that you figured it out on your own, but I don't see what the point of me posting posts is if you don't read them.
err, i might have been offline when you made that post; i never saw it. but thanks for the optimisation.