Adventure Game with text input

A forum where you can announce your awesome project(s).

Moderator: MaxCoderz Staff

Would you play an adventure game where you have to type two word input?

yes
10
71%
no
4
29%
 
Total votes: 14

CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

hart wrote:CompWiz, your code is pretty inefficient, so use this code instead. It should work for most cases, and it is relatively small and fast. Just remember to give credit. Also tell me if you find any problems with it.

Code: Select all

DelVar XDelVar Y
While X<length(Str1
While sub(Str1,1,1)=" // 1 space
sub(Str1,2,length(Str1)-1->Str1
End
Repeat max(X={16,length(Str1
X+1->X
If sub(Str1,X,1)=" // 1 space
X->Y
End
Disp sub(Str1,1,min(Y(Y>12)+16(Y<=12),length(Str1
If X!=length(Str1
Then
sub(Str1,Y(Y>12)+16(Y<=12)+1,length(Str1)-Y(Y>12)-16(Y<=12->Str1
DelVarXDelVar Y
End:End
thankyou. I will definitely give you credit in the credits and readme. :D
In Memory of the Maxcoderz Trophy Image
hart
New Member
Posts: 3
Joined: Wed 26 Oct, 2005 8:06 pm

Post by hart »

After looking at the code, I noticed an optimization that I forgot.

Code: Select all

DelVar XDelVar Y
While X<length(Str1
While sub(Str1,1,1)=" // 1 space
sub(Str1,2,length(Str1)-1->Str1
End
Repeat max(X={16,length(Str1
X+1->X
If sub(Str1,X,1)=" // 1 space
X->Y
End
16:If Y>12:Y
Disp sub(Str1,1,min(Ans,length(Str1
If X!=length(Str1
Then
sub(Str1,Ans+1,length(Str1)-Ans->Str1
DelVarXDelVar Y
End:End
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

hart wrote:After looking at the code, I noticed an optimization that I forgot.

Code: Select all

DelVar XDelVar Y
While X<length(Str1
While sub(Str1,1,1)=" // 1 space
sub(Str1,2,length(Str1)-1->Str1
End
Repeat max(X={16,length(Str1
X+1->X
If sub(Str1,X,1)=" // 1 space
X->Y
End
16:If Y>12:Y
Disp sub(Str1,1,min(Ans,length(Str1
If X!=length(Str1
Then
sub(Str1,Ans+1,length(Str1)-Ans->Str1
DelVarXDelVar Y
End:End
I put some letters and spaces into string1, then ran your program. It started to work, then gave me the overflow error on this line:

Code: Select all

If X!=length(Str1
it put the cursor on the ! for the error.
In Memory of the Maxcoderz Trophy Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

I hope you know it means not equal to (!=) so you need to change it to the equal sign with the slash through it.[/code]
DarkerLine
Calc Wizard
Posts: 526
Joined: Tue 08 Mar, 2005 1:37 am
Location: who wants to know?
Contact:

Post by DarkerLine »

Code: Select all

Repeat X
While sub(Str1,1,1)=" // 1 space 
sub(Str1,2,length(Str1)-1->Str1 
End
1
While Ans and Ans<=min(16,length(Str1
Ans->Y
inString(Str1,Ans+1," //1 space
End
16<=length(Str1->X
16:If Y>12:Y 
Disp sub(Str1,1,min(Ans,length(Str1 
If not(X
sub(Str1,Ans+1,length(Str1)-Ans->Str1 
End
There's also another alternative. If the strings were formatted so that the "/" symbol signified a line break (this won't cause an increase in size because spaces were line breaks before), you could use the following (shorter) code:

Code: Select all

0
Repeat Ans=length(Str1
Ans+1->X
inString(Str1,"/",X
Disp sub(Str1,X,Ans-X
End
An example string would be "THIS SENTENCE/WRAPS ACROSS/SEVERAL LINES/". Of course, if you replace the "/" symbol with another symbol, you can use another symbol, just choose something that won't occur in the string naturally.
just try to be nice to people.
_________________
My TI Blog - http://mpl.unitedti.org/
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

kalan_vod wrote:I hope you know it means not equal to (!=) so you need to change it to the equal sign with the slash through it.[/code]
Oh, I forgot to change that. I'm not used to adapting tibasic to text and back. The =! just looked natural. I program C++ a lot.
DarkerLine wrote:There's also another alternative. If the strings were formatted so that the "/" symbol signified a line break (this won't cause an increase in size because spaces were line breaks before), you could use the following (shorter) code:
Code:
0
Repeat Ans=length(Str1
Ans+1->X
inString(Str1,"/",X
Disp sub(Str1,X,Ans-X
End
An example string would be "THIS SENTENCE/WRAPS ACROSS/SEVERAL LINES/". Of course, if you replace the "/" symbol with another symbol, you can use another symbol, just choose something that won't occur in the string naturally.
Thanks for the suggestion, but this won't work the way the game will be set up. Thank you for working on it though :D
In Memory of the Maxcoderz Trophy Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Yeah no problem, I know that it does look natural b/c of java ( for me) and other languages.
BUT my knowledge != to yours :lol:
hart
New Member
Posts: 3
Joined: Wed 26 Oct, 2005 8:06 pm

Post by hart »

Last edited by hart on Thu 19 Jan, 2006 10:06 pm, edited 2 times in total.
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

Thanks Heart, your code works great. As soon as I get home I will try out DarkerLine's code as well. Probably the smaller one will get into the final program. I will be able move onto the rest of the program now.
Thanks for all the help! :D
In Memory of the Maxcoderz Trophy Image
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

What is the best way to put a bunch of numbers into a matrix? I need to fill a 20x6 matrix with numbers when the game is first started as a pre-load. Would it be best to put something like:

Code: Select all

List>matr({4,3,2,0,0,0},{0,0,0,1,0,0},{1,0,0,0,0,0},{0,1,0,5,0,0},(more until matrix is full), [A])
Or would it be better to have the program take one huge number that is all of the numbers that need to go in the matrix, in order, and have a loop pull each digit off and put it into the matrix, one at a time.

Code: Select all

1->b
432000000100100000010500->x
while(x>0)
a+1->a
if(a>6)
then
b+1->b
1->a
End
x-(int(x/10))*10->[A](a,b)
int(x/10)->x
End
(I know this code isn't done. Don't correct it. Just showing my concept. Thanks :) )

While it would be smaller, I fear that might take too long unfortunately. This operation cannot take too long, as it needs to run when the program starts, without too much delay. In case it would help, most of the digits are 0. Does anyone have a suggestion on how to do this?
In Memory of the Maxcoderz Trophy Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

It would be alot alot smaller, but the load time would be quiet some time. I'll work on some code tomorrow and see what I come up with.
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

kalan_vod wrote:It would be alot alot smaller, but the load time would be quiet some time. I'll work on some code tomorrow and see what I come up with.
Yeah, that's what I figured. Any help is greatly appreciated(and worth a mention in the credits section). :) Thanks!
In Memory of the Maxcoderz Trophy Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Ok due to the limits of basic or just the calc itself, once you have a # larger than 13 it will not work, what I mean is I can get it to return the part of the # that I want, but when the part I need is greater than the 13th postition it returns a zero atoumatically.
BASIC Code wrote::ClrHome
:1234567890123ImageX
:For(Image,1,int(log(X)+1
:X/10ImageX
:X-int(X
:Pause int(Ans*10
:End
When you run this it returns X in reverse order.
Edit:
On anouther note you could use a compression techniqe where you list how many of the number proceeds I.E. 12,0 means 12 of sprite 0.
Btw if this did work or will work how would you make it use sprites larger than 9?
CompWiz
Calc King
Posts: 1950
Joined: Thu 13 Oct, 2005 1:54 pm
Location: UB

Post by CompWiz »

Yeah, now that I think about it, I will have to use numbers higher than 9. (however, I need only a couple of those) So, would the best, fastest way be to just write out the lists and put them into the maxtrix, like:

Code: Select all

List>matr({4,3,2,0,0,0},{0,0,0,1,0,0},{1,0,0,0,0,0},{0,1,0,5,0,0},(more until matrix is full), [A])
In Memory of the Maxcoderz Trophy Image
User avatar
kalan_vod
Calc King
Posts: 2932
Joined: Sat 18 Dec, 2004 6:46 am
Contact:

Post by kalan_vod »

Well that takes up about the same space as just writing the whole matrix it self, so just make the matrix in the program.
Post Reply