Join us on Discord!
You can help CodeWalrus stay online by donating here.

Some super crappy Axe code...

Started by p2, August 24, 2016, 11:41:43 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

p2

Hey guys,
As some of you might already know, I haven't used axe for a couple of years and forgot almost everything about it  :'(
So now I'm trying to relearn axe and wanted ot ask you how I could improve the following code I wrote...
It's ment to be a player (just a square) kickign arount a Ball (a nice circle) with workign colission and gravty stuff...
I'm really sorry but I got no GIF to upload yet, hope you still understand what the code should do...  :(

[spoiler=Main Program].TRY07AXE
ClrDraw
[3C7EFFFFFFFF7E3C]->Pic01
[FF818181818181FF]->Pic02
.L1{0,2, 4, 6
.L1{X,Y,vX,vY
1000->{L1+0}^r
1000->{L1+2}^r
200->{L1+4}^r
100->{L1+6}^r
.Direction(X,Y)=T,U
1->T->U
.Pos Player *100 = V,W
5000->V
1000->W
.Gravitation=G
0->G
.N=NotCollide to prevent double collision
0->N
.C=Counter
0->C
Repeat getKey(15)
C++
ClrDraw
Pt-On({L1+0}^r/100,{L1+2}^r/100,Pic01)
Pt-On(V/100,W/100,Pic02)
DispGraph
{L1+0}^r+({L1+4}^r*T)->{L1+0}^r
{L1+2}^r+({L1+6}^r*T)->{L1+2}^r
prgmTRY07MOV
prgmTRY07COL
prgmTRY07GRV
End
[/spoiler]

[spoiler=Program for players Movement]..TRY07MOV
.DownArrowKey
If getKey(1) and (W<5600):W+100->W:End
.LeftArrowKey
If getKey(2) and (V>0):V-100->V:End
.RightArrowKey
If getKey(3) and (V<8600):V+100->V:End
.UpArrowKey
If getKey(4) and (W>0):W-100->W:End
[/spoiler]

[spoiler=Program for colission and stuff]..TRY07COL
.DOUBLECOLLIDE
N-1->N:If N=(0-1):0->N:End
.COLIDE
.Top Left
If (N=0) and (({L1+0}^r/100)>=((V/100)-7)) and (({L1+0}^r/100)<=((V/100)-6)) and (({L1+2}^r/100)>=((V/100)-7)) and (({L1+2}^r/100)<=((V/100)-6)):{L1+4}^r+80->{L1+4}^r:{L1+6}^r+80->{L1+6}^r:(0-1)->T->U:5->N:0->G:End
.Top Right
If (N=0) and (({L1+0}^r/100)>=((V/100)+7)) and (({L1+0}^r/100)<=((V/100)+7)) and (({L1+2}^r/100)>=((V/100)-7)) and (({L1+2}^r/100)<=((V/100)-6)):{L1+4}^r+80->{L1+4}^r:{L1+6}^r+80->{L1+6}^r:1->T:(0-1)->U:5->N:0->G:End
.Bottom Left
If (N=0) and (({L1+0}^r/100)>=((V/100)-7)) and (({L1+0}^r/100)<=((V/100)-6)) and (({L1+2}^r/100)>=((V/100)+6)) and (({L1+2}^r/100)<=((V/100)+7)):{L1+4}^r+100->{L1+4}^r:{L1+6}^r+100->{L1+6}^r:(0-1)->T:1->U:5->N:End
.Bottom Right
If (N=0) and (({L1+0}^r/100)>=((V/100)+6)) and (({L1+0}^r/100)<=((V/100)+7)) and (({L1+2}^r/100)>=((V/100)+6)) and (({L1+2}^r/100)<=((V/100)+7)):{L1+4}^r+100->{L1+4}^r:{L1+6}^r+100->{L1+6}^r:1->T->U:5->N:End
.Top
If (N=0) and (({L1+0}^r/100)>=((V/100)-5)) and (({L1+0}^r/100)<=((V/100)+5)) and (({L1+2}^r/100)>=((V/100)-8)) and (({L1+2}^r/100)<=((V/100)-6)):{L1+6}^r+100->{L1+6}^r:(0-1)->U:5->N:0->G:End
.Left
If (N=0) and (({L1+0}^r/100)>=((V/100)-8)) and (({L1+0}^r/100)<=((V/100)-7)) and (({L1+2}^r/100)>=((V/100)-5)) and (({L1+2}^r/100)<=((V/100)+5)):{L1+4}^r+80->{L1+4}^r:5->N:If ({L1+2}^r>5500):(0-1)->U:{L1+6}^r+80->{L1+6}^r:{L1+4}^r+20->{L1+4}^r:End:End
.Right
If (N=0) and (({L1+0}^r/100)>=((V/100)+7)) and (({L1+0}^r/100)<=((V/100)+8)) and (({L1+2}^r/100)>=((V/100)-5)) and (({L1+2}^r/100)<=((V/100)+5)):{L1+4}^r+80->{L1+4}^r:5->N:If ({L1+2}^r>5500):(0-1)->U:{L1+6}^r+80->{L1+6}^r:{L1+4}^r+20->{L1+4}^r:End:End
.Bottom
If (N=0) and (({L1+0}^r/100)>=((V/100)-5)) and (({L1+0}^r/100)<=((V/100)+5)) and (({L1+2}^r/100)>=((V/100)+7)) and (({L1+2}^r/100)<=((V/100)+8)):1->U:G/5+{L1+6}^r/2+50->{L1+6}^r:0->G:End
.BORDERS
.Left
If ({L1+0}^r<100) or ({L1+0}^r>(0-1000)):100->{L1+0}^r:1->T:End
.Right
If ({L1+0}^r>8600):8600->{L1+0}^r:(0-1)->T:End
.Top
If ({L1+2}^r)<100):100->{L1+2}^r:1->U:({L1+6}^r/2)->{L1+6}^r:End
.Bottom
If ({L1+2}^r)>5600):5600->{L1+2}^r:(0-1)->U:((G/10)+{L1+6}^r)->{L1+6}^r:0->G:End
[/spoiler]

[spoiler=Program fpr gravity]..TRY07GRV
.Friction
If {L1+4}^r>50:{L1+4}^r+99/100->{L1+4}^r:Else:If {L1+4}^r<20:If (C/4+4)=C:{L1+4}^r*99/100->{L1+4}^r:End:Else:If (C/2+2)=C:{L1+4}^r*99/100->{L1+4}^r:End:End:End
.Slow down and speed up
If U=1:{L1+6}^r*102->{L1+6}^r:Else:{L1+6}^r*97->{L1+6}^r:End:{L1+6}^r/100->{L1+6}^r
.Add Gravity
G+3->G:G/10+{L1+2}^r->{L1+2}^r
[/spoiler]

Aaand explanations:
You're a square kicking arount a circle....
{L1+0}^r = X-pos ball
{L1+2}^r = Y-pos ball
{L1+4}^r = X-speed ball
{L1+6}^r = Y-Speed ball
T = Direction X-Movement ball (1 or -1)
U = Direction Y-Movement ball (1 or -1)
V = X-Pos player
W = Y-Pos player
C = Counter (add 1 each loop in main program so I can use it for executing stuff every 2 or every 4 rounds)
N = No-collide (counter for how many "rounds" it's gonna ignore colission stuff. To prevent trigering the colusion twice at once)
G = Gravitation (always rising and reset/changed by colissions)

Important: All graphic-related stuff is multiplied with 100... So I't wirking with a 9600x6400 screen and a Speed of 100 means 1px movement per round.
That's where all the /100 is coming from :)
[spoiler=Where the strange numbers in Colission come from]


These numbers seem a bit strange because it's actually the positions for the coliding object:
It's the top-left coordinates of an 8x8 image (the ball in this case) that collides with these zones (marked orange and green).
The darked boxes are the border of the player itself (just a square)

I used this for colission in order to bet the edges working well, too and also to prevent a colision from not being detected
(for example if the ball is faster than 1px/round and "jumps" inside the player)


I really hope you understand what I mean... :/


[/spoiler]


I plan on moving all teh vars inside L1, add a second player, add Goals and add the gravity for players, too (so you got a realistic jump isntead of just floating around).
Still It'll be a crappy game, but it's just for learning purposes not for being published or something ^^

Pls dont hate me for writing such crappy code - this is my first attempt after more than 4 years... :(

Edit: Fixed a typing mistake in Gravitation program... accidentally used '+' instead of '*' there...
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

c4ooo

#1
Alot to of code to correct everything, but here are some tips:

Axe has left to right order of operations;
{L1+0}^r+({L1+4}^r*T)->{L1+0}^r
can be
{L1+4}^r*T+{L1+0}^r->{L1+0}^r


0->G
.N=NotCollide to prevent double collision
0->N
.C=Counter
0->C

The above can just be 0->G->N->C

G+3->G:G/10+{L1+2}^r->{L1+2}^r
Can be
G+3->G:/10+{L1+2}^r->{L1+2}^r
If there is no var/number before the "/10", then it just uses the last value. (in this case G+3)

If U=1:{L1+6}^r+102->{L1+6}^r:Else:{L1+6}^r+97->{L1+6}^r:End
Can be

If U=1:102:Else:97:End
+{L1+6}^r->{L1+6}^r


This block:

If getKey(1) and (W<5600):W+100->W:End
.LeftArrowKey
If getKey(2) and (V>0):V-100->V:End
.RightArrowKey
If getKey(3) and (V<8600):V+100->V:End
.UpArrowKey
If getKey(4) and (W>0):W-100->W:End

Can be:

If W<5600 and getKey(1):W+100->W:End
If V>0 and getKey(2):V-100->V:End
If V<8600 and getKey(3):V+100->V:End
If  W>0 and getKey(4):W-100->W:End

which can further be optimized to:

W<5600 and andgetKey(1)-(W>0 and getKey(4))*100+W->W
V<8600 and getKey(3)-(V>0 and getKey(2))*100+V->V



Please not that some of this stuff has the possibility of being wrong so dont change everything at once ;)

Hayleia

1) Indentation.
If you're developing on-calc, it's obviously harder to do. zStart has a small font editor but I'd also understand that you avoid zStart or that editor.
So, do it if you can, and obviously don't if you can't.

2) Custom variables.
Instead of having a comment saying "L1{X,Y,vX,vY" then using a lot of these "{L1+__}^r", you could use custom variables.
How? Well just try that:

