Author |
Message |
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 28 May 2009 09:12:36 pm Post subject: |
|
|
I made a racing game and i was wondering if you guys could help me opyimize it and cut down on the flashynees
I'v read about racing games in the routines section but i couldnt find out how to cut out the glare and i just suck at optimazitation
/->/=store
Code: 8/->/X
8/->/Y
1/->/B
1/->/A
3/->/G
1/->/v
DelVar S
Repeat Y=4 or Y=12 or X=G and Y=P or X=V And Y=H
ClrHome
For(B,1,8
Output(B,4,X
End
For(A,1,8
Output(A,12,X
End
Output(X,Y,"^
Output(1,1,S
getKey/->/K
If K=0
getKey/->/K
If K=24:Then
Y-1/->/Y
End
If K=26:Then
Y+1/->/Y
End
If V>8:Then
1/->/V
S+1/->/S
randint(5,11/->/H
End
If G>8:Then
1/->/G
randInt(5,11/->/P
S+1/->/S
End
Output(G,P,"*
Output(V,H,"*
V+1/->/
G+1/->/G
End
there is no opining or ending yet just the game thanks in advance
Edit: fixed missing star
Last edited by Guest on 28 May 2009 10:51:09 pm; edited 1 time in total |
|
Back to top |
|
|
tr1p1ea
Elite
Joined: 03 Aug 2003 Posts: 870
|
Posted: 29 May 2009 01:46:31 am Post subject: |
|
|
Sick! Ricing Game!! .
From what i can tell, you are redrawing everything every loop, which is most likely what is causing things to flicker. What you could do is take parts that dont need to be redrawn out of your loop, and maybe redraw only the parts that are needed. Instead of clearing the who screen, you may be able to just clear your characters with a "space" instead.
You can also optimise your key stuff to something like:
getKey->K
Y-(K=24)+(K=26)->Y
Instead of using if/then. You could even use Ans instead of K.
Also you dont need to initialise your A and B variables. In fact you can just use A twice and not bother with B at all.
Last edited by Guest on 29 May 2009 02:07:14 am; edited 1 time in total |
|
Back to top |
|
|
tiuser1010
Member
Joined: 23 Apr 2009 Posts: 100
|
Posted: 29 May 2009 03:23:51 am Post subject: |
|
|
I must say this is an excellence game especially for being in BASIC
Some ways to opyimize the program:
:When it says If K=24:Then
Y-1/->/Y
End
If K=26:Then
Y+1/->/Y
End
You could repalce that with:
If K=24:Y-1/->/Y
If K=26:Y+1/->/Y
Also When you say:
getKey/->/K
If K=0
getKey/->/K
You could take out the:
If K=0
getKey/->/K |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 29 May 2009 01:41:23 pm Post subject: |
|
|
tr1p1ea wrote: Sick! Ricing Game!! .
From what i can tell, you are redrawing everything every loop, which is most likely what is causing things to flicker. What you could do is take parts that dont need to be redrawn out of your loop, and maybe redraw only the parts that are needed. Instead of clearing the who screen, you may be able to just clear your characters with a "space" instead.
ok ill try that when i get the chance thanks . and the get key stuff ill just have to rember to use that code
tiuser1010 wrote: I must say this is an excellence game especially for being in BASIC
Some ways to opyimize the program:
:When it says If K=24:Then
Y-1/->/Y
End
If K=26:Then
Y+1/->/Y
End
You could repalce that with:
If K=24:Y-1/->/Y
If K=26:Y+1/->/Y
But the If thens are faster
tiuser1010 wrote: I must say this is an excellence game especially for being in BASIC
Some ways to opyimize the program:
Also When you say:
getKey/->/K
If K=0
getKey/->/K
You could take out the:
If K=0
getKey/->/K
ok ill try that too
here is the new code
Code: 8/->/X
8/->/Y
5/->/p
3/->/G
1/->/v
DelVar S
ClrHome
For(A,1,8
Output(A,4,X
Output(A,12,X
End
Repeat Y=4 or Y=12 or X=G and Y=P or X=V And Y=H
If k=24
Output(X,Y+1," //space
If K=26
Output(X,Y-1," // space
Output(X,Y,"^
getKey/->/K
Y-(k=24)+(k=26)/->/Y
If V>8:Then
1/->/V
S+1/->/S
randint(5,11/->/H
End
If G>8:Then
1/->/G
randInt(5,11/->/P
S+1/->/S
End
Output(G,P,"*
Output(V,H,"*
V+1/->/V
G+1/->/G
rand(3 // so you can see the stars
Output(V-1,H," // space
Output(G-1,P," // space
End
I have a closing/ score display any one have a good idea for the beggining Also how would i curve the track and make the stars follow that curve.
Last edited by Guest on 29 May 2009 02:20:33 pm; edited 1 time in total |
|
Back to top |
|
|
IAmACalculator In a state of quasi-hiatus
Know-It-All
Joined: 21 Oct 2005 Posts: 1571
|
Posted: 29 May 2009 05:32:33 pm Post subject: |
|
|
tiuser1010 wrote: When it says
If K=24:Then
Y-1/->/Y
End
If K=26:Then
Y+1/->/Y
End
You could repalce that with:
If K=24:Y-1/->/Y
If K=26:Y+1/->/Y
Or even
Y - (K=24) + (K=26) -> Y
There's probably a way to reduce that even more, but none that I know of. Not that this is completely relavent, as the latest revision doesn't even have this part, but it's good to know.
EDITED for formatting
Last edited by Guest on 11 Jul 2010 03:16:27 pm; edited 1 time in total |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 29 May 2009 05:47:07 pm Post subject: |
|
|
Y - (K=24) + (K=26) -> Y
I still havent quiet figured out boolen(?) logic but this is a good code and i have started to use it to move things |
|
Back to top |
|
|
ticalcnoah
Member
Joined: 28 Oct 2007 Posts: 153
|
Posted: 29 May 2009 05:47:38 pm Post subject: |
|
|
If thens are not faster than boolean expressions. |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 29 May 2009 05:51:24 pm Post subject: |
|
|
ticalcnoah wrote: If thens are not faster than boolean expressions.
nonono... I ment that
if
then
end
is faster than just an if
And youll notice i used the boolean in my code
Last edited by Guest on 29 May 2009 05:52:41 pm; edited 1 time in total |
|
Back to top |
|
|
IAmACalculator In a state of quasi-hiatus
Know-It-All
Joined: 21 Oct 2005 Posts: 1571
|
Posted: 29 May 2009 05:56:37 pm Post subject: |
|
|
With the 83+(SE)/84+(SE), it parses booleans as 1 and 0, with 1 (or anything >1) being true and 0 being false. If 1 will always resolve, and If 0 will never resolve. A popular method for creating infinite loops in TI-Basic is While 1 (or, alternately, Repeat 0).
Y + (X=24) -> Y will be Y + (1) -> Y if X is 24, otherwise it will be Y + (0) -> Y.
Last edited by Guest on 11 Jul 2010 03:16:49 pm; edited 1 time in total |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 29 May 2009 06:17:15 pm Post subject: |
|
|
Yeah i got that far. But iv just not gotten very good at using them yet!or rembering That they can be used!!
:ninja: :! |
|
Back to top |
|
|
TheStorm
Calc Guru
Joined: 17 Apr 2007 Posts: 1233
|
Posted: 29 May 2009 10:10:22 pm Post subject: |
|
|
dxfan101010 wrote: ticalcnoah wrote: If thens are not faster than boolean expressions.
nonono... I ment that
if
then
end
is faster than just an if
And youll notice i used the boolean in my code
An If statement is slower only if it is the comand right after a unclosed For( statement so as long as you have at least one command between the For( statement and the If it will be faster than 'If Then' |
|
Back to top |
|
|
TI-newb
Member
Joined: 24 Dec 2008 Posts: 158
|
Posted: 29 May 2009 10:43:34 pm Post subject: |
|
|
i do not know if the if-thens are like slower under for('s.. but for me. i just use If X=2:5->L if thers only 1 thing i wanna do. and i use If Then for multiple stuff...
If
Then
Blah
Blah
End..
i don't get why you would do
If K=26:Then
Y-1->Y
End..
Last edited by Guest on 29 May 2009 10:44:03 pm; edited 1 time in total |
|
Back to top |
|
|
Eeems
Advanced Member
Joined: 25 Jan 2009 Posts: 277
|
Posted: 29 May 2009 11:13:28 pm Post subject: |
|
|
If thens are faster then normal if statments under for loops and for loops slow down if you don't put the ending ) |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 29 May 2009 11:23:27 pm Post subject: |
|
|
did i forget a for loop ending
ooops u mean the perethency ")" this thing dont you
So you have to close for loops?
[/quote]
An If statement is slower only if it is the comand right after a unclosed For( statement so as long as you have at least one command between the For( statement and the If it will be faster than 'If Then'
[/quote]
so i should just use if's not if thens right
And when i fixed the code to use a boolean expression i took out the if thens
Last edited by Guest on 29 May 2009 11:32:50 pm; edited 1 time in total |
|
Back to top |
|
|
Eeems
Advanced Member
Joined: 25 Jan 2009 Posts: 277
|
Posted: 29 May 2009 11:26:17 pm Post subject: |
|
|
yeah I do, so remember to close your For( loops with a )
and guess what, I'm not alone in programming in Alberta any more |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 29 May 2009 11:35:05 pm Post subject: |
|
|
wow ill have to fix that in like 8 of my programs! thanks for telling me. |
|
Back to top |
|
|
Eeems
Advanced Member
Joined: 25 Jan 2009 Posts: 277
|
Posted: 29 May 2009 11:52:30 pm Post subject: |
|
|
np, I found out about a month ago so I had a lot of work to do with it |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 30 May 2009 12:11:27 am Post subject: |
|
|
so
Code: 8/->/X
8/->/Y
5/->/p
5/->/G
1/->/v
DelVar S
ClrHome
[color=#00FF00][font="Arial Black"][size=3]For(A,1,8)[/size][/font][/color]
Output(A,4,X
Output(A,12,X
End
Repeat Y=4 or Y=12 or X=G and Y=P or X=V And Y=H
If k=24
Output(X,Y+1," //space
If K=26
Output(X,Y-1," // space
Output(X,Y,"^
getKey/->/K
Y-(k=24)+(k=26)/->/Y
If V>8:Then
1/->/V
S+1/->/S
randint(5,11/->/H
End
If G>8:Then
1/->/G
randInt(5,11/->/P
S+1/->/S
End
Output(G,P,"*
Output(V,H,"*
V+1/->/V
G+1/->/G
rand(1
Output(V-1,H," // space
Output(G-1,P," // space
[color=#00FF00]End
ClrHome
Output(4,6,"score
For(A,1,8)
Output(5,A,S
Rand(3
Output(5,A," //space
End
Output(5,8,s
Pause
ClrHome
"[/color]
Green is my new ending sequence
total size minus an opening and a menu 319(byts)
Last edited by Guest on 30 May 2009 06:38:38 pm; edited 1 time in total |
|
Back to top |
|
|
Eeems
Advanced Member
Joined: 25 Jan 2009 Posts: 277
|
Posted: 30 May 2009 11:30:22 pm Post subject: |
|
|
yep, that should run a little bit faster now |
|
Back to top |
|
|
dxfan101010
Member
Joined: 31 Mar 2008 Posts: 194
|
Posted: 31 May 2009 01:12:43 am Post subject: |
|
|
yep it dosent slow down has far as i have gotten whici is like 1500 so i think you could go until it ends in an :ninja: error
Code:
ClrHome
For(x,1,5)
Output(4,X," Race //space before R
rand(3
End
For(X,7,5,-1)
Output(X,3,"By Mclovin
Output(X+1,3," " // 10 spaces
rand(3
End
For(x,1,250)
End
Lbl 1
Menu("Race Game","Play",P,"Quit",Q
Lbl P
8/->/X
8/->/Y
5/->/p
5/->/G
1/->/v
7/->/H
DelVar S
ClrHome
For(A,1,8 )
Output(A,4,X
Output(A,12,X
End
Repeat Y=4 or Y=12 or X=G and Y=P or X=V And Y=H
If k=24
Output(X,Y+1," //space
If K=26
Output(X,Y-1," // space
Output(X,Y,"^
getKey/->/K
Y-(k=24)+(k=26)/->/Y
If V>8:Then
1/->/V
S+1/->/S
randint(5,11/->/H
End
If G>8:Then
1/->/G
randInt(5,11/->/P
S+1/->/S
End
Output(G,P,"*
Output(V,H,"*
V+1/->/V
G+1/->/G
rand(1
Output(V-1,H," // space
Output(G-1,P," // space
End
ClrHome
Output(4,6,"score
For(A,1,8 )
Output(5,A,S
Rand(3
Output(5,A," //space
End
Output(5,8,s
Pause
Menu("Play Again","Yes",1,"No",Q
Lbl Q
ClrHome
"
Total size 485(Bytes)
Last edited by Guest on 31 May 2009 01:44:36 am; edited 1 time in total |
|
Back to top |
|
|
|