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

0 Members and 1 Guest are viewing this topic.

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 #930 on: November 07, 2011, 06:40:36 pm »
Yeah because if your bullets are in x1 format, you won't have enough precision for them to move in many directions smoothly

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Axe Q&A
« Reply #931 on: November 07, 2011, 06:40:52 pm »
Don't you need to multiply L by 256 since it's returning magnitude of the vector in pixel format rather than *256 format?

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 #932 on: November 07, 2011, 06:43:41 pm »
Still not working :\
Code incoming, will edit...
Code: [Select]
[all FFs]→Pic1
[C0C000...]→Pic2
0→X→Y→Z
12032→S
7936→S
.center of screen, x256
-1000→Θ
.lazy way of making it create bullet in first frame :P
Repeat getKey(15)
X+(getKey(3)*256)-(getKey(2)*256)→X
X+(getKey(1)*256)-(getKey(4)*256)→Y
Pt-On(X//256,Y//256,Pic1)
If ...(bullet goes off-screen)
sqrt(abs(X-S)/256^2+(abs(Y-T)/256^2))->A
S-X//A*50->A
T-Y//A*50->B
.without the *50 it was moving really slow so yeah
S→Z
T→Θ
End
U+Z→Z
V+Θ→Θ
Pt-On(Z//256,Θ//256,Pic2)
DispGraphClrDraw
End
« Last Edit: November 07, 2011, 06:50:25 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 #933 on: November 07, 2011, 06:48:26 pm »
Well lets say one object is 10 pixels away from another.  So XY = (0,0) and CD = (2560,0) (since we are in x256 format).  We then start the math:

Code: [Select]
Sqrt(abs(X-C)/256^2+(abs(Y-D)/256^2))->L
Sqrt(abs(0-2560)/256^2+(abs(0-0)/256^2))->L
Sqrt(10^2 + 0^2)->L
10->L

So now we have the distance in pixels between the two objects

Code: [Select]
X-C//L->A
0-2560//L->A
-2560//10->A
-256->A

So A = -256 which is a velocity of -1 pixels per frame.  If we multiplied L by 256, we would get A as a value of -1, which is much too slow to have any precision.  Since A is operating on a position that is in x256 format, it all works out in the end.  :D

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 #934 on: November 07, 2011, 10:16:26 pm »
Ok for some reason it only shoots at 45-degree angles (not horizontal or vertical), despite having x256 precision.
I've been messing around with it a bit, and it'll still only shoot at said angles away from the target ???

EDIT:
Quote
Darl181 and 19 Guests are viewing this topic.
0.o
« Last Edit: November 07, 2011, 10:32:06 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 #935 on: November 07, 2011, 10:22:30 pm »
Hmm could you post the code you are using?

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 #936 on: November 07, 2011, 10:25:50 pm »
Um this time I'll just bbify it :P
Quote from: Axe
.ATT1
[FFFFFFFFFFFFFFFF]Pic1
[C0C0000000000000]Pic2
[6090906000000000]Pic3
0XYZ
12032S
7936T
~1000theta
Repeat getKey(15)
X+(getKey(3)*256)-(getKey(2)*256)X
Y+(getKey(1)*256)-(getKey(4)*256)Y
Pt-On(X//256,Y//256,Pic1)
...
rand^3-1*256+S->S
(S<<6144)*256-((S>>18432)*256)+S->S
rand^3-1*256+T->T
(T<<4096)*256-((T>>12288)*256)+T->T
Pt-On(S//256-1,T//256-1,Pic3)
...

Pt-On(46,30,Pic3)
If Z>>24320 or (Z<<0) or (theta>>16128) or (theta<<0)
(abs(X-S)/256^2+(abs(Y-T)/256^2))B
S-X//BU
T-Y//BV
XZ
Ytheta
End
U+ZZ
V+thetatheta
Pt-On(Z//256,theta//256,Pic2)
DispGraphClrDraw
End


Generated by the BBify'r (http://clrhome.tk/resources/bbify/)
« Last Edit: November 07, 2011, 10:31:48 pm by Darl181 »
Vy'o'us pleorsdti thl'e gjaemue

Offline mrmprog

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 559
  • Rating: +35/-1
    • View Profile
Re: Axe Q&A
« Reply #937 on: November 07, 2011, 10:52:01 pm »
  In a game I am making, I have a tilemap of powerups, and then a fully variable character. How would I get the value of the tile that the character is in?

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 #938 on: November 07, 2011, 11:01:44 pm »
It's because you are using the modular expression ^ instead of the squared symbol :)

EDIT: And what do you mean the value of the tile the character is in?  Do you mean the tile in the tilemap that he is standing in?
« Last Edit: November 07, 2011, 11:02:34 pm by Builderboy »

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Axe Q&A
« Reply #939 on: November 07, 2011, 11:51:01 pm »
Darl: Here's an Axiom jacobly wrote that does 8.8 square roots. it uses the seq( token.
http://ourl.ca/9165/257366
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

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 #940 on: November 08, 2011, 12:15:28 am »
It's because you are using the modular expression ^ instead of the squared symbol :)
* Darl181 looks at above code and attached source...
So I'm supposed to use it?  *tests*

Also since there isn't a sqrt() token, is that 2nd + x2?
I was meaning the button..

EDIT:
..it works :D
* Darl181 facepalms @ self
« Last Edit: November 08, 2011, 12:19:28 am 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 #941 on: November 08, 2011, 12:18:12 am »
Yes, in the source and your code, you used the ^ symbol, which in Axe means modulus, not exponent.  You need to use the squared symbol, which is on the left side of the calc above the Log button. 

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Q&A
« Reply #942 on: November 09, 2011, 03:21:05 am »
could someone explain lambdas? Ashbads tutorial doesnt really help me.
I dont know what lambdas do, the syntax, and how to use...
I'm not a nerd but I pretend:

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: Axe Q&A
« Reply #943 on: November 09, 2011, 05:53:20 am »
Code: [Select]
:λ(EXPR)→A
Is shorthand for:

Code: [Select]
:ʟTEMP→A
:
:Lbl TEMP
:Return EXPR

With the added convenience that you don't need to create a new label name, thus you can think of lambdas as creators of unnamed functions.  This is mainly useful when you have a high order subroutine (one that takes another subroutine as an argument) that you want to pass a simple function inline instead of having to create one somewhere far away in your code and pass the reference.

For instance here is a useful high order subroutine I thought of:

Code: [Select]
:Lbl Merge
:r₁→r₆
:L₆→A
:For(768)
: (r₆)({A},{A+L₃-L₆})→{A}+1→A
:End
:Return

This subroutine "Merge" takes only one argument: A function of 2 variables.  It then applies this function to corresponding bytes of the front and back buffers and writes the result to the front buffer.  So here are some things we can pass to it:

Code: [Select]
:Merge(λ(r₁ or r₂))    ."or" the buffers together.
:Merge(λ(r₁ xor r₂))    ."xor" the buffers together.
:Merge(λ(r₁ and r₂))    ."and" the buffers together.
:Merge(λ(not(r₁) and r₂))  .some other logic
:Merge(λ(0))         .Clear the buffer
:Merge(λ(255))       .Fill the buffer with black
:Merge(λ(r₂))         .Replace front buffer with back buffer
:Merge(λ(not(r₂)))    .Replace front buffer with the inverse of the back buffer

And so on... Notice how we were able to do all these similar functions without having to re-type a ton of code with tons of separate subroutines.  Also notice how easy this was using lambdas.  The high order function are really great for repetitive code and can be used to reduce code size with only a small overhead cost in speed.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Axe Q&A
« Reply #944 on: November 09, 2011, 03:05:31 pm »
What would be the best way to make enemys and characters not go through walls and obstacles?