L1+00->°PosX
L1+02->°PosY
L1+04->°VX
L1+06->°VY

Then do stuff with PosX, PosY and others as if they were variables. Like 0->PosX, PosX++, etc. It works.
Your names can contain 13 characters max. That's enough for most uses.

3) Names in general.
Pic01, what is that supposed to mean? Well, if it's a sprite, having "Pic" in the name is better than having "Str", but still. I guess it's the ball's sprite. And same, Pic02 must be the Player's sprite. Well, then, try that:

...
...
[3C7EFFFFFFFF7E3C]->°BallSprite
[FF818181818181FF]->°PlayerSprite
...
...
Pt-On({L1+0}^r/100,{L1+2}^r/100,°BallSprite)
Pt-On(V/100,W/100,°PlayerSprite)
...
...

Same, 13 characters max.

4) Subprograms.
I'd say they should only be used as a compilation of subfunctions you didn't want to put in the main file (to save space or have less lines or whatever), but having them in a loop the way you did is a bad idea. You seem to think this works the same way as in basic, which is "there is no custom subfunctions but there are subprograms that are not pasted everytime". Well it's exactly the contrary, there are subfunctions in Axe and subprograms are pasted everytime.
To use a subfunctions, do like that:

.TOASTER
...
...
Add(3,4)->A
...
...
Return

Lbl Add
r1+r2
Return


5) Optimization.
Well, I'm not talking about that one. Readability is better for beginners.

p2

Quote from: c4ooo on August 24, 2016, 03:20:12 PM
G+3->G:G/10+{L1+2}^r->{L1+2}^r
Can be
G+3->G:/10+{L1+2}^r->{L1+2}^r
If there is no var/number before the "/10", then it just uses the last value. (in this case G+3)
Definitely gonna modify the whole code like this :D Thanks a lot!  :thumbsup:


Quote from: Hayleia on August 24, 2016, 03:30:02 PM
2) Custom variables.
Instead of having a comment saying "L1{X,Y,vX,vY" then using a lot of these "{L1+__}^r", you could use custom variables.
How? Well just try that:

L1+00->°PosX
L1+02->°PosY
L1+04->°VX
L1+06->°VY

Then do stuff with PosX, PosY and others as if they were variables. Like 0->PosX, PosX++, etc. It works.
Your names can contain 13 characters max. That's enough for most uses.

[3C7EFFFFFFFF7E3C]->°BallSprite
[FF818181818181FF]->°PlayerSprite
...
...
Pt-On({L1+0}^r/100,{L1+2}^r/100,°BallSprite)
Pt-On(V/100,W/100,°PlayerSprite)
...
...

