Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: yrinfish on March 17, 2011, 10:11:51 am

Title: getKey question
Post by: yrinfish on March 17, 2011, 10:11:51 am
I'm trying to make a key remapping function for DionJump, in Settings, users can edit the keys and the number is saved to an appvar.

But when I try to check the keys, it doesn't work...
Code: [Select]
:If getKey({K+2}) // K is the pointer to the appvar.
: ...
:End

Here is my source, the getKey is changed back to getKey(41), to make the game work. Please don't ask questions about the rest of the code, it isn't really good code, I know that...
WHOA, that's BIG, BIIIIIIIIIIIIIIIIIIIG, did I make that in 4 days ???
Spoiler For Spoiler:
:.NEWJUMP
:DiagnosticOff
:Fix 5
:.---------DATA
:[30]→Pic0
:[8CFC22A5E121A2FCFCA221E1A522FC8C1C62898581621C10020505050505050208151715151715080002050205020502]
:"vsnewJump→Str0
:"vinewJump→Str1
:det(128)→GDB0:
:.--------START
:sub(IN,1,Str0,1,6,Pic0,Str1)
:GetCalc(Str1)→L:GetCalc(Str0)→K:ClrDraw
:ClrHome
:.---------MENU
:Lbl RE
:Normal
:0→D→F→H→M→N→O→P→R→W→X→Y→Z→θ
:Fix 1
:Text(9,9,"DionJump"
:Line(40,20,89,20)
:Line(39,21,39,61)
:Line(40,62,89,62)
:Line(90,61,90,21)
:Text(42,22,"Easy")
:Text(42,30,"Normal")
:Text(42,38,"Hard")
:Text(42,46,"Insane")
:Text(42,54,"Settings")
:DispGraph
:Repeat getKey(9)
: If getKey(1) and (M<4)
:  M+1→M
:  1
: ElseIf getKey(4) and (M>0)
:  M-1→M
:  1
: Else
:  0
: End
: If
:  rref(40,8*M+21,50,9)
:  DispGraph
:  Pause 400
:  rref(40,8*M+21,50,9)
: End
:End
:Fix 0
:Pause 500
:.--------APPLY
:If M=0
: 125→R
:ElseIf M=1
: 080→R
:ElseIf M=2
: 040→R
:ElseIf M=3
: 020→R
:Else
: Goto HLP
:End
:If Full
: R*3→R
:End
:{K+2}→N
:{K+3}→O
:{K+4}→P
:.----INIT GAME
:3→{GDB0+56}
:1→{GDB0+57}
:For(I,0,10)
: rand^27*2+GDB0→M
: 3→{M}
: rand^96→{M+1}
: rand^27*2+58+GDB0→M
: 3→{M}
: rand^96→{M+1}
:End
:32→Y:16→X
:.----GAME LOOP
:While 1
:Pause R
:.---------KEYS
:If getKey(49)
: Return
:End
:0→θ
:If getKey(54)
: -3→θ
: 0→F
:ElseIf getKey(41)
: 3→θ
: 8→F
:End
:.----DATA EDIT
:Z-1→Z
:Y+θ+4^64-4→Y
:For(I,0,63)
: 2*I+GDB0→M
: If {M+1}>95 or ({M+1}=0)
:  0→{M}r
: End
:End
:
:.---COLLISSION
:For(I,0,12)
: Y+I-6*2+GDB0→M: If X<<0
:  Text(2,14,"Luckily we've got doctors..."
:  Text(5,26,"Otherwise you'd be pretty")
:  Text(32,32,"dead now.")
:  Text(7,57,"Press [ENTER] to restart.")
:  DispGraphClrDraw
:  Repeat getKey:  End
:  If getKey(9)
:   Pause 1000
:   Goto RE
:  End
:  ClrHome
:  Fix 4
:  Return
: ElseIf {M+1}+8+1000>(X+Z+1000) and ({M+1}+1000<(X+992)
:  If {M}<6 and ({M}>2)
:   {M+1}+8→X
:   0→Z
:  End
: ElseIf {M+1}=(X-8)
:  If {M}=3
:   8→Z
:  ElseIf {M}=4
:   10→Z
:  ElseIf {M}=5
:   0→{M}r
:  End
: End
:End
:
:
:
:
:.----DATA EDIT
:X+Z→X
:If X>70 and (X<100)
: X-70→M
: X-M→X
: H+M→H
: For(I,0,63)
:  {I*2+GDB0+1}-M→{I*2+GDB0+1}
: End
: !If rand^20
:  sub(GEN,4,M)
:  H→D
: Else!If rand^15
:  sub(GEN,5,M)
: ElseIf H-D>25
:  sub(GEN,3,0,95)
:  H→D
: End
:End
:
:.------DRAWING
:For(I,0,64)
: If {2*I+GDB0}
:  Pt-On({2*I+GDB0+1},I,8*{2*I+GDB0}+L)
: End
:End
:Text(74,0,H►Dec:Pt-On(X,Y,L+F)
:
:DispGraphClrDraw
:End
:
:prgmLINIT
:
:
:.-------BARGEN
:Lbl GEN
:While {rand^64*2+GDB0→A}
:End
:r1→{A}
:If r2
: 95-(rand^r2)→{A+1}
:Else
: r3→{A+1}
:End
:Return
:
:Lbl HLP
:ClrDraw
:Fix 1
:Text(9,9,"Settings"
:Line(40,20,89,20)
:Line(39,21,39,61)
:Line(40,62,89,62)
:Line(90,61,90,21)
:Text(42,22,"Change")
:Text(42,30,"Controls")
:Text(42,38,"About")
:Text(42,46,"You lost")
:Text(42,54,"Back")
:DispGraph
:sub(CHS)
:!If M
: 9→A
:ElseIf M=1
: ClrDraw
: Fix 0
: Text(9,9,"Press the key to go left.")
: DispGraph
: sub(PCK)→{K+2}: Text(66,9,"right.")
: DispGraph
: sub(PCK)→{K+3}: Text(60,9,"quit.           ")
: DispGraph
: sub(PCK)→{K+4}:ElseIf M=2
: 11→A
:ElseIf M=3
: 0→M
:Else
: Goto RE
:End
:Text(45,57,"Press a key...")
:DispGraphClrDraw
:Pause 1000
:Repeat getKey
:End
:Goto RE
:
:Lbl CHS
:Repeat getKey(9)
: If getKey(1) and (M<4)
:  M+1→M
:  1
: ElseIf getKey(4) and (M>0)
:  M-1→M
:  1
: Else
:  0
: End
: If
:  rref(40,8*M+21,50,9)
:  DispGraph
:  Pause 400
:  rref(40,8*M+21,50,9)
: End
:End
:Fix 0
:Pause 500
:M
:Return
:
:Lbl PCK
:Pause 1000
:Repeat getKey
:End
:getKey
Title: Re: getKey question
Post by: Compynerd255 on March 17, 2011, 10:25:37 am
Make sure you are using the right "v" when defining your appvar string. It needs to be the [2nd]+[v] token, NOT the lowercase v. If you did it right, it should show up as "appv". Also, in your PCK method, PCK is actually not getting the last key pressed. It is simply waiting for a key, then it gets the one pressed immediately after it (which, unless they press the arrow keys, is always going to be zero). The code should actually be:
Code: [Select]
Lbl PCK
Pause 1000
0->K
Repeat K
getKey->K
End
I only skimmed your source, but if you are using K for something else, feel free to use some other variable name or even a memory location.
Title: Re: getKey question
Post by: yrinfish on March 17, 2011, 10:49:11 am
Ah, PCK is the problem, I used your fix and it works now.

THANK YOU