Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Halifax on July 15, 2006, 06:30:00 pm

Title: [83+ xLIB] Programming Grayscale Help
Post by: Halifax on July 15, 2006, 06:30:00 pm
Here is the code that I was wondering if it could be optimized and it would be much appriciated if this was done before 1 today because after this ima be gone for three weeks.Also another problem is I cant find the right place to put the AI. Cause before the While 1 it only runs when palyer moves. After Repeat it runs so much that getkey doesnt register. At the end it dont move until user moves.

Key:
prgmGROUT3E= Enemy grayscale
prgmGROUT3G=Person grayscale
prgmGAI=Enemy AI(sorta)
->=store

QUOTE
prgmGENGINE:
real(0,1:->S:->T
44->I:-34->M:44->J:-26->P
real(1,I,36,1,8,7,0,0,0,0,1
While 1
prgmGROUT3G:prgmGROUT3E
real(1,I,36,1,8,7,0,0,0,0,1
prgmGROUT3G:prgmGROUT3E
prgmGROUT3G:prgmGROUT3E
Repeat K
getkey->K
prgmGROUT3G:prgmGROUT3E
End
If (K>=24 and K<=26):Then
prgmGROUT3G
real(1,I,36,1,8,8,2,0,3,0,1
End
prgmGAI
prgmGROUT3G
I-8(K=24)+8(K=26->I
If K=25:Then
For(N,1,4
Pt-On(I,M
End
Pt-Off(I,M
-34->M
End
End

prgmGAI:
real(1,J,19,1,8,7,1,0,0,0,1
prgmGROUT3G:prgmGROUT3E
randInt(1,3->O
prgmGROUT3G:prgmGROUT3E
real(1,J,19,1,8,7,11,0,0,0,1
J-8(O=1)+8(O=2)->J
real(1,J,19,1,8,7,1,0,0,0,1
prgmGROUT3G:prgmGROUT3E
If O=3:Then
prgmGROUT3G:prgmGROUT3E
For(N,1,4
Pt-On(J,P
End
prgmGROUT3G:prgmGROUT3E
Pt-Off(J,P
End
Please help o.oblink.gif
Title: [83+ xLIB] Programming Grayscale Help
Post by: kalan_vod on July 19, 2006, 11:38:00 am
Well there is a gs guide here made by CDI, other than that I could help a little with your code. Btw, why are you Pt-On four times on the same spot?

c1-->
CODE
ec1For(N,1,4
Pt-On(I,M
Endc2
ec2
Title: [83+ xLIB] Programming Grayscale Help
Post by: DJ Omnimaga on July 19, 2006, 11:57:00 am
he might have made a typo
Title: [83+ xLIB] Programming Grayscale Help
Post by: Dragon__lance on July 19, 2006, 01:22:00 pm
as far as your code gos,some simple optimisations are:

In the very beginning,replace the ->S,T with DelvarS,DelvarT.And instead of real(0,1,just have real(0.
Now i noticed you use seperate programs to run the grayscale.My advice is this,if you plan on having a lot of programs in the game,then just copy that program code into the main engine instead of having it as a subroutine.Calling subroutines is slower than just having an if/then statement,especially with a lot of programs involved ;)wink.gif

As for the AI problem....the only place i see to put it is the Repeat Getkey loop.To make it not run so much,you might have to set up ur own interrupt:

:not(X->X (x being interrupt variable)
:if X:prgmGAI

there are numerous other ways to do this :)smile.gif

Title: [83+ xLIB] Programming Grayscale Help
Post by: Zeromus on July 19, 2006, 04:22:00 pm
@d_l: NEVER skimp code from xLIB, I learned that the hard way, if you include the full code it works fine.  
Title: [83+ xLIB] Programming Grayscale Help
Post by: Dragon__lance on July 20, 2006, 02:10:00 pm
i agree,but i'm very use to just using real(0,instead of real(0,1,has nvr crashed for me yet.
Title: [83+ xLIB] Programming Grayscale Help
Post by: Liazon on July 21, 2006, 12:35:00 am
That's because real( is a regular Ti-OS command.  I don't know what it does, but I think normally it should return the real part of a complex number.  I think.

Since xlib won't parse it, Ti-OS will parse it and there will be no crash... hopefully.
Title: [83+ xLIB] Programming Grayscale Help
Post by: DJ Omnimaga on July 21, 2006, 09:22:00 am
I always use real(0 until I found out that trick to check if xlib is installed or not I never knew there was a sec argument o.oblink.gif
Title: [83+ xLIB] Programming Grayscale Help
Post by: threefingeredguy on July 21, 2006, 08:16:00 pm
Yeah, but it doesn't matter. I think adding a second argument will cause an error if xLIB isn't installed anyway.
Title: [83+ xLIB] Programming Grayscale Help
Post by: DJ Omnimaga on July 22, 2006, 01:10:00 am
yeah i like how you can detect if its installed with one argument at prgm startup