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

0 Members and 2 Guests are viewing this topic.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Q&A
« Reply #1260 on: December 19, 2011, 09:56:16 pm »
I have a question: why doesn't this code work? (It compiles, but it glitches on me)
0→{S}→{S+5}→{S+15}
and S is the pointer to appvar.
(I just had this happen to me too and I spent a couple of hours before getting Runer's help and facepalming.)

Because of the way Axe optimizes, number→{pointer} returns the pointer instead of the number.  The code equivalent to what you are doing is actually this:
:0→{S} :S→{S+5} :S+5→{S+15}
Oh I think I've been doing that O.O
I've noticed a few bugs in my game so I'll check for those :P

For that
and 0->
Is that supposed to be more optimized than
0->
« Last Edit: December 19, 2011, 10:01:25 pm by epic7 »

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Axe Q&A
« Reply #1261 on: December 19, 2011, 10:43:25 pm »
Only if you are storing to a one-byte value.

I need to update my guide...lool

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 #1262 on: December 19, 2011, 11:05:31 pm »
For that
and 0->
Is that supposed to be more optimized than
0->
Explained right before you posted, but you probably didn't notice because it was the last post on the page. It's one byte smaller and three cycles faster (but it works only if you're doing something with one byte, as squidgetx said, such as for sin(), xor , or →{}).

You probably wouldn't notice if you just used 0, though XD
« Last Edit: December 19, 2011, 11:06:17 pm by Deep Thought »




Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Q&A
« Reply #1263 on: December 19, 2011, 11:10:42 pm »
Only if you are storing to a one-byte value.

I need to update my guide...lool
Please do. Everything I know on optimizing is from that :P

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Q&A
« Reply #1264 on: December 21, 2011, 03:53:07 pm »
Can Z-Test be used to go to subroutines?

Like doing
1->A
Z-Test(A,1
Disp "World" ;returns here after subroutine
Return
Lbl 1
Disp "Hello"
Return

And have it display Hello world?

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 #1265 on: December 21, 2011, 07:25:59 pm »
Try this:
Code: [Select]
0→A
DO(A)
Disp "World"
Return
Lbl DO
Z-Test(r1,1)
Return
Lbl 1
Disp "Hello"
Return
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #1266 on: December 21, 2011, 11:04:36 pm »
Ok I'm trying to figure out how to do angles.
What I'm thinking of is if some value is, say, 64 (the 256-degree equivalent of 90 degrees), it sets the x-velocity to the max and y-velocity to 0.  If that value is 128 it should set the y-vel to the max, x-vel zero, etc.

How would I go about doing this?

EDIT: answered on IRC.
.A is angle, 256 degrees
.M is max velocity
cos(A)*2**M→(x-vel)

Then determine Y-velocity based on that.
« Last Edit: December 21, 2011, 11:31:31 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

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 #1267 on: December 21, 2011, 11:33:16 pm »
Cos(angle) for the X velocity and Sin(angle) for the Y velocity?

Offline Darl181

  • «Yo buddy, you still alive?»
  • CoT Emeritus
  • LV12 Extreme Poster (Next: 5000)
  • *
  • Posts: 3408
  • Rating: +305/-13
  • VGhlIEdhbWU=
    • View Profile
    • darl181.webuda.com
Re: Axe Q&A
« Reply #1268 on: December 21, 2011, 11:35:06 pm »
Hm that makes sense actually..I was thinking it might be something really simple like this but didn't know what it would be :P
tho I prolly should have known after taking algebra II...idk :\
Vy'o'us pleorsdti thl'e gjaemue

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 #1269 on: December 21, 2011, 11:50:03 pm »
Rather than computing Y velocity based on X velocity, it might be better to just do sin(A)*2**M→(y-vel)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline jacobly

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 205
  • Rating: +161/-1
    • View Profile
Re: Axe Q&A
« Reply #1270 on: December 22, 2011, 12:12:23 am »
Here is an example program that might help:
Code: [Select]
:.VELOCITY
:192→θ .begin facing up
:0.0→V .begin stationary
:47.0→X .begin in the middle
:31.0→Y
:Repeat getKey(15)
:getKey(4)-getKey(1)+V→V .press up/down to speed up/slow down
:getKey(3)-getKey(2)+θ→θ .press left/right to turn left/turn right
:cos(θ)*2**V+X^96.0→X .use V and θ to change position
:sin(θ)*2**V+Y^64.0→Y
:Pxl-On(X/256,Y/256)
:DispGraphClrDraw
:End

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe Q&A
« Reply #1271 on: December 30, 2011, 01:29:48 pm »
is there a way to shift the portion of the buffer? (Rectangular region will be fine.)
Sig wipe!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Q&A
« Reply #1272 on: December 30, 2011, 02:50:54 pm »
Are you talking at an arbitrary spot, or can it be in multiples of 8 pixels in the X direction?  It's quite easy if the X can be in multiples of 8, but a little more difficult if you need to mask off parts of bits.

Offline MGOS

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +95/-0
    • View Profile
Re: Axe Q&A
« Reply #1273 on: December 31, 2011, 08:25:09 am »
Another question about number input:

I need a function in my program that checks if a number key from 1 - 8 is pressed. It should return the a value between 1 and 8, or 0 if none of them is pressed. I already looked at the number input routine, but it isn't that what I need.
Would you recommend a LUT, a mathematical way or only some Ifs and Elses?

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Axe Q&A
« Reply #1274 on: December 31, 2011, 11:20:48 am »
I recommend using inData.  Yesterday I wrote some code to do the exact thing you talk about, only with the numbers 0 through 9, and it looks like this:

While 1
EndIf inData(getKey,Data(33,34,26,18,35,27,19,36,28,20,0))->r1


This gives you the number of the key pressed plus one, stored in r1.  If my condensed code doesn't make sense to you, here's an uncompressed version:

Data(33,34,26,18,35,27,19,36,28,20,0)->GDB0
While 1
getKey->K
inData(K,GDB0)->r1
EndIf r1


You could easily modify it to suit your needs, and while you do it I hope you figure out how it works.  InData is a very useful and powerful command, though it is a bit advanced. If you need more help with it, check out this post: http://ourl.ca/4129/114828

Edit:  In response to your question, I am using a LUT, but accessing it through InData for some great space savings (assuming you use InData more than once or twice in your program).
« Last Edit: December 31, 2011, 02:26:32 pm by ztrumpet »