Remember that the row that starts with the Math key corresponds with the top of the screen, and pressing any button above that (as demonstrated in the video) will just draw a line at the top of the screen.

The only annoying thing is those dots that appear every time a line finishes drawing, but that should be easy enough to fix.
Edit: dots are fixed! The pastebin has been updated, but I can't upload an updated file just yet for reasons explained below.

Feel free to use this for your own purposes as long as you give me credit. If you don't want the fruit ninja background, either replace line 7 with your own appvar pic or delete lines 7,8 and 9.

Download here (If you just want the program without the background pic, that's here), code here.


The original post is below.

--

Download here

If you can't download that for whatever reason, the code as text is here; tell me if you see any optimizations! (besides not using ClrHome; I'm currently figuring out how to erase the lines. ʟFRNP will be used for that)

For those wondering how it works:
You may have noticed that the TI-OS's getKey command maps keys by row, then column. Using the ᴇ, iPart() and fPart() commands, the program extracts those row/column values, multiplies them to make them usable on the screen, and uses the multiplied column value/multiplied row value as X/Y coords to draw the line.

The example in the video uses xLIBC to draw the lines , but I have one that just moves an O around on the homescreen using pure TI-BASIC; that can be found here. (code here)

By the way, does that video look familiar? If so, it's because it's an attempt to clone the control scheme of Deep Thought's Fruit Ninja... so no guarantees, but we might be seeing Fruit Ninja on the CSE soon if I can figure out how to make it fast enough.
Or Swype functionality could be added... just saying. It could be an overlay to the current app, and provide input for the selected letter to a list. You could convert the list to a string, and then you could output the string and display it in a text box of some sorts.

That would be cool, seeing I'm the only person that I know (locally) that took the time to memorize the positions of the keys on the actual keyboard...
Oh, and if you press the right button, the program glitches out. I think I personally might add Swype functionality or a demo to my apps (with your permission, of course).
Looks great! The control scheme appears to work really well.
solarsoftware wrote:
Or Swype functionality could be added... just saying. It could be an overlay to the current app, and provide input for the selected letter to a list. You could convert the list to a string, and then you could output the string and display it in a text box of some sorts.

That would be cool, seeing I'm the only person that I know (locally) that took the time to memorize the positions of the keys on the actual keyboard...

solarsoftware wrote:
Oh, and if you press the right button, the program glitches out. I think I personally might add Swype functionality or a demo to my apps (with your permission, of course).


