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

0 Members and 1 Guest are viewing this topic.

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Need code help with Sprites
« Reply #30 on: March 16, 2010, 11:25:44 pm »
is D your previous getKey? and it flickers because (a) you don't erase the pic after updating the screen and (b) when you do press a key, it's not going to draw anything that loop because getKey won't = 0, so itll skip drawing the sprite. Does that make sense?
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #31 on: March 16, 2010, 11:30:17 pm »
Not quite... This is all in context, so here's the whole of it:

Code: [Select]
ClrHome
ClrDraw
DiagnosticOff
'DOWN
[3C245A42A5A55A663C245A42A5A55E603C245A42A5A55A663C245A42A5A57A06→Pic1
'RIGHT
[3824445858582838382444586C6894EC3824445858582838382444585C4894EC→Pic2
'LEFT
[1C24221A1A1A141C1C24221A361629371C24221A1A1A141C1C24221A3A122937→Pic3
'UP
[3C244242A5A55A663C244242A5A55E603C244242A5A55A663C244242A5A57A06→Pic4
1→A
1→B
0→X
Pt-On(A,B,Pic1

While getKey(15)=0
If getKey=0
If D=1:Pt-On(A,B,Pic1)End
If D=2:Pt-On(A,B,Pic2)End
If D=3:Pt-On(A,B,Pic3)End
If D=4:Pt-On(A,B,Pic4)End
End
Pause 100
DispGraph
X+1→X
If X=20:0→XEnd
If getKey(1)=1
B+1→B
1→D
ClrDraw
Pt-On(A,B,X/5*8+Pic1
End
If getKey(2)=1
A-1→A
2→D
ClrDraw
Pt-On(A,B,X/5*8+Pic3
End
If getKey(3)=1
A+1→A
3→D
ClrDraw
Pt-On(A,B,X/5*8+Pic2
End
If getKey(4)=1
B-1→B
4→D
ClrDraw
Pt-On(A,B,X/5*8+Pic4
End
End
« Last Edit: March 16, 2010, 11:30:34 pm by ikemike »
Anonymous Legend

Offline trevmeister66

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1009
  • Rating: +14/-5
    • View Profile
Re: Need code help with Sprites
« Reply #32 on: March 16, 2010, 11:33:29 pm »
Hmm well you don't need to do ClrDraw, you can just do "Pt-Off(X,Y,Pic#" before you update it's X or Y location, and then draw the new sprite.
Projects:    nameless RPG: 1.0%  |  Reverse Snake v1.5: 100%  |  Secret Project: 5%  |  DUNGEON: 70%

My MW2 Blog <-- Please visit :)

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #33 on: March 16, 2010, 11:37:41 pm »
The problem is, it might have been a completely different sprite, and then it would only erase a portion of the sprite. Of course, I might be wrong. Does it slow the program down?
Also, that doesn't help me for making the sprites not flicker.
Anonymous Legend

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Need code help with Sprites
« Reply #34 on: March 16, 2010, 11:38:36 pm »
Hmm well you don't need to do ClrDraw, you can just do "Pt-Off(X,Y,Pic#" before you update it's X or Y location, and then draw the new sprite.
Pt-Off doesn't work that way. What it actually does is similar to the "overwrite" option in xLib. You could do Pt-Off with a blank sprite to erase though, I think
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #35 on: March 16, 2010, 11:45:06 pm »
Would I need to append a 0000000000000000 to a hex code, or is that the default?
Also, I'd really like some help with the flicker problem...
Anonymous Legend

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 #36 on: March 16, 2010, 11:47:02 pm »
Umm, I might be able to help with the rest of the code if i actually knew what it did other than display sprites when you press keys.  I can't really get intentions from code. :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 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 #37 on: March 16, 2010, 11:47:53 pm »
You need a beeline or a ':' between the ) and the End, and you don't need the )

also for any If statements, any time you use and/or/xor you need a bracket after.
So this: If x=10 and x=11 would change to this: if x=10 and (x=11
that's just some quirks of the axe parser right now.

Edit: wow, didn't see those new posts x.x
« Last Edit: March 16, 2010, 11:49:50 pm by Eeems »
/e

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #38 on: March 16, 2010, 11:51:57 pm »
Okay. It displays a sprite and moves it around the screen when you press the corresponding arrow key. The sprite that's shown is part of that direction's walking animation. A  X is constantly changing values from 0 to 20, and that value changes which sprite in the walking animation is shown. The problem is the revert-to-non-walking-sprite. This causes the walking animation to constantly flicker back to the default non-walking sprite, when it should be displaying a sprite of a limb extended.

The fact I can make a sprite animate and walk around, though, is awesome, because I haven't been able to do this is pure basic in my two years of (amateurish) programming. I learn how to do this in 2 days with Axe parser. Cool stuff.
« Last Edit: March 16, 2010, 11:52:53 pm by ikemike »
Anonymous Legend

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 #39 on: March 16, 2010, 11:58:56 pm »
So the first sprite is the walking down animation, the second walking right animation etc. is that correct? if so what are you using for standing still?
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 ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #40 on: March 17, 2010, 12:01:10 am »
The standing still sprite is the first and third hexadecimal code in each Pic#. I can add walking-specific sprites later.
« Last Edit: March 17, 2010, 12:01:26 am by ikemike »
Anonymous Legend

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 #41 on: March 17, 2010, 12:16:23 am »
Oh, ok, i see. How about trying this?
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
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)
If K=15:Goto FN:End
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

Lbl FN
I think that should do what you want... if it doesn't just tell me what happened, scince i just typed this up w/o testing it :P  Ask if you want to know anything about that, of if really just want me to try to edit yours...

EDIT: Forgot to initialize the variables! oops :P
EDIT2: Hopefully you didn't try that code either, you wouldn't have been able to quit...
« Last Edit: March 17, 2010, 09:28:09 am by cooliojazz »
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 #42 on: March 17, 2010, 11:12:35 am »
try changing the If K=15:Goto FN:End to ReturnIf K=15 and get rid of the Lbl FN at the end as well as the Return. You could also change the While 1 to Repeat K=15 or Repeat getkey(15), and then adding a Return at the end of the loop.

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 #43 on: March 17, 2010, 01:38:57 pm »
thats a good idea, except, what return?
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
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
btw, ikemike, i swapped the numbers of the left and right directional sprite so they directly correlate to the arrow keys
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 ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: Need code help with Sprites
« Reply #44 on: March 17, 2010, 04:16:34 pm »
I tried the code, but it gives me a fatal error... Then I have to take the batteries out and it resets the RAM.
« Last Edit: March 17, 2010, 07:00:51 pm by ikemike »
Anonymous Legend