Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Munchor on March 22, 2011, 05:43:37 pm
-
I've been working on a few things have the following questions:
1. How to write white text in black background? So if I have Rect(0,96,96,64 and then want to use Text( and make it white over dark background. How can I do it? I can't DrawInv everything by the way.
2. I have 2 pictures (two FFFFFFFFFFFFFFFF Pics) and I want to check collision between them, I have (X,Y) for the upper left corner of one of them and (A,B) for the upper left corner of the other one. How can I make them both stop when they collide with each other. So, if one hits the other, they'll both block, collide and can't move unless if they turn around. Thanks.
Notes: I'm not using the x256 mode (I never use/used it). Thanks
-
1] Use one of the 'Fix' commands.
.TEST
ClrDraw
DrawInv
Fix 3
Text(10,10,"Hello World")
Text(10,20,"More Text")
Dispgraph
Repeat getKey(15)
End
Fix 4
.Don't forget to call Fix 4 to return the text to normal.
2.
If you want to use only the coordinates provided, try measuring the X and Y distance between the two points. If both distances are less then or equal to 8 (or perhaps 7 or 9, tweaking needed), then you know that they collided. Making them stop depends on how you implemented your physics.
-
Remember, with all the fix commands, though, you should switch it back at the end, otherwise the OS will be messed up. It doesn't matter so much on some, but it does on others.
-
Concerning the Fix command, thanks but I still have a problem:
Fix 3
Text(0,10,"TITLE
Fix 4
The thing is, it's gray on black background :S
Thanks.
EDIT: It's not gray but it's constantly rewriting itself, it's in a loop, but still :S
EDIT 2:
Concerning collision,
I can check their distances, but is their a simpler method, using pxl-Test, etc.?
-
Concerning the Fix command, thanks but I still have a problem:
Fix 3
Text(0,10,"TITLE
Fix 4
The thing is, it's gray on black background :S
Thanks.
EDIT: It's not gray but it's constantly rewriting itself, it's in a loop, but still :S
Did you add 'Fix 5' to the start of the program so that text is drawn to the buffer? Because if you didn't, it drew to the screen directly, and will probably keep redrawing itself to the screen every time you repeat that command, and that causes flickering/is very slow.
-
@Michael: You're a god.
ClrDraw
Fix 5
Repeat getKey(15)
Fix 3
Text(0,0,"TEXT
Fix 2
DispGraph
End
Fix 4
Thanks :)
-
@Michael: You're a god.
ClrDraw
Fix 5
Repeat getKey(15)
Fix 3
Text(0,0,"TEXT
Fix 2
DispGraph
End
Fix 4
Thanks :)
okay, so you can use multiple Fix commands at once?
also, I find this kinda funny since you're the one who wrote that awesome Fix tutorial. :P
-
@Michael: You're a god.
ClrDraw
Fix 5
Repeat getKey(15)
Fix 3
Text(0,0,"TEXT
Fix 2
DispGraph
End
Fix 4
Thanks :)
okay, so you can use multiple Fix commands at once?
also, I find this kinda funny since you're the one who wrote that awesome Fix tutorial. :P
It's fun lol, I forgot about the fixes.
-
How do you shake the screen in Axe?
Or am I being a donk and there's a command for it?
-
How do you shake the screen in Axe?
Or am I being a donk and there's a command for it?
I think you could run a loop through all pixels and move them left (Pxl-On, Pxl-Test) but that sounds too much work, any simpler ideas?
-
Use a bunch of Horizontal/Vertical commands?
The only bad thing is that the edges will then be pure-white/pure-black, so you'd have to redraw the screen after all the shaking if you were worried about graphics.
I'm also interested in knowing if there's a better way then using Horizontal/Vertical.
-
Use a bunch of Horizontal/Vertical commands?
The only bad thing is that the edges will then be pure-white/pure-black, so you'd have to redraw the screen after all the shaking if you were worried about graphics.
I'm also interested in knowing if there's a better way then using Horizontal/Vertical.
Horizontal -/Vertical- (+, ++, etc) seems way better than my idea as a start.
-
for(...)
horizontal+
dispgraph
Horizontal-
dispgraph
end
like that?
Edit: double ninja'd
-
The "proper" way to shake the screen is with the z-addressing feature of the display driver. However, Axe does not have a command for this. With a little bit of assembly, I used z-addressing in my otherwise entirely Axe crazy tunnel (http://ourl.ca/9322/177233). You could use z-addressing with something like:
Zsub(Z)
Lbl Z
Asm(147DE63FF640D310)
Return
The input would be taken mod 64 and then applied as the screen's z-address. A z-address of 0 would mean the screen is in its normal state, and for every increase by 1, the screen would be shifted down 1 pixel. Pixels that are shifted off the bottom of the screen wrap around back to the top. This doesn't change the buffer data at all, it just changes how it is mapped to the display.
-
GOD.
I need to learn effin' ASM.
>:\
-
Yeah what Runer112 suggested is kinda what Reuben Quest and ROL2 used for earthquake effects.
HOWEVER, keep in mind this doesn't work on the TI-Nspire (it will do nothing) and will not work all the time on WabbitEmu.
-
How do you do collision detection with sprites in Axe?
-
In a monochrome map. You can store the "physical" objects in both buffers. Then you can check if there is a pxl on the back buffer at the spot you are moving to.
-
How do you do collision detection with sprites in Axe?
To detect if two 8x8 sprites are colliding, simple do
If abs(X1-X2)<8 && (abs(Y1-Y2)<8
I'm sure it could be optimized, but its just a demonstration :P
-
How do you test for an enemy or a wall?
Can you distinguish the two pixels?
EDIT: Oh wait. I'm an idiot.
-
Can someone explain what and, or, and xor do in axe?
Not in If statements, but otherwise. It's not very descriptive in the commands list :P
-
It is the exact same thing though. (methinks)
If you and it, the outcome will be 1 iff both inputs are 1.
If you or it, the outcome will be 1 iff any of the inputs are 1.
If you xor it, the outcome will be 1 iff only one input is 1.
Although I might be completely wrong.
Note: for those who may not know, in the us, "iff" stands for, "If and only if"
-
By the way, I think a few people have gotten confused a bit. This is not the general Axe Q&A thread, this is just a thread that Scout started to ask a few specific questions for his program. If you want to ask short questions, in the future it would probably be better to ask them in the general Axe Q&A (http://ourl.ca/9165) thread made for this purpose.
Can someone explain what and, or, and xor do in axe?
Not in If statements, but otherwise. It's not very descriptive in the commands list :P
I think Wikipedia (http://en.wikipedia.org/wiki/Bitwise_operation#Bitwise_operators) can explain the bitwise operations better than I can. The examples they give are for 4-bit numbers, whereas Axe uses 16-bit numbers. The and, or, xor, and not() commands only operate on the low 8 bits (the high 8 bits will simply be copied from one of the arguments). The ยท, ?, ?, and not()r commands perform the operation on the full 16 bits.
-
Runer, I'm afraid I'm not very comfortable with the Axe Q&A topic, since a lot of people are asking questions in the same thread :S
I have one more question:
3. How to get arguments in a label that is a subroutine. I want to call it like sub(DW,"HEY",1 and in the Lbl DW I want to get the arguments. Thanks.
-
Runer, I'm afraid I'm not very comfortable with the Axe Q&A topic, since a lot of people are asking questions in the same thread :S
I have one more question:
3. How to get arguments in a label that is a subroutine. I want to call it like sub(DW,"HEY",1 and in the Lbl DW I want to get the arguments. Thanks.
r1 is the first argument, r2 is the second, etc. They're all accessed from VARS > Y-VARS > 3:Polar....
-
Runer, I'm afraid I'm not very comfortable with the Axe Q&A topic, since a lot of people are asking questions in the same thread :S
I have one more question:
3. How to get arguments in a label that is a subroutine. I want to call it like sub(DW,"HEY",1 and in the Lbl DW I want to get the arguments. Thanks.
r1 is the first argument, r2 is the second, etc. They're all accessed from VARS > Y-VARS > 3:Polar....
Woooh thanks seems good help :)
-
Btw, it's all in the documentation (commands.html) ;)
-
Yeah Deep, thanks.
I have a new question now, is there any way I can extend r1-r6 to 37?
-
Yeah Deep, thanks.
I have a new question now, is there any way I can extend r1-r6 to 37?
37? What do you mean?
If you mean r7, nope, there's a max of 6 args. When would you use 7?
You can always pass more args as variables, though.
-
meh... Somehow, I managed to forget how to display a grayscale sprite :(
anyone?
-
What was in this post has been removed since I found a way to get through it.
EDIT:
How to optimize this?:
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5
I made it with a For( loop or nested For( loops, and I did it! I really did, but I lost the source code (deleted it in Doors CS7 by mistake) and rewrote 900bytes of code (phew) but can't remember how to make a cross with a loop... I can't make it now (even though I did it before).
Thanks.
-
meh... Somehow, I managed to forget how to display a grayscale sprite :(
anyone?
You need to have the sprite stored as two 8x8 sprites (one for the front buffer, one for the back). Then use Pt-On() to display the first one and Pt-On()r to display the second.
Whatever's black on the buffer is black on the screen; whatever's white on the buffer and black on the back-buffer is gray on the screen; whatever's white on both buffers is white.
What was in this post has been removed since I found a way to get through it.
EDIT:
How to optimize this?:
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5
I made it with a For( loop or nested For( loops, and I did it! I really did, but I lost the source code (deleted it in Doors CS7 by mistake) and rewrote 900bytes of code (phew) but can't remember how to make a cross with a loop... I can't make it now (even though I did it before).
Thanks.
Use a sprite? That makes it several times smaller.
-
How to optimize this?:
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5
Pixel method: 117 bytes not counting the pixel routine, 158 bytes with it; 2853 cycles
Pt-On(88,0,[0022140814220000])
Aligned sprite method: 24 bytes not counting the sprite routine, 150 bytes with it; 918 cycles
-
How to optimize this?:
Pxl-On(90,1
Pxl-On(91,2
Pxl-On(92,3
Pxl-On(93,2
Pxl-On(94,1
Pxl-On(90,5
Pxl-On(91,4
Pxl-On(93,4
Pxl-On(94,5
Pixel method: 117 bytes not counting the pixel routine, 158 bytes with it; 2853 cycles
Pt-On(88,0,[0022140814220000])
Aligned sprite method: 24 bytes not counting the sprite routine, 150 bytes with it; 918 cycles
But it's supposed to be Pxl-Off( so how do I make the sprite White?
-
Pt-change(80,0,[FFFFFFFFFFFFFFF])
Pt-Change(88,0,[0022140814220000])
I think that would work
-
Pt-change(80,0,[FFFFFFFFFFFFFFF])
Pt-Change(88,0,[0022140814220000])
I think that would work
Hum, all I needed was Pt-Change(88,0,[0022140814220000])
Thanks, I had used Pt-On( before.
-
/me slaps himself awake.
Opps, thanks scout.
-
/me slaps himself awake.
Opps, thanks scout.
No! I have to thank you, you helped me :P
-
How do you shift one row on the buffer to the right or the left? Just one row, not like horizontal whwere it shifts the entire screen.
-
Not easily/efficiently in Axe code. I believe this would do it though. This can also be easily modified to work with buffers besides L6 if you need that.
.Example call
63sub(SRL)
.Shift Row Left
Lbl SRL
Asm(140140937DE6C0B4C02C7D87856F292909060C2BCB1610FBC9)
.Shift Row Right
Lbl SRR
Asm(140140937DE6C0B4C07D87856F292909060C2BCB1E10FBC9)