0 Members and 1 Guest are viewing this topic.
:For(G,1,I):If pxl-Test({L2+(G*4)},{L2+(G*4)+1}):For(θ,1,U):If {L2+(G*4)}=({L1+(θ*4)}) or ({L2+(G*4)}=({L1+(θ*4)}-1)):If {L2+(G*4)+1}=({L1+(θ*4)+1}) or ({L2+(G*4)+1}=({L1+(θ*4)+1}-1)):{L1+(θ*4)+2}-100→{L1+(θ*4)+2}:0→r1:If {L1+(θ*4)+2}=0 and (U≠0):S+10→S:100→{L1+(θ*4)+2}:Pxl-Off({L1+(θ*4)},{L1+(θ*4)+1}):Pxl-Off({L1+(θ*4)},{L1+(θ*4)+1}-1):Pxl-Off({L1+(θ*4)}-1,{L1+(θ*4)+1}):Pxl-Off({L1+(θ*4)}-1,{L1+(θ*4)+1}-1):5→{L1+(θ*4}→{L1+(θ*4)+1}:r1+1→r1:End:End:End:End:U-r1→U::{L2+(I*4)}→{L2+(G*4)}:{L2+(I*4)+1}→{L2+(G*4)+1}:{L2+(I*4)+2)→{L2+(G*4)+2}:0→{L2+(I*4)}→{L2+(I*4)+1}→{L2+(I*4)+2}:I-1→I:Else:Pxl-On({L2+(G*4)},{L2+(G*4)+1}):End:End
I have had a similar problem with a project of my own previously, and assuming the enemies freeze the moment another one gets killed, you might be doing something wrong in the code that removes enemies from the buffer when they get killed. An enemy "freezing" could have several causes: forgetting to erase an enemy from the screen buffer, or incorrectly/not moving backwards the remaining enemy entries in the buffer when one is removed (in my case it was the latter, causing enemies to turn invisible and randomly freeze and warp around when one was killed).
Narrow down the randomness of a "sometimes-occuring" bug to specific criteria that must be met to reproduce the problem.
Lbl DIFF10→A→B→C→S→T→R→U→D→I→θ→G→{L1}→{L2}
0→{L1}L1→{L2}
:If K=15:Goto DIE:End:If K=33:0→L:Else:End:If K=34:1→L:Else:End:If K=26:2→L:Else:End:If K=16:3→L:Else:End
If K=47 and (Z=0):1→R:End
If {L1+(θ*4)}=(X+1) or ({L1+(θ*4)}=(X-2)) or ({L1+(θ*4)}=X) or ({L1+(θ*4)}=(X-1)) or ({L1+(θ*4)}=(X+2))
If {L2+(G*4)+2}=1becomesIf {G*4+2+L2}=1
!If {G*4+2+L2}-1
Pxl-Off({L1+(θ*4)},{L1+(θ*4)+1})Pxl-Off({L1+(θ*4)},{L1+(θ*4)+1}-1)Pxl-Off({L1+(θ*4)}-1,{L1+(θ*4)+1})Pxl-Off({L1+(θ*4)}-1,{L1+(θ*4)+1}-1)becomesPxl-Off({θ*4+L1→F},{F+1})Pxl-Off({F},{F+1}-1)Pxl-Off({F}-1,{F+1})Pxl-Off({F}-1,{F+1}-1)
.
:If K=15:Goto DIE:End :If K=33:0→L:Else:End:If K=34:1→L:Else:End:If K=26:2→L:Else:End:If K=16:3→L:Else:End
Oh I see, should I use the Fill( command to zero out the ram?
What is a LUT and what does inData do?
{0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225}→GBD1 ; a LUT with the squares of 0-15...instead of a calculation likeA²→Byou can use the LUT:{A+GBD1}→B
inData(BYTE,PTR) Searches for BYTE in the zero-terminated data. If found, it returns the position it was found in (starting at 1). If not found, 0 is returned.
{33,34,26,16,0}→GBD1
If inData(K,GBD1)→F ; if the key is one of the weapon selectorsF-1→L ; take this value (1-4) and subtract 1 (then we have 0-3) and store it in L.End
If inData(K,GBD1) -1→L ; that is the subtraction minus sign, same as above. It subtracts from the last evaluated expression, which is "inData"End
I never knew about the "+" and "*" operations
Code: [Select]Lbl DIFF10→A→B→C→S→T→R→U→D→I→θ→G→{L1}→{L2}storing something into a Ram location pointed to and will return the address of that location, not the value.You're basically doing that - which is not what you want:Code: [Select]0→{L1}L1→{L2}
then, the elses here make absolutely no sense to me:Code: [Select]:If K=15:Goto DIE:End:If K=33:0→L:Else:End:If K=34:1→L:Else:End:If K=26:2→L:Else:End:If K=16:3→L:Else:EndYou could also use a LUT and the inData( Command.
Use + instead of "or" and * instead of "and" in when doing conditionals, those are bitwise operations.Code: [Select]If {L1+(θ*4)}=(X+1) or ({L1+(θ*4)}=(X-2)) or ({L1+(θ*4)}=X) or ({L1+(θ*4)}=(X-1)) or ({L1+(θ*4)}=(X+2))
Quote from: Derf321 on September 03, 2012, 10:12:47 pmWhat is a LUT and what does inData do?LUT stands for Look-up-table. It is basically just a constant array with values. You can get each value by accessing the data with an index. That is usually a lot faster than having a calculation for it.Example:Code: [Select]{0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225}→GBD1 ; a LUT with the squares of 0-15...instead of a calculation likeA²→Byou can use the LUT:{A+GBD1}→B
You can use an LUT also the other way round. Axe provides the function inData() for that.Quote from: Axe Command ListinData(BYTE,PTR) Searches for BYTE in the zero-terminated data. If found, it returns the position it was found in (starting at 1). If not found, 0 is returned.Zero-terminated means, that the last value of the LUT has to be 0 respectively the first 0 in the LUT is considered as the end.Say, at the beginning of the code we have a LUT with our keys, ending with 0:Code: [Select]{33,34,26,16,0}→GBD1at the point where we need the data, we use inData().Code: [Select]If inData(K,GBD1)→F ; if the key is one of the weapon selectorsF-1→L ; take this value (1-4) and subtract 1 (then we have 0-3) and store it in L.Endoptimized to save a variable:Code: [Select]If inData(K,GBD1) -1→L ; that is the subtraction minus sign, same as above. It subtracts from the last evaluated expression, which is "inData"End
Only applies if the pointer is not a constant! L2 is a constant, so that part of his code is fine.
Remember, the syntax to create a list of data in Axe is different from that in TI-BASIC:Data(0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225)→GBD1
Also would the arithmetic logic be a good optimization for speed on a ti84+SE?