Author Topic: How to move a sprite while updating greyscale???  (Read 6884 times)

0 Members and 2 Guests are viewing this topic.

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
How to move a sprite while updating greyscale???
« on: September 07, 2012, 09:29:14 pm »
So, I understand grey-scale, and physics and so on, So I decided to make some sort of simple game. Except I don't get how to make a sprite move around using getkey or whatever, and still not pause the actual gray-scale updating? Can someone tell me how, to say make a small gray-scale box move around the screen? Just need an idea for the loop structure, that's all.

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #1 on: September 07, 2012, 09:41:56 pm »
simple.

Repeat getKey(15) //make sure the program quits when you press {Clear}
ClrDrawrr
your greyscale sprite goes here
DispGraphrr
your sprite movement control goes here
End

I know that it's not optimized, but it'll do. :D
Sig wipe!

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #2 on: September 07, 2012, 09:44:11 pm »
simple.

Repeat getKey(15) //make sure the program quits when you press {Clear}
ClrDrawrr
your greyscale sprite goes here
DispGraphrr
your sprite movement control goes here
End

I know that it's not optimized, but it'll do. :D
Okay, thanks, and one more question, why is most sprite movement multiplied by 256? it it for some specific reason?

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #3 on: September 07, 2012, 09:46:38 pm »
I'm not sure but I think they were usually related to gravity or something.
Sig wipe!

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #4 on: September 07, 2012, 09:50:27 pm »
Yes, *256 inflation is used for physics, which allows the player to move at 1/256 of a pixel at a time.

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #5 on: September 07, 2012, 09:51:27 pm »
Yes, *256 inflation is used for physics, which allows the player to move at 1/256 of a pixel at a time.
How does that work, say you have to move 2, then *256, it becomes 512, doesn't that go over the limit of 96 px?

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #6 on: September 07, 2012, 09:54:10 pm »
No, when you display it, you do /256, which means that you have to add 512 to the value in order to move 2 pixels. It's kind of hard to explain it in a condensed form, I'd try looking at some of the many physics tutorials. :)

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #7 on: September 07, 2012, 09:54:59 pm »
No, when you display it, you do /256, which means that you have to add 512 to the value in order to move 2 pixels. It's kind of hard to explain it in a condensed form, I'd try looking at some of the many physics tutorials. :)
K, and this is used in pretty much all physics right?

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: How to move a sprite while updating greyscale???
« Reply #8 on: September 07, 2012, 11:13:04 pm »
No, when you display it, you do /256, which means that you have to add 512 to the value in order to move 2 pixels. It's kind of hard to explain it in a condensed form, I'd try looking at some of the many physics tutorials. :)
K, and this is used in pretty much all physics right?
It's certainly the most optimized number for position inflation. In fact, since Axe is big-endian, instead of doing VAR/256, you can do {°VAR+1}. This method also has a lot of uses outside of physics, too.
In-progress: Graviter (...)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How to move a sprite while updating greyscale???
« Reply #9 on: September 08, 2012, 12:26:23 am »
No, when you display it, you do /256, which means that you have to add 512 to the value in order to move 2 pixels. It's kind of hard to explain it in a condensed form, I'd try looking at some of the many physics tutorials. :)
K, and this is used in pretty much all physics right?
It's certainly the most optimized number for position inflation. In fact, since Axe is big-endian, instead of doing VAR/256, you can do {°VAR+1}. This method also has a lot of uses outside of physics, too.
It's actually little-endian, but yes, that is the correct method.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: How to move a sprite while updating greyscale???
« Reply #10 on: September 08, 2012, 12:27:52 am »
Wait, if you use +1 to access the high byte, why isn't it big endian? :P I've been deceived D:
In-progress: Graviter (...)

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: How to move a sprite while updating greyscale???
« Reply #11 on: September 08, 2012, 12:31:20 am »
Big endian means that the highest byte comes first. Little endian means the lowest byte comes first.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: How to move a sprite while updating greyscale???
« Reply #12 on: September 08, 2012, 12:32:21 am »
Ugh, I got big endian and little endian mixed up XD Big endian sounds like the big byte should be at the end, that's my justification.
* leafy runs
In-progress: Graviter (...)

Offline Link

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 152
  • Rating: +7/-3
  • Well excuse me princess!
    • View Profile
Re: How to move a sprite while updating greyscale???
« Reply #13 on: September 08, 2012, 04:23:58 pm »
Hmm, well I tried this according to what yeong said: but it isn't working? Whats wrong >.>

Code: [Select]
:.A
:AsmComp(SPEEDKEY)
:[7E81BD817E18183C]→Pic1
:[7EFFC3FF7E18183C]→Pic2
:ClrDraw{^r}{^r}
:0→X→Y
:While 1
:Zoom Out→A
:Pt-Off(X/256,Y/256,Pic1)
:Pt-Off(X/256,Y/256,Pic2){^r}
:DispGraphClrDraw{^r}{^r}
:If A=1
:Y--
:End
:If A=2
:X--
:End
:If A=3
:X++
:End
:If A=4
:Y++
:End
:EndIf getKey(15)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: How to move a sprite while updating greyscale???
« Reply #14 on: September 08, 2012, 04:33:25 pm »
Hmm, well I tried this according to what yeong said: but it isn't working? Whats wrong >.>

Code: [Select]
:.A
:AsmComp(SPEEDKEY)
:[7E81BD817E18183C]→Pic1
:[7EFFC3FF7E18183C]→Pic2
:ClrDraw{^r}{^r}
:0→X→Y
:While 1
:Zoom Out→A
:Pt-Off(X/256,Y/256,Pic1)
:Pt-Off(X/256,Y/256,Pic2){^r}
:DispGraphClrDraw{^r}{^r}
:If A=1
:Y--
:End
:If A=2
:X--
:End
:If A=3
:X++
:End
:If A=4
:Y++
:End
:EndIf getKey(15)

I'm assuming that when you press the enter keys, the sprite doesn't appear to move. That's totally normal, because you're only subtracting or adding one to each variable, and it takes 256 such adds or subtracts to move one pixel. To mitigate this, you might try Y-25->Y instead of Y-- and see if that makes a difference.
« Last Edit: September 08, 2012, 04:33:36 pm by leafy »
In-progress: Graviter (...)