Author Topic: Ok, I give. I need help.  (Read 5203 times)

0 Members and 1 Guest are viewing this topic.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Ok, I give. I need help.
« 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.

Code: [Select]
____↓_________________________________________________________________↓
____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_|_|_|_|_|_|_|_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_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_23|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|
_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).

Code: [Select]
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. :)
« Last Edit: March 16, 2010, 05:52:35 am by meishe91 »
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Gale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +1/-0
  • Ti-84+ Silver Edition
    • View Profile
Re: Ok, I give. I need help.
« Reply #1 on: March 16, 2010, 03:28:32 pm »
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
remember me as a time of day...

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Ok, I give. I need help.
« Reply #2 on: March 16, 2010, 03:45:56 pm »
Well I'm trying to avoid ASM Libs right now. Thanks though.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Ok, I give. I need help.
« Reply #3 on: March 16, 2010, 05:59:20 pm »
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. :)

Offline Radical Pi

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1143
  • Rating: +5/-2
    • View Profile
    • RealityRevolution
Re: Ok, I give. I need help.
« Reply #4 on: March 16, 2010, 06:41:52 pm »
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:
Code: [Select]
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 :)
One of these days I'll get a sig I'm really proud of.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Ok, I give. I need help.
« Reply #5 on: March 16, 2010, 08:53:40 pm »
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 :)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Radical Pi

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1143
  • Rating: +5/-2
    • View Profile
    • RealityRevolution
Re: Ok, I give. I need help.
« Reply #6 on: March 17, 2010, 12:14:14 am »
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.

Code: [Select]
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)
« Last Edit: March 17, 2010, 06:11:47 pm by Nyrax »
One of these days I'll get a sig I'm really proud of.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Ok, I give. I need help.
« Reply #7 on: March 17, 2010, 03:06:04 am »
Thanks, Nyrax. I'll have to go over that later when I have time.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Ok, I give. I need help.
« Reply #8 on: March 17, 2010, 04:28:57 pm »
That looks great Nyrax.  Awesome job! ;D

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Ok, I give. I need help.
« Reply #9 on: March 17, 2010, 11:02:40 pm »
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.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Ok, I give. I need help.
« Reply #10 on: March 18, 2010, 12:27:59 am »
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?
Spoiler For Random signess:
You can not beat my skills.
Trust me.
So don't even try.
And remember never to trust someone who says, "Trust me."

TI File Editor Progress: Remade in java like a boss. 50% we'll call it? IDK =P
Java Libraries: JIRC - 90% JTIF - 5%
TI Projects: Unreal Notator - -5000%
Nomcraft, a Bukkit mod
Some of the music I write can be found here | The Rest Should Be Here (Bandcamp)

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Ok, I give. I need help.
« Reply #11 on: March 18, 2010, 12:37:05 am »
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.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Radical Pi

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1143
  • Rating: +5/-2
    • View Profile
    • RealityRevolution
Re: Ok, I give. I need help.
« Reply #12 on: March 18, 2010, 10:30:32 am »
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.
One of these days I'll get a sig I'm really proud of.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Ok, I give. I need help.
« Reply #13 on: March 18, 2010, 05:17:24 pm »
Hmmm, ok. I think I get it. Thanks.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)