Same, 13 characters max.
Okeyy these custom names are really cool :D I'll use them, too ^^ (Always got to add ° before the name, right? :)

But just in theory, let's say I wanted a second and a third ball added to the game...
Could I just do something like {100*Z+L1+2}^r and {100*Z+L1+4}^r and put it in a for(Z,0,2) or won't that work?
Because then it wouldn't always make sense for me to use custom variable names... ^^


Quote from: Hayleia on August 24, 2016, 03:30:02 PM
4) Subprograms.
I'd say they should only be used as a compilation of subfunctions you didn't want to put in the main file (to save space or have less lines or whatever), but having them in a loop the way you did is a bad idea. You seem to think this works the same way as in basic, which is "there is no custom subfunctions but there are subprograms that are not pasted everytime". Well it's exactly the contrary, there are subfunctions in Axe and subprograms are pasted everytime.
To use a subfunctions, do like that:

.TOASTER
...
...
Add(3,4)->A
...
...
Return

Lbl Add
r1+r2
Return

I guess this Add is an example for a subroutine... Do I have to give the variables as parameter or can it just access the vars, too?
That would be a problem since I'm gonna change a lot of stuff for example in the colission program (G, xPos, YPos, vX, vY, T, U)
Aaand do I need to add a "Return" too at the end of the subroutine as long as my subroutine shouldn't return a specific value but rather change a lot of vars...?


Quote from: Hayleia on August 24, 2016, 03:30:02 PM
5) Optimization.
Well, I'm not talking about that one. Readability is better for beginners.
Just show me some stuff and let's see how much I'll understand ;D Want to quickly learn everything again... >.>
*Thank you very much for your help!! :) :)
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

E37

L1+2->oNAME
NAME = {L1+2}r
You don't need the angle. You can use NAME exactly as a letter var. It is two bytes. The angle is only needed in declaration.
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

p2

So this is how it's done? :)
5->°SuperAwesome
3->A
A+SuperAwesome->A
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

E37

#6
SuperAwesome must be given a memory location at its declaration.
if you used your verson, 37->SuperAwesome would changes bytes 5 and 6 in ram.
if the variable was declared as L1->°SuperAwesome then 37-> SuperAwesome would set {L1}r to be 37.

What you are thinking of is a constant. Here is how to use them:
number->->°CONSTANT
creates a constant named CONSTANT and gives it the value number.
Disp °CONSTANT >dec
would display the value of the number. Note the angle sign!
Constants cannot be changed!
They do have the benefit of being the same size and speed of typing number in each time instead of constant. Axe simply replaces °CONSTANT with the number when it compiles.
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

p2

wooow, wait a sec *-*
{L1+2}^r->°xBallA
{L1+102}^r->°xBallB
{L1+202}^r->°xBallC
for(Z,0,2):{100*Z+L1+2}^r->A:Text(10,10*Z,A>Dec):end

This would actually work? It would display all three values?
So I can then access the stuff both by using the fancy name xBallA AND by using the momory position {L1+2}^r  O.O
I love this language... >.>
  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

E37

#8
Quote from: p2 on August 24, 2016, 05:26:02 PM
wooow, wait a sec *-*
{L1+2}^r->°xBallA
{L1+102}^r->°xBallB
{L1+202}^r->°xBallC
for(Z,0,2):{100*Z+L1+2}^r->A:Text(10,10*Z,A>Dec):end

This would actually work? It would display all three values?
So I can then access the stuff both by using the fancy name xBallA AND by using the momory position {L1+2}^r  O.O
I love this language... >.>
Woah, Woah, Woah! hang on a sec!
Custom variables need a MEMORY LOCATON not a number!
L1+102->°xBallB would be the correct way to declare it.
Disp xBallB={L1-102}r >Dec
should then always display true (1).
It needs a memory loction because, of course, you can't create memory. It needs a place to store its data.
edit: i'm not sure you can start a variable with a lowercase though...
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

Hayleia

Quote from: p2 on August 24, 2016, 04:28:16 PM
I guess this Add is an example for a subroutine... Do I have to give the variables as parameter or can it just access the vars, too?
That would be a problem since I'm gonna change a lot of stuff for example in the colission program (G, xPos, YPos, vX, vY, T, U)
Aaand do I need to add a "Return" too at the end of the subroutine as long as my subroutine shouldn't return a specific value but rather change a lot of vars...?
Yes it was a subroutine.
You never specify arguments in Axe. If there are any, they are r1,r2...r6.
So basically, Add(3,4,5) is the same as 3->r1:4->r2:5->r3:Add().
And the Return is the end of the subroutine. Even if it returns nothing, you must finish with a return.
And the same way G+3->G:/10 worked, the r1+r2:Return works.

E37

#10
As for modifying c4ooo code even further,
W<5600 and getKey(1)-(W>0 and getKey(4))*100+W->W
could be even further optimized to:
W<5600?getkey(1)-(W?getkey(4))*100+W->W //note that the question marks are there on purpose and that is a negative sign, not a minus.
Since Axe doesn't really do negative numbers, (that is up to you) W>0 could be changed to just number. since any nonzero number is greater than zero.
(there are negative commands but I don't really touch them since they aren't a lot of cases they are useful outside of physics engines and my physics engines are terrible)
The question mark means if the previous statement is true, continue. If it isn't skip the rest of the code and go the the next newline.

As for learning to program Axe I still find it helpful to program with a paper or electronic copy of the Axe command list nearby. http://axe.eeems.ca/Commands.html
Oh... by the way, your code isn't bad at all! It is heaps better than my first code! It took me weeks to grasp the concepts of how lists are structured.
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

p2

Quote from: E37 on August 24, 2016, 05:31:10 PM
Woah, Woah, Woah! hang on a sec!
Custom variables need a MEMORY LOCATON not a number!
L1+102->°xBallB would be the correct way to declare it.
Disp xBallB={L1-102}r >Dec
should then always display true (1).
It needs a memory loction because, of course, you can't create memory. It needs a place to store its data.
edit: i'm not sure you can start a variable with a lowercase though...
uh sorry my fault ^^
ok then this should work now? :)
L1+2->°xBallA
L1+102->°xBallB
L1+202->°xBallC
for(Z,0,2):{100*Z+L1+2}^r->A:Text(10,10*Z,A>Dec):end

L1+2 would be a memory position while {L1+2} would be the content of the byte 2 adresses after that same one, right?
and the ^r in the declaration (first 3 lines) isn't needed because as  basic integer is's using 2 Bytes by default, right? :)
If this is both correct, I understood how to do it ^.^

Quote from: E37 on August 24, 2016, 05:31:10 PMedit: i'm not sure you can start a variable with a lowercase though...
Does someone here know this? ^^



