Author Topic: Axe Q&A  (Read 587293 times)

0 Members and 3 Guests are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #315 on: May 19, 2011, 01:16:04 pm »
pxl-Test(X,Y+1) should be pxl-Test(X,Y/256+1)

Also you can save a lot of memory by doing !If pxl-Test(X,Y/256+1) instead of If (pxl-Test(X,Y/256+1)=0).

I had tried that before and I knew it would work.

My problem is though: Aren't I ruining all the 256 collision by pixel testing with Y/256. Isn't that doing the same as if Y was not a giant value?

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Axe Q&A
« Reply #316 on: May 19, 2011, 01:22:40 pm »
Yes, it is. The advantage to having x256 is that you can have the object move at partial speeds (such as one pixel every three frames for the illusion of 33% speed). pxl-Test( and all those other commands still treat it as if it were a multiple of 256, but this way you can have one object moving one pixel every frame and another at a fraction of that speed.




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #317 on: May 19, 2011, 01:31:18 pm »
Yes, it is. The advantage to having x256 is that you can have the object move at partial speeds (such as one pixel every three frames for the illusion of 33% speed). pxl-Test( and all those other commands still treat it as if it were a multiple of 256, but this way you can have one object moving one pixel every frame and another at a fraction of that speed.

Ah I see, thanks.

So I have a new question about this, can I have like the acceleration of X in values that are also in 256 mode?

So, I'll give this example:

Code: [Select]
.Y of the sprite
0→Y
.X of the sprite
0→X
.X Acceleration of the sprite
0→A
.Y Acceleration of the sprite
0→B
Repeat getKey(15)
  ClrDraw

  If getKey(2)
    A-128→A
  End

  If getKey(3)
    A+128→A
  End

  Line(0,63,95,63)
 
  X+A→X
  Y+B→Y

  Pxl-On(X/256,Y/256)

  If (pxl-Test(X,Y+1)=0)
    Y+128→Y
  End

  DispGraph
End

Is this code OK for accelerating a sprite? For the record, this crashed my calculator during runtime.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #318 on: May 19, 2011, 01:53:22 pm »
That crashed your calculator?  What version of Axe are you using?  Under no circumstances should that code cause a crash o.O

And yes that will work for acceleration, but you are accelerating at .5 (128/256) pixels per frame, which is actually really really fast for a high framerate program.  Try turning it down to like 8 or so.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Axe Q&A
« Reply #319 on: May 19, 2011, 01:57:32 pm »
The pxl-Test arguments need to be scaled down by 256 as well. And it might be a good idea to make sure that the velocity does not exceed 256 (i.e. one pixel per frame), or else the vertical line might be jumped over.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #320 on: May 19, 2011, 02:06:07 pm »
I seriously don't get this, in most of my programs I use X+2->X and sometimes even 3. In order to avoid skipping vertical lines I usually check if (X<88) and (X<87) and stuff like that.

Either way, I am using Axe 0.5.2, but perhaps it was not the program's problem, I shall try again.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Q&A
« Reply #321 on: May 19, 2011, 02:45:28 pm »
It occurred to me that I'm treating memory almost as magic in some cases.
So, some questions.

What's the difference between doing
Code: [Select]
[FFFFFF->Str1
[010203
[More hex
[504432]
and
Code: [Select]
[FFFFFF
[010203
[More hex
[504432]->Str1

If want to load a large amount of memory (using hex, strings or Data()) on multiple lines, how does Axe know when the block of memory ends?  For example, if I have
Code: [Select]
[0102
"Foobar"
Data(42)->Str1
How does the compiler know the limits of the block of memory?
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #322 on: May 19, 2011, 02:53:29 pm »
It occurred to me that I'm treating memory almost as magic in some cases.
So, some questions.

What's the difference between doing
Code: [Select]
[FFFFFF->Str1
[010203
[More hex
[504432]
and
Code: [Select]
[FFFFFF
[010203
[More hex
[504432]->Str1

In the first example, the location Str1 points to is the first byte FF of the first line.  In the second example it points to the byte 50 in the last line.

If want to load a large amount of memory (using hex, strings or Data()) on multiple lines, how does Axe know when the block of memory ends?  For example, if I have
Code: [Select]
[0102
"Foobar"
Data(42)->Str1
How does the compiler know the limits of the block of memory?
I'm not quite sure what you mean?  You have defined 51 bytes in that code, and so Axe adds those 51 bytes into your program.

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Q&A
« Reply #323 on: May 19, 2011, 02:56:54 pm »
If want to load a large amount of memory (using hex, strings or Data()) on multiple lines, how does Axe know when the block of memory ends?  For example, if I have
Code: [Select]
[0102
"Foobar"
Data(42)->Str1
How does the compiler know the limits of the block of memory?
I'm not quite sure what you mean?  You have defined 51 bytes in that code, and so Axe adds those 51 bytes into your program.
[/quote]

Hmm, let me ask different questions.

Is there any difference between
Code: [Select]
[FFFFFF]->Str1
[010203]
[HEX000]
[FFFFFF]
or
Code: [Select]
[FFFFFF->Str1
[010203
[HEX000
[FFFFFF]
?
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #324 on: May 19, 2011, 02:59:55 pm »
Nope, no difference :)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #325 on: May 19, 2011, 03:02:02 pm »
Also,

Code: [Select]
.Y of the sprite
0→Y
.X of the sprite
0→X
.X Acceleration of the sprite
0→A
.Y Acceleration of the sprite
0→B
Repeat getKey(15)
  ClrDraw

  If getKey(2)
    A-128→A
  End

  If getKey(3)
    A+128→A
  End

  Line(0,63,95,63)
 
  X+A→X
  Y+B→Y

  Pxl-On(X/256,Y/256)

  !If (pxl-Test(X/256,Y/256+1))
    Y+128→Y
  End

  DispGraph
End

This freezes my calculator, not crashes, but freezes.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #326 on: May 19, 2011, 03:04:59 pm »
Is that all of your code?  Because that works perfectly fine on my calc

Offline yunhua98

  • You won't this read sentence right.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2718
  • Rating: +214/-12
  • Go take a dive in the River Lethe.
    • View Profile
Re: Axe Q&A
« Reply #327 on: May 19, 2011, 03:13:14 pm »
you're using an Nspire, I take it?

Blame TI.

Spoiler For =====My Projects=====:
Minor setback due to code messing up.  On hold for Contest.
<hr>
On hold for Contest.


Spoiler For ===Staff Memberships===:






Have you seen any good news-worthy programs/events?  If so, PM me with an article to be included in the next issue of CGPN!
The Game is only a demo, the code that allows one to win hasn't been done.
To paraphrase Oedipus, Hamlet, Lear, and all those guys, "I wish I had known this some time ago."
Signature Last Updated: 12/26/11
<hr>

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #328 on: May 19, 2011, 03:18:36 pm »
I am indeed using a Nspire. Either way, I figured it out. I now have a sort of working platforming engine with gravity, my problem is stoping the sprite.

B is the Y acceleration
A is the X acceleration

How to stop the sprite when Y=0?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Axe Q&A
« Reply #329 on: May 19, 2011, 03:21:48 pm »
This will stop it when the sprite is exactly on the 0th pixel, that might be not what you want though. 

Code: [Select]
!If Y/256
0->A->B
End

Do you want to stop the sprite completely, or only the Y velocity?  Or maybe if it goes past the 0th pixel?