This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
United-TI Archives -> TI-Basic
 
    » Goto page Previous  1, 2
» View previous topic :: View next topic  
Author Message
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 02 Jun 2009 07:08:41 pm    Post subject:

woodswolf wrote:
When considering randInt(A,B,C
rand can do exactly the same
A+int(Brand(C
Careful; you can't just carry over the variables directly like that. Change it to A+int((B-A+1)rand(C, and then simplify. But also make sure that you're truly saving space in the process. (Unless A=0, it's unlikely that you are.)

ztrumpet wrote:
max(K={24,25,26,34
I see this all too often. It's better to go with K=34 or 1[font="verdana"]≥abs(K-25 – smaller and faster.

ztrumpet wrote:
max(K={21,22 is smaller than .5=abs(K-21.5 )
Yes, but it's slower than K=21 or K=22, and larger than not(iPart(K-7[font="times new roman"]π.

dxfan101010 wrote:
i NEVER THOUGHT there was a 3rd argument for randint
If you don't have the inch-thick 83+ programming guidebook by Texas Instruments, try the wiki. It's good to assume that there's a new way to use a function that you're already familiar with (and for beginners, a function that you haven't already heard about).

dxfan101010 wrote:
For(X,1,3)
1+L1(X/->/L1(X
End
ztrumpet has the right idea about using both a row list and a column list, e.g., Output(L1(A),L2(A),">"). If, in general, you want to add to the first N values of a list on the fly, you can use N[font="verdana"]≥cumSum(binomcdf(dim(L1)-1,0. Make the appropriate substitutions if the dimension of the list or the range of values to be added are rigid, and then simplify.

Last edited by Guest on 11 Jul 2010 03:11:56 pm; edited 1 time in total
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 02 Jun 2009 07:37:18 pm    Post subject:

Weregoose wrote:
If you don't have the inch-thick 83+ programming guidebook by Texas Instruments, try the wiki. It's good to assume that there's a new way to use a function that you're already familiar with (and for beginners, a function that you haven't already heard about).

I do i Just couldnt find it and This. is on my favorites because i use it alot

I "finished" making the astroids move around Right now its in another program b/c i havent figured out where i want to put it the next then i have to figure out is how to tell if the laser hits the astroid and then take that element out of the list.

Code:
randint(1,8,5/->/L1
randint(1,16,5/->/L2
Repeat Y=100 // This makes it go b/c i dont know what condition i am going to use
For(X,1,5)
Output(L1(X),L2(X),"O
End
1+L1(4)/->/L1(4)
-1+L4(5)/->/L1(5)
For(X,1,2)
1+L1(X)/->/L1(X)
End
-1+L1(3)/->/L1(3)
If L1(1)=9:1/->/L1(1
If L1(2)=9:1/->/L1(2
If L1(3)=0:8/->/L1(3
If L2(4)=17:1/->/L2(4
If L2(5)=0:16/->/L2(5
ClrHome
End


I made it so it works off 2 list instead of 4 and saved ~20 bytes


Last edited by Guest on 02 Jun 2009 08:45:43 pm; edited 1 time in total
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 02 Jun 2009 08:11:46 pm    Post subject:

Lol.. i think i lost my booklet T_T *I R SO SAD! No more Staying up late reading it over again.. T_T
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 02 Jun 2009 08:32:57 pm    Post subject:

I think mine is in a pile of books that were used than put there to never be used again that was before i started to learn to program now i cant find it
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 02 Jun 2009 09:22:29 pm    Post subject:

Just B4 i went to BC Nelson. i took everything outa my backpack. Including my TI-Booklet and i forgot if iput it in my locker. or at home..
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 02 Jun 2009 10:45:27 pm    Post subject:

ok so i added tha astroids to the game and this code works great but i cant wrap my head around the collision detection any one willing to point me in the right direction(maybe some psydocode)
i need to get the ship not to hit the astroids and then the laser to work


Code:
4/->/X
8/->/Y
"^"/->/Str1
randint(1,8,5/->/L1
randint(1,16,5/->/L2
Repeat A=100// this is just to keep the game going
getkey/->/K
If K=0
Q/->/K
X+(k-34)-(K=25)/->/X
Y+(K=26)-(K=24)/->/Y
ClrHome
If K=24
"<"/->/Str1
If K=25
"^"/->/Str1
If K=26
">"/->/Str1
If K=34
"V"/->/Str1
If K!=21 and K!=31
K/->/Q
If X=0:8/->/X
If X=8:1/->/X
If Y=0:16/->/y
If Y=17:1/->/Y
Output(X,Y,Str1
If K=21:Then
If 1=abs(Q-25
Then
Y→B
For(A,B,1+15(Q=26),1-2(Q=24
Output(X,A,"-
End
End
If 9=2abs(Q-29.5
Then
X→B
For(A,B,1+7(Q=34),1-2(Q=25
Output(A,Y,"'
End
End
End
If K=31:Then
randint(1,8/->/X
randint(1,16/->/Y
End
For(X,1,5)
Output(L1(X),L2(X),"O
End
1+L1(4)/->/L1(4)
-1+L4(5)/->/L1(5)
For(X,1,2)
1+L1(X)/->/L1(X)
End
-1+L1(3)/->/L1(3)
If L1(1)=9:1/->/L1(1
If L1(2)=9:1/->/L1(2
If L1(3)=0:8/->/L1(3
If L2(4)=17:1/->/L2(4
If L2(5)=0:16/->/L2(5
End
End


total size minus collision detection 549(bytes)
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 02 Jun 2009 10:51:37 pm    Post subject:

Is it a fair analysis to say that BASIC is way to slow for a clone of asteroids?

The structure of x and y value + collision detection is way beyond the realm of BASIC.

Anything more then just simple moving objects won't have much functionality and not to mention angles beyond mutiples of 90 will take to much mathmatical calculations.

Feel free to criticize. I'm assuming asteroids, as the game where you can rotate and shoot crap thats flying around and that stuff.


-----------------------------
What you were interested in knowing <3
---------------------------------

Collision detection requires a comparison of x and y coordinates of the bullets shot by the ship and the x and y coordinates of the asteroids. You need a list for both the asteroid locations AND the bullets, which makes things a slow no doubt. Collision detection on the home screen is fairly easily with aligned coordinates, as there isn't anything between 1,1 and 1,2 etc.

A bullet collides with an asteroid when their x and y coordinates are of equal value. Fun part. You must go through each bullet using a for loop. Now you need to use a 2nd for loop to check its collisions with every single asteroid.. Now do that for every bullet........

so 5 bullets and 7 asteroids = 35 loops and checks.. Yea.... If a collision is true, then you "Delete" the bullet and the asteroid.

Another loop is required to check the x and y coordinates of all the asteroids as compared to the ship to check for collisions.


Oh and you haven't handled object creation which is pretty much a necessity for asteroids and... that takes even more time trying to find free spaces in the fixed size lists.

Whew for assembly language. <3


Last edited by Guest on 02 Jun 2009 11:01:54 pm; edited 1 time in total
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 02 Jun 2009 11:51:18 pm    Post subject:

Quote:
Feel free to criticize. I'm assuming asteroids, as the game where you can rotate and shoot crap thats flying around and that stuff

Nope you are right but in my game you only go left right and up down no rotation b/c that would be alot

cjgone wrote:
Collision detection requires a comparison of x and y coordinates of the bullets shot by the ship and the x and y coordinates of the asteroids. You need a list for both the asteroid locations AND the bullets, which makes things damn slow no doubt. Collision detection on the home screen is fairly easily with aligned coordinates, as there isn't anything between 1,1 and 1,2 etc.

A bullet collides with an asteroid when their x and y coordinates are of equal value. Fun part. You must go through each bullet using a for loop. Now you need to use a 2nd for loop to check its collisions with every single asteroid.. Now do that for every bullet........

so 5 bullets and 7 asteroids = 35 loops and checks.. Yea.... If a collision is true, then you "Delete" the bullet and the asteroid.

Another loop is required to check the x and y coordinates of all the asteroids as compared to the ship to check for collisions.


Oh and you haven't handled object creation which is pretty much a necessity for asteroids and... that takes even more time trying to find free spaces in the fixed size lists.


Omfg is that the only way to do this. there are only 5 astroids and 1 bullet on the screen at a time I know how to do the basic collision detction but when i use

For(A,1,5)
If L1(A)=X And L2(A)=Y
100/->/X // used to stop the repeat loop
End

it dosent work
what did i do wrong this should see that the ship is at X Y and so is the Astroid But it dosent
and if it takes all that mabey ill take out the laser!!


Last edited by Guest on 03 Jun 2009 12:19:47 am; edited 1 time in total
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 03 Jun 2009 08:17:24 am    Post subject:

ahh jeez. i was trying to make a game like Pheonix with Basic. And i could not figure out how to get more then 1 bullet on the screen at once.

I had all the coordination stuff down. But displaying it would be difficult.
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 03 Jun 2009 09:31:38 am    Post subject:

i have got all the displays down and they work The laser even shows but it dosent hit things it goes through then
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Jun 2009 12:25:26 pm    Post subject:

cjgone wrote:
Is it a fair analysis to say that BASIC is way to slow for a clone of asteroids?
No, that's a fair analysis. But that shouldn't stop a person from trying. [No Bullets] | [Bullets]

Before you ask about the code, it uses finance variables and some lookup table trickery. I'm too lazy to articulate the rest, but I think it'll lend itself to a fine Lunar Lander game. :)

[EDIT]

Hmm, oops. It looks like a coordinate gets repeated at the wrap-around point of rotation. Not sure what to do about that (and I'm too scared to try).


Last edited by Guest on 03 Jun 2009 12:46:03 pm; edited 1 time in total
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 03 Jun 2009 12:35:59 pm    Post subject:

Thanks for the code Weregoose ill take a look at it after the baseball game (I hate rain)
Back to top
ztrumpet


Active Member


Joined: 06 May 2009
Posts: 555

Posted: 03 Jun 2009 01:09:24 pm    Post subject:

dxfan101010 wrote:

For(A,1,5)
If L1(A)=X And L2(A)=Y
100/->/X // used to stop the repeat loop
End

I don't know what's wrong with this, but it can be optimized to:
For(A,1,5
If X=L1(A) And Y=L2(A
E2/->/X // used to stop the repeat loop
End
The E2 is the E from [2nd] [,].
Back to top
Weregoose
Authentic INTJ


Super Elite (Last Title)


Joined: 25 Nov 2004
Posts: 3976

Posted: 03 Jun 2009 01:18:40 pm    Post subject:

max(X=L1 and Y=L2 will give 1 if X and Y coincide with a coordinate pair from the lists. I think this is what you were going for.

Last edited by Guest on 11 Jul 2010 03:12:45 pm; edited 1 time in total
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 03 Jun 2009 04:57:43 pm    Post subject:

OK Weregoose you code in Here
Quote:
No, that's a fair analysis. But that shouldn't stop a person from trying. [No Bullets] | [Bullets]

Is insane and wayyyyy beyond me but on another hand
Quote:
max(X=L1 and Y=L2
I cant get this to work do you test it with an if statment?


Code:
4/->/X
8/->/Y
"^"/->/Str1
randint(1,8,5/->/L1
randint(1,16,5/->/L2
Repeat D=100// this is just to keep the game going
getkey/->/K
If K=0
Q/->/K
X+(k-34)-(K=25)/->/X
Y+(K=26)-(K=24)/->/Y
ClrHome
If K=24
"<"/->/Str1
If K=25
"^"/->/Str1
If K=26
">"/->/Str1
If K=34
"V"/->/Str1
If K!=21 and K!=31
K/->/Q
If X=0:8/->/X
If X=8:1/->/X
If Y=0:16/->/y
If Y=17:1/->/Y
Output(X,Y,Str1
If K=21:Then
If 1=abs(Q-25
Then
Y→B
For(A,B,1+15(Q=26),1-2(Q=24
Output(X,A,"-
End
End
If 9=2abs(Q-29.5
Then
X→B
For(A,B,1+7(Q=34),1-2(Q=25
Output(A,Y,"'
End
End
End
If K=31:Then
randint(1,8/->/X
randint(1,16/->/Y
End
For(X,1,5)
Output(L1(X),L2(X),"O
End
1+L1(4)/->/L1(4)
-1+L4(5)/->/L1(5)
For(X,1,2)
1+L1(X)/->/L1(X)
End
-1+L1(3)/->/L1(3)
If L1(1)=9:1/->/L1(1
If L1(2)=9:1/->/L1(2
If L1(3)=0:8/->/L1(3
If L2(4)=17:1/->/L2(4
If L2(5)=0:16/->/L2(5
[color=#0000FF]max(X=L1 and y=L2/->/D
IF D=1
100/->/D[/color]
End

Heres how i tried to use it but it only notices an astroid 1/4 times


Last edited by Guest on 11 Jul 2010 03:13:18 pm; edited 1 time in total
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 03 Jun 2009 07:22:31 pm    Post subject:

Why not code it without uneccessary optimizations. Very Happy
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 03 Jun 2009 07:53:18 pm    Post subject:

Cause its slow has crap already although i am still happy with it i just cant get the hit detection


Code:
4/->/X
8/->/Y
"^"/->/Str1
randint(1,8,5/->/L1
randint(1,16,5/->/L2
Repeat  Theta=5 or K=23
0/->/B
For(A,1,5)
If L1(A)=X and L2(A)=Y
5/->/Theta
End
Clrhome
getkey/->/K
If K=0
Q/->/K
X+(k-34)-(K=25)/->/X
Y+(K=26)-(K=24)/->/Y
ClrHome
If K=24
"<"/->/Str1
If K=25
"^"/->/Str1
If K=26
">"/->/Str1
If K=34
"V"/->/Str1
If K!=21 and K!=31 and K!=23
K/->/Q
If X=0:8/->/X
If X=8:1/->/X
If Y=0:16/->/y
If Y=17:1/->/Y
Output(X,Y,Str1
If K=21:Then
If 1=abs(Q-25
Then
Y→B
For(A,B,1+15(Q=26),1-2(Q=24
Output(X,A,"-
End
End
If 9=2abs(Q-29.5
Then
X→B
For(A,B,1+7(Q=34),1-2(Q=25
Output(A,Y,"'
End
End
End
If K=31:Then
randint(1,8/->/X
randint(1,16/->/Y
End
For(X,1,5)
Output(L1(X),L2(X),"O
End
1+L1(4)/->/L1(4)
-1+L4(5)/->/L1(5)
For(X,1,2)
1+L1(X)/->/L1(X)
End
-1+L1(3)/->/L1(3)
If L1(1)=9:1/->/L1(1
If L1(2)=9:1/->/L1(2
If L1(3)=0:8/->/L1(3
If L2(4)=17:1/->/L2(4
If L2(5)=0:16/->/L2(5
For(A,1,5)
If L1(A)=X and L2(A)=Y
5/->/Theta
End
End
Clrhome
DelVar L1DelVar L2DelVar ADelVar KDelVar QDelVar XDelVar YDelVar thetaDelVar B


I gots it the hit detection for the ship works i hope it workes great for me anyone willing to try it
After my vacation for a couple days ill try to work on the bullet hit detection
Ill still take any optimazitations cause its slow


Last edited by Guest on 03 Jun 2009 09:14:27 pm; edited 1 time in total
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 05 Jun 2009 11:53:45 am    Post subject:

i would test it. but im really wayyy to lazy to type anything down into my calc. How about you Attach that onto a file.. and upload it onto UTI
Back to top
cjgone
Aw3s0m3


Active Member


Joined: 24 May 2006
Posts: 693

Posted: 05 Jun 2009 06:44:54 pm    Post subject:

I can't see this running fast ever no matter the optimizations. Soon as you implement bullet collision, you're gonna have a major slow down as collision detection will take up like 80% of the cpu.

It's a good learning experience no doubt. Very Happy
Back to top
dxfan101010


Member


Joined: 31 Mar 2008
Posts: 194

Posted: 07 Jun 2009 12:08:05 pm    Post subject:

Quote:
I can't see this running fast ever no matter the optimizations. Soon as you implement bullet collision, you're gonna have a major slow down as collision detection will take up like 80% of the cpu.

Yeah i know its going to be slow but i am haveing fun making it and i am learning alot


Quote:
i would test it. but im really wayyy to lazy to type anything down into my calc. How about you Attach that onto a file.. and upload it onto UTI

my link port is broken. If anyone is willing to type it in and upload it to the archives i am fine with that.
Back to top
Display posts from previous:   
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
    » Goto page Previous  1, 2
» View previous topic :: View next topic  
Page 2 of 2 » All times are UTC - 5 Hours

 

Advertisement