Oh, I thought I'd fixed that. It's an easy fix, actually; fine the line that says If B<25 and change it to If B<6 (I've already reuploaded the file to dropbox so you can just redownload that).
And go ahead with the Swype thing, I'd love to see that!

tr1p1ea wrote:
Looks great! The control scheme appears to work really well.

thanks Smile

--

I'm having issues trying to remove ClrHome from the program and just erasing/inverting the lines instead. Will post code snippets in a bit...
That looks really nice from the video! By the way, thanks for taking a video of it on jsTIfied right after I added the feature that highlights which buttons are being pressed. I think it would have been a lot less interesting and clear of a video had that feature not just been added. Wink I look forward to seeing how this project evolves.
I just thought of a new RPG/action gameplay using this control scheme. Mind if I use it if I end up making the RPG?
Unicorn wrote:
I just thought of a new RPG/action gameplay using this control scheme. Mind if I use it if I end up making the RPG?


Not at all, go ahead!

KermMartian wrote:
That looks really nice from the video! By the way, thanks for taking a video of it on jsTIfied right after I added the feature that highlights which buttons are being pressed. I think it would have been a lot less interesting and clear of a video had that feature not just been added. Wink I look forward to seeing how this project evolves.


Thank you! I actually think this has potential to turn into a full-fledged Fruit Ninja game, which is amazing. Plus, it's so versatile that there's a lot more that can be done with it, beyond games even!
And yeah, I was wondering how I was going to record keypresses, then I remembered that jsTIfied highlights keys Razz So thanks for putting that feature in, too!

M. I. Wright wrote:
I'm having issues trying to remove ClrHome from the program and just erasing/inverting the lines instead. Will post code snippets in a bit...


...never mind! My code was throwing an ERROR:UNDEFINED because I was apparently storing values to lists without realizing it, then attempting to call them as variables; I've fixed that now, though. I'm now working on making it erase the lines completely, which is hopefully going well (it's currently glitching out with the line coordinates but I'm 90% sure it's just a byproduct of the fact that I haven't finished it yet)


I'll publish the line-drawing/erasing code here once I get it figured out.


...I still haven't fixed the lines but here's an awesome background that I totally didn't just spend half an hour making!
Wow, just like totally haven't spent the last half hour making a new website when I should be working on an email to someone. Razz
Gahhhh.

Alright, so for the third time, I've managed to- wait for it...



...make it erase the last segment of a line you drew.

And it doesn't even work all the time.

If I can't fix it by next Friday or so, I'm honestly thinking of just scrapping the whole integer compression thing I had going and opting for a simpler route at the cost of using up more space; it wouldn't be as small, sure, but it would be a hell of a lot faster and easier for me to work with.
Basically, what I'm doing is trying to store the X0,Y0,X1,Y1 values of a line in a single list element using compression (so it ends up as X0Y0X1Y1). This works, as far as I can tell, but the way I have it set up to iterate through the list is working absolutely terribly.

actually, I could probably use the seq( command... why the hell didn't I think of that? brb
edit: preliminary research shows that that's probably not how seq( works, so nope

(also here's the code if anyone else can fix what I've done:

Code:

Real
ClrHome
SetUpEditor |LFRNP
0->dim(|LFRNP
real(0,1,1
"This comment is here so that syntax highlighting will work
"FRNBG
real(5,2,1
real(5,2,1
1->A:1->B:1->R:1->C:0->Q
Repeat K=22
getKey->K
If E>0 and Q:Then
~1->E
1(F<dim(|LFRNP)-1(F>dim(|LFRNP->G
For(F,dim(|LFRNP)-1,0,G+(G=0
|LFRNP(dim(|LFRNP)-F
iPart(Ans/|E9->M
|LFRNP(dim(|LFRNP)-F
iPart(|E3fPart(Ans/|E9->N
|LFRNP(dim(|LFRNP)-F
iPart(|E3fPart(Ans/|E6->O
|LFRNP(dim(|LFRNP)-F
|E3fPart(Ans/|E3->P
real(7,6,N,M,O,P,1
real(7,6,N,M,O,P,1
If N!=O and M!=P:Then
real(7,6,O,P,N,M,1
real(7,6,O,P,N,M,1
real(7,6,N,M,O,P,1
real(7,6,N,M,O,P,1
End
End
~1->E
0->Q
End
If K:Then
(20(iPart(.1K)-3))-15->A
(32(10fPart(.1K)))-16->B
If E>=0:Then
0->dim(|LFRNP
dim(|LFRNP)+1
Ans->F
real(7,6,C,R,B,A,1
real(7,6,C,R,B,A,1
|E9(A+(|E6(B+(|E3(C+R/|E3))/|E6))/|E9->|LFRNP(F
A->R:B->C
real(7,6,C,R,B,A,1
real(7,6,C,R,B,A,1
End
1->Q
If E<0
startTmr->D
checkTmr(D->E
End
End
Archive |LFRNP
ClrHome
In case you didn't get my message last night, i would thoroughly recommend using the hardware's timer as a means to getting the specific time you want outputted.

See back in digital electronics, electronic signals would often be displayed based upon the ticks or frequency of the hardware clocks that was built in. There is a small delay of time hardware takes in order to execute a loop of say

Code:

:Prompt N
:Lbl Start
:n+1
:If n>720 Then GOTO end
:Goto Start
:Lbl End
:Stop


You could exploit this by measuring how long it takes to complete this loop to a desired time length thus presenting you with a hardware based timer. You may have to test it a few times to get the time length you want but in the end, you will get a very accurate timer.
Let me help you learn some optimization for TI-BASIC! First pass: flip your conditional to remove an unnecessary Goto and Lbl:
Code:
:Prompt N
:Lbl Start
:n+1
:If n<=720 Then Goto Start
:Stop
Second pass: use a While, Repeat, or For loop (any of those three would work here):
Code:
:Prompt N
:Repeat N>720
:n+1
:End
:Stop
Third pass: Make it valid TI-BASIC:
Code:
:Prompt N
:Repeat N>720
:N+1->N
:End
:Return
It wooooorks!


Remember that the row that starts with the Math key corresponds with the top of the screen, and pressing any button above that (as demonstrated in the video) will just draw a line at the top of the screen.

The only annoying thing is those dots that appear every time a line finishes drawing, but that should be easy enough to fix.

Feel free to use this for your own purposes as long as you give me credit. If you don't want the fruit ninja background, either replace line 7 with your own appvar pic or delete lines 7,8 and 9.

Download here (If you just want the program without the background pic, that's here), code here.

Basically, instead of entirely doing away with integer compression, I just made it a bit less compressed, using two lists instead of one (or four!) to store coordinates. Basically it's X0.X1 in one list and Y0.Y1 in the other (that's X0+X1/1000 and Y0+Y1/1000) and it iterates through the lists with a For( loop... now to go figure out how I'm supposed to make this thing move sprites around.

Jouster500 wrote:


Code:

:Prompt N
:Lbl Start
:n+1
:If n>720 Then GOTO end
:Goto Start
:Lbl End
:Stop


You could exploit this by measuring how long it takes to complete this loop to a desired time length thus presenting you with a hardware based timer. You may have to test it a few times to get the time length you want but in the end, you will get a very accurate timer.

While this is a valid and useful technique, it would not work for this program because I need user input to take place while the timer is running. As such, startTmr and checkTmr are really the only ways I can do the time detection. Thank you, though!
Can this code be made to look for certain combinations of keys? For example, if I swipe bottom left to top right it displays a: Great Job!
Unicorn wrote:
Can this code be made to look for certain combinations of keys? For example, if I swipe bottom left to top right it displays a: Great Job!


It theoretically could, but if that's all you want to do then using this code would be pretty inefficient. Instead, you could do something like this

Code:

ClrHome
0->A
Repeat A=2
getKey->K
10fPart(.1K
If Ans>3 and not(A
Then
iPart(.1K
If Ans>8
A+1->A
End
If Ans<3 and Ans and A:Then
iPart(.1K
If Ans<6 and Ans
A+1->A
End
End
Disp "Great Job!

Could probably be optimized more, but you get the gist of it.

Edit: of course, if you want to actually include swiping/line-drawing while detecting for bottom-left to top-right swiping, you could add this to the program right after the line that reads If K:Then --


Code:

10fPart(.1K
If Ans>3 and not(Z
Then
iPart(.1K
If Ans>8
1->Z
End
If Ans<3 and Ans and Z:Then
iPart(.1K
If Ans<6 and Ans:Then
"GREAT JOB!
real(6,0,0,15,0,47,1
real(6,0,0,15,0,47,1
End
End
Oh, this is pretty neat M. I. Wright! Smile Are you thinking of making a fruit-ninja like game, or is this more of a demo? Anywho, great work, it looks to me like it functions pretty well!
So I kinda-sorta got a working fruit-type thing (on Friday, actually), but there are three problems with it as of now:

1. it slows down the game so user input lags even more than it was already. Adding more fruits and using actual fruit sprites would make it even worse. Is there a faster way to do this?
Edit: pay no attention to this, it makes no sense and isn't what I was doing

Code:

Repeat K=11
If N>=O:Then
randInt(100,180->O
0->Y
End
getKey->K
[code for line erasing]
If
If K:Then
[code for line drawing]
End
O-E2sin(Y->N
real(7,4,X,O-E2sin(Y),3,1
real(7,4,X,O-E2sin(Y),3,1
real(7,4,X,O-E2sin(Y),3,1
real(7,4,X,O-E2sin(Y),3,1
Y+.2->Y
X+Z->X
End


2. It looks terrible. I'm probably using xLIBC wrong, but the sprite constantly flickers.

3. In an attempt to make the game faster, I tried storing the coordinates of the lines in xLIBC's uservars. This should have functioned exactly the same as using TIOS variables, but I messed something up and now line erasing is completely screwed.
Welp, I haven't done anything on this in a while, but I got a decently fast-ish version with 'fruit' working! I don't think the speed at which it travels is quite right, but it's good enough for a test.
Download here.
Still dunno if it's gonna be this fast with actual fruit sprites. Fingers crossed for now.
I downloaded your program SWIPE and I looked in it and I saw the line:
"FRNBG
I assume this stands for FRuit Ninja BackGround. Is this Appvar available too?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 3
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement