• Axe Q&A 5 5
Currently:  

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

0 Members and 2 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 #225 on: April 18, 2011, 11:01:26 am »
rand^n generates a random number from 0 to N-1.

and you can have Lbl B and variable B and the program will have no issue :)

How to make border-line rectangles? I really need this.

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 #226 on: April 18, 2011, 11:15:27 am »
You can use rectI() (inverted rectangle) to make all sorts of fun effects.  To make a white rectangle with black borders, simply draw a black rectangle and then an inverted one that is inside of it

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #227 on: April 18, 2011, 11:36:42 am »
You can use rectI() (inverted rectangle) to make all sorts of fun effects.  To make a white rectangle with black borders, simply draw a black rectangle and then an inverted one that is inside of it

Sweet, thanks.

Thanks a lot Builderboy, all this help has been wonderful.

I have a new question.

This isn't really an Axe question, this is more like problem solving.

I have a part of the screen where the main sprite can't enter (X>=78 and Y<=9). So, if X>=71 or Y<=9 all the getkeys should be disabled (71 cos the sprite is 7 pixels width).

I tried this:

Code: [Select]
If Y>=9 or (X<=71
//All getKeys code
End

However, when Y=9 or X=71, the sprite can't move.

So I though, when Y=9 and X=71, it can only walk left or down. It didn't work.

How can I only let the player move when (Y<=9 and X>=71) is false. I have to let the user move but not inside the forbidden area.

Thanks

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Q&A
« Reply #228 on: April 18, 2011, 11:39:27 am »
You should use:
Code: [Select]
if getkey(keycode)                         
If x/y (any) != (max/min for x/y value)   ; choose the fitting one
x/y(any) +/-1 ->x/y                           ; idem
end
I'm not a nerd but I pretend:

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #229 on: April 18, 2011, 12:06:25 pm »
You should use:
Code: [Select]
if getkey(keycode)                         
If x/y (any) != (max/min for x/y value)   ; choose the fitting one
x/y(any) +/-1 ->x/y                           ; idem
end

Code: [Select]
If getKey(1)
If X/Y != 71/9
X/Y +1 ->X/Y
End

I don't get the third line at all. What is +1/-1. Also, is there a way to make it global?

Thanks
« Last Edit: April 18, 2011, 04:55:26 pm by Scout »

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #230 on: April 19, 2011, 04:55:17 am »
*Double Post Alert*

I have another question, how can I have sprite so that if it touches the left and right border of the screen it appears on the other side.
For now it disappears for a while and then reappears on the other side after a while, but it's X/Y positions are crazy and it don't work.

Thanks.

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Q&A
« Reply #231 on: April 19, 2011, 08:08:26 am »
This code works. I made and tested it myself 1 minute ago on your request ;)
Code: [Select]
.SCROLLJP ;Scroll-Jump :P
0→X
20→Y
Repeat getkey(15)
ClrDraw
If getKey(2)
X+1→X    ;that cool arrow do you type with left-alt + 2 6
End
If getKey(3)
X-1→X
End
Pt-On(X,Y,[FF818181818181FF])
If X>88
Pt-On(X-96,Y,[FF818181818181FF])
End
If X=96
0→X
End
If X=666
Disp "The Game",imaginary i,"Never Gonna Give You up"   ; Could not resist xD
If X≤65535
Pt-On(X+96,Y,[FF818181818181FF])
End
If X=65528
88→X
End
DispGraph
End
Return
Just change the sprites to the ones you need.
« Last Edit: April 19, 2011, 08:08:50 am by aeTIos »
I'm not a nerd but I pretend:

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #232 on: April 19, 2011, 10:59:52 am »
My getkeys file:

Code: [Select]
:..GETKEYS
:DispGraphClrDraw
:If getKey(1) and (Y<59
:Y+2→Y
:End
:If getKey(2)
:X-2→X
:End
:If X>88
:Pt-On(X-96,Y,[FE44381000000000
:End
:If X=96
:0→X
:End
:If getKey(3)
:X+2→X
:End
:If X≤65535
:Pt-On(X+96,Y,[FE44381000000000
:End
:If X=65528
:88→X
:End
:If getKey(4) and (Y>8
:Y-2→Y
:End

My screenshot:


Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe Q&A
« Reply #233 on: April 19, 2011, 11:02:16 am »
Try to find the bug with "text(0,0,X>Dec.
I'm not a nerd but I pretend:

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #234 on: April 19, 2011, 11:09:13 am »
@aeTIos: I don't need it to be smooth =D

Here's my new and working code:

Code: [Select]
:..GETKEYS
:DispGraphClrDraw
:If getKey(1) and (Y<59
:Y+2→Y
:End
:If getKey(2)
:X-2→X
:End
:If X=96
:0→X
:End
:If getKey(3)
:X+2→X
:End
:If X=0
:88→X
:End
:If getKey(4) and (Y>8
:Y-2→Y
:End

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe Q&A
« Reply #235 on: April 24, 2011, 09:33:27 am »
I know how rand works more or less...

Code: [Select]
rand^n
.THIS GENERATES A RANDOM NUMBER UP TO N-1

So how to get numbers between n and m? I know we can do it with rand somehow, but can't remember how.

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 #236 on: April 24, 2011, 11:06:38 am »
Think about it:

rand generates a number between 0 and 255. When you do a modulus (rand^12, for instance), you're taking that number between 0 and 255 and taking its remainder when it's divided by 12, which is always between 0 and 11. It's all just arithmetic after that.

If you add thirty (rand^12+30), you get a number between 30 and 41. If you multiply by two instead (rand^12*2), you get a number between 0 and 22 that's a multiple of 2. No fancy tricks; it's all just math.




Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Axe Q&A
« Reply #237 on: April 24, 2011, 03:59:29 pm »
Think about it:

rand generates a number between 0 and 255.

Rand returns a 2 byte number i think,
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Axe Q&A
« Reply #238 on: April 24, 2011, 06:06:32 pm »
Code: [Select]
Lbl RAN
    ...
    Returns a random number from r1 to r2, excluding r2.
    r3 is the increment.
    ...
    r2-r1/r3
    rand^
    *r3+r1
Return

I think that works?
« Last Edit: April 24, 2011, 06:06:43 pm by Michael_Lee »
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 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 #239 on: April 24, 2011, 06:12:18 pm »
Code: [Select]
Lbl RAN
    ...
    Returns a random number from r1 to r2, excluding r2.
    r3 is the increment.
    ...
    r2-r1/r3
    rand^
    *r3+r1
Return

I think that works?
You'll have to put the second argument to the ^ operator after it (the omission trick only works for the first argument of an operator)
rand^(r2-r1/r3)
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman