Author Topic: Need code help with Sprites  (Read 22241 times)

0 Members and 1 Guest are viewing this topic.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Need code help with Sprites
« Reply #45 on: March 17, 2010, 08:30:02 pm »
When does the fatal error happen? And what exactly happened?
/e

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #46 on: March 17, 2010, 09:16:47 pm »
Basically, the nothing happens. I start it up, and am greeted with a blank screen. Whereupon I press the arrow keys and nothing appears. Pressing clear doesn't exit, so I take out a battery and put it back in. This causes a RAM clear, so I'm sure it was a fatal error and not just a stuck loop or something.

By the way, what's the pattern of getKey expressions? It's different than the standard one used in Ti-BASIC, and i haven't quite figured it out.
Anonymous Legend

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Need code help with Sprites
« Reply #47 on: March 17, 2010, 09:24:52 pm »
Just going to help optimize a bit and fix some code
Code: [Select]
ClrHome
ClrDraw
DiagnosticOff
.DOWN
[3C245A42A5A55A663C245A42A5A55E603C245A42A5A55A663C245A42A5A57A06→Pic1
.RIGHT
[3824445858582838382444586C6894EC3824445858582838382444585C4894EC→Pic2
.LEFT
[1C24221A1A1A141C1C24221A361629371C24221A1A1A141C1C24221A3A122937→Pic3
.UP
[3C244242A5A55A663C244242A5A55E603C244242A5A55A663C244242A5A57A06→Pic4
0→X
1→A→B                   ;More efficient way to initialize similar variables

Repeat getKey(15)             ;"Repeat" is the same as "while zero"

Pt-On(A,B,D*64+Pic1)       ;Each sprite group is 64 bytes apart
                                     ;Draw the rest sprite every frame, even if it gets written over.
If X+1→X=20             ;You can put the storage statements in if conditions.
  0→X
End
Pause 100

If getKey(1)              ;You don't need the equals one here
  B+1→B
  0→D                     ;D should start at zero
  sub(DW)
End
If getKey(2)
  A-1→A
  1→D
  sub(DW)
End
If getKey(3)
  A+1→A
  2→D
  sub(DW)
End
If getKey(4)
  B-1→B
  3→D
  sub(DW)
End

DispGraph
End
ClrHome                         ;Clear the screen on exit
Return

Lbl DW
ClrDraw                                   ;Clear the screen.  It will erase the rest sprite.
Pt-On(A,B,D*64+(X/5*8)+Pic4)   ;Draw the sprite with the right sprite set.
Return


Haven't tested anything.  But it should work I think.  There are a lot more optimizations you can do, but they are relatively minor and I don't want to confuse you since you're new to this.
« Last Edit: March 17, 2010, 09:41:50 pm by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Need code help with Sprites
« Reply #48 on: March 17, 2010, 11:56:42 pm »
O I'm so stupid :P it wiould never run the main loop.  sorry if i cleared stuffs you were working on :(
Code: [Select]
DiagnosticOff
'DOWN
[3C245A42A5A55A663C245A42A5A55E603C245A42A5A55A663C245A42A5A57A06→Pic1
'LEFT
[1C24221A1A1A141C1C24221A361629371C24221A1A1A141C1C24221A3A122937→Pic2
'RIGHT
[3824445858582838382444586C6894EC3824445858582838382444585C4894EC→Pic3
'UP
[3C244242A5A55A663C244242A5A55E603C244242A5A55A663C244242A5A57A06→Pic4

1->C
0->X
0->Y
While 1
C+1->C
If X^5=0 \\ this should actually be "If C^5=0"
C/5->A
getkey->K
X+(K=3)-(K=2)->X
Y+(K=1)-(K=4)->Y
If K=0
0->A
Else
K->D
End
sub(DP)
ReturnIf K=15
End
End

Lbl DS
ClrDraw
If D=1:Pt-Off(X,Y,A*8+Pic1:End
If D=2:Pt-Off(X,Y,A*8+Pic2:End
If D=3:Pt-Off(X,Y,A*8+Pic3:End
If D=4:Pt-Off(X,Y,A*8+Pic4:End
DispGraph
Return
now that should work.  well, i'm assuming so, if return will quit... (i'm just assuming so since thats what Eeems implied :P)  O random quirk, pressing a key other than the arrows will give you nothing till an arrow key is pressed. didnt feel like fixing that rigth then :P
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 DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Need code help with Sprites
« Reply #49 on: March 18, 2010, 12:08:15 am »

By the way, what's the pattern of getKey expressions? It's different than the standard one used in Ti-BASIC, and i haven't quite figured it out.
Not too sure, I think the key codes were posted somewhere but I totally forgot. Quigibo should probably include the list if they are not included with Axe latest releases.

Offline cooliojazz

  • Support Staff
  • LV7 Elite (Next: 700)
  • *******
  • Posts: 619
  • Rating: +66/-9
  • I omnoms on your soul
    • View Profile
    • Unreal Phantasies
Re: Need code help with Sprites
« Reply #50 on: March 18, 2010, 12:21:39 am »
53 52 51 50 49
54 55 56    4
             2    3
48 40 32    1
47 39 31 23 15
46 38 30 22 14
45 37 29 21 13
44 36 28 20 12
43 35 27 19 11
42 34 26 18 10
    33 25 17 9

Those are the keys of the calculator...  the pattern, basically, is just dereasing numbers asyou move down the rows and to the right, with the arrow keys and the top two rows being different
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 Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: Need code help with Sprites
« Reply #51 on: March 18, 2010, 12:52:29 am »
Return is the equivalent of the 'ret' instruction in ASM. It will quit a macro/routine back to the main code and it will also quit the program if it is no longer in a macro/routine.
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Need code help with Sprites
« Reply #52 on: March 18, 2010, 01:59:33 am »
cool thanks Squirreliojazz... er... Cooliojazz :D

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #53 on: March 18, 2010, 04:20:15 pm »
Thanks, Cooliojazz. Those getKey values will help a lot.

Also, the code doesn't work. It displays the sprite, and it can move around, but it doesn't animate and leaves a trail when moving up or down. It's also really slow.
Anonymous Legend