Quote from: Hayleia on August 24, 2016, 05:34:42 PM
And the Return is the end of the subroutine. Even if it returns nothing, you must finish with a return.
And the same way G+3->G:/10 worked, the r1+r2:Return works.

So this Subfunction DoStuff would actually do 5->A->Z:
...
...
DoStuff( )->Z
...
...
Return

Lbl DoStuff
5->A:Return


But this one would not return anything so be an error?
...
...
DoStuff( )->Z
...
...
Return

Lbl DoStuff
5->A
Return


Is it a problem if a called Subfunction returns some value but It's not used afterwards...?
Or is it optional to use the returned value, no matter if there is one or not?
Like this:
...
...
DoStuff( )
...
...
Return

Lbl DoStuff
5->A:Return

  • Calculators owned: ti-83+, ti-84+, ti-84+, ti-84+se, ti-84+se(te), ti-nsphire, ti-nsphire CAS, ti-nsphire CX-CAS, ti-voyage, ti-voyage, Who reads this list anyways...?
Anyway war sucks. Just bring us your food instead of missiles  :P ~ DJ Omnimaga (11.10.2016 20:21:48)
if you cant get a jframe set up, draw stuff to it, and receive input, i can only imagine how horrible your game code is _._   ~ c4ooo (14.11.2016 22:44:07)
If they pull a Harambe on me tell my family I love them ~ u/Pwntear37d (AssangeWatch /r/)
make Walrii great again ~ DJ Omnimaga (28.11.2016 23:01:31)
God invented the pc, satan the smartphone I guess ~ p4nix (16.02.2017 22:51:49)

Hayleia

Quote from: p2 on August 24, 2016, 05:51:15 PM
So this Subfunction DoStuff would actually do 5->A->Z:
...
...
DoStuff( )->Z
...
...
Return

Lbl DoStuff
5->A:Return


But this one would not return anything so be an error?
...
...
DoStuff( )->Z
...
...
Return

Lbl DoStuff
5->A
Return

They are exactly the same. A new line or a ":" is the same thing.
You can even write something after the return if you want (and it can be useful in some cases). Like

...
...
Lbl Stuffs
r1*r2->r5
r3*r4->r6
Return r5+r6
...
...

Well yeah, not so useful here, but you see what I mean.

Quote from: p2 on August 24, 2016, 05:51:15 PM
Is it a problem if a called Subfunction returns some value but It's not used afterwards...?
Or is it optional to use the returned value, no matter if there is one or not?
There is something you didn't get about Axe. Every single thing "returns" something.
Example that seems unrelated but helps you understand Axe better.

A+3*3->B


A
+3
*3
->B

These codes do the same thing.
So as long as your subfunction (that we call "routine actually") has code, it will return something, even if you don't care and don't do anything with its return value.
And that's how you end up writing code that doesn't use any variable (@matref involved too) :P

c4ooo

" As for modifying c4ooo code even further,
W<5600 and getKey(1)-(W>0 and getKey(4))*100+W->W
could be even further optimized to:
W<5600?getkey(1)-(W?getkey(4))*100+W->W //note that the question marks are there on purpose and that is a negative sign, not a minus."

Don't think that will work @E37  If W>5600, then everything past the "?" will simply be ignored, which we don't want. In the second case it might work, but it is unnecessary. Also you can't dojust do "W?"; that will only be true if W is non zero, and a negative number is non zero. However " W>0" won't work either because ">" is unsigned comparison. You would have to do "W>>0". (So -1>0 in axe would return true)

E37

#14
You got it!
Subroutines don't need to return anything.
They can just hold code. They will always return the result of the last line of code. Nobody said you had to do anything with it.
You nailed memory locations on the head.
Thanks c4ooo, my mind seemed to edit in an if at the beginning.
You don't need the greater than zero c4ooo it is unsigned.
  • Consoles, mobile devices and vintage computers owned: Ti83,Ti84!
I've never finished a project, there is always a way to improve!
What's my calc's name? Convert $37 to decimal. Look up that element in the periodic table. Then take the abbreviation of that element and you have it!
Look! A slime!    <(^.^)>

Powered by EzPortal