Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: meishe91 on March 16, 2010, 01:49:02 am
-
So I have been trying to create a walking system that will work for a game I'm creating but I can't get it to work properly and I have tried basically everything I can think of. Basically what I'm trying to do (for the test program) is make it so that it will only move 32 spaces left or right and 24 spaces up and down (basically being restricted to a 24x32 map). I have tried assigning sections of map to not let it move past, I have tried making it so only u can walk over 32 spaces. Nothing has worked. I have gotten close...but not quite.
____↓_________________________________________________________________↓
____0 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 3
→0_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|←
_1_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_2_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_3_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_4_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_5_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_6_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_7_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_8_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_9_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_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|
_24|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
→25|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|←
____↑_________________________________________________________________↑
Within those bounds are what I have been able to achieve. The problem though is that it isn't supposed to go into the rows marked with arrows.
Basically, effect wise, what I'm trying to do is that it will wrap around when it gets to row nine and seventeen but stop once you get to row twenty-four. Same basically in the horizontal just stretched out over two screens and only one wrap around. I can post sample code of what I have come up with that has failed (or I can recreate the one that got close), just ask. Thanks for anything :)
I also hope this makes sense haha.
Edit: so I decided I would post the code up that I just created (I thought this would work...not so much :P).
ClrHome
DelVar CDelVar DDelVar EDelVar F1→A
1→B
Repeat K=45
Output(A,B,"_
A+D→A
E+(A=9)-not(A→E
If (A=9) and (not(E) or (E=1))
A-8→A
If (A=9) and (E=2)
A-1→A
If not(A) and ((E=2) or (E=1))
A+8→A
If not(A) and not(E
A+1→A
B+C→B
F+(B=17)-not(B→F
If (B=17) and not(F
B-16→B
If (B=17) and (F=1)
B-1→B
If not(B) and (F=1)
B+16→B
If not(B) and not(F)
B+1→B
Output(A,B,"*
Repeat Ans
getKey→K
End
(K=34)-(K=25→D
(K=26)-(K=24→C
End
Note: I realize this is very unoptimized. I also realize that this could potentially contain errors that I just didn't catch. Cut me some slack though, I created this at three in the freaking morning :P (I really need to sleep better...)
Anywho, thanks again for any input/help/anything. :)
-
i'm pretty sure that xLIB has a command that can restrict the size of the graph screen, thus allowing you to do your 32-space thingy. but, i'm rough with xLIB (finally got it two days ago), so i'm not totally certain
-
Well I'm trying to avoid ASM Libs right now. Thanks though.
-
I'm unsure what you're trying to do. Do you want it to scroll smoothly (like Tifreak's pokemon) or room-by-room (like Builderboy's Trapped or DJ Omni's Illusiat 13)? Once you let us know that, I'll try to help whip up a solution. :)
-
If I'm interpreting your post correctly, basically you want a non-scrolling 3x2 map of standard 8x16 map segments, and you want to prevent yourself from going outside the 3x2 mega-map?
I didn't fully read your code, but this is what I would use to keep myself in any kind of bounds: min(8,max(1,R -> R
min(16,max(1,C -> C
Just replace R and C with whatever vars you use for your mega-level row and column.
I hope this is what you were looking for, and if it is, that this post helps :)
-
Ya, I think Nyrax knows what I mean. But ya, basically a room by room would be nice. The whole map is a 3x2 of 8x16 screens. I'm not sure how to implement what Nyrax said though into the program (don't fully understand the max( and min( commands yet). Thanks though :)
-
Alright, I've implemented the basics of what you want, but in a way that I don't think can easily be extended for whatever the real reason you wanted this for was (an rpg engine?). But it's the idea behind it that counts.
ClrHome
:1→R //R and C are my row and column,
:1→C //R from 1 to 8, C from 1 to 16. Standard stuff.
:1→P //P and Q are my higher-level-map row and column, respectively.
:1→Q //I'm using a 3x3 mega-map, so both are 1 to 3.
:Repeat K=45
:Repeat Ans
:getKey→K
:End
:Output(R,C,"
:R+(K=34)-(K=25→R //Typical.
:C+(K=26)-(K=24→C
:min(3,max(1,P+(R>8)-not(R→A //The innermost part moves P if R is out of its current map. The min/max keep P in its bound. But store this to A, to see whether P changes later.
:min(3,max(1,Q+(C>16)-(C<1→B //Same basic thing for Q. If C is out of bounds, change Q, then force Q back into its bounds with min/max.
:min(8,max(1,R-8(A-P→R //Inner part: awesome way of saying "If P changed, put R on the other side of the screen like it should be".
:min(16,max(1,C-16(B-Q→C //Outer part: "unless you're going out of the mega-map. Then this catches you and puts you back in the 1-8 bounds." Same for C.
:A→P //And then we need to actually update P and Q
:B→Q
:Output(1,2,"P Q
:Output(2,1,{P,Q //Just for you to keep track, really.
:Output(R,C,"*
:End
Apologies if my explanation isn't up to par. It's after midnight and I honestly started forgetting how exactly my code worked while I was typing ;D
(edited to fix a typo)
-
Thanks, Nyrax. I'll have to go over that later when I have time.
-
That looks great Nyrax. Awesome job! ;D
-
So I went over the code, could someone explain how exactly the min( and max( commands work though? I mean I get what they are doing, just not how they work exactly. Thanks again for the code, Nyrax.
-
They take a list, such as {1,2,3,4} and find either the minimum element, or the maximum element, of that list. so the min({1,2,3,4}) = 1 and the max({1,2,3,4}) = 4
Does this help?
-
Ya, but I kinda knew that part. Its more of how the max( inside the min( works. Because I don't see how the 8 being in the min ends up being the max space you can move on the screen.
-
min(8,max(1,R
max(1,R returns 1 if R is less than 1. AKA, This is the bounding code for the top of the screen.
min(8,R returns 8 if R is greater than 8. This is the bounding code for the bottom of the screen.
And since both of those expressions = R, you can nest them like I did to combine their functionality/optimize.
-
Hmmm, ok. I think I get it. Thanks.