Omnimaga

Calculator Community => TI Calculators => TI-BASIC => Topic started by: Cowmaster232 on March 12, 2010, 09:42:26 pm

Title: Lots of Questions (I'm a newb ^_^)
Post by: Cowmaster232 on March 12, 2010, 09:42:26 pm
I have been programming small little programs to help me solve equations in math class (on my TI-83 plus) for a few weeks now after I was introduced to the TI-BASIC language. I've been reading the tibasicdev website to learn more about the language and I have made short simple text based games using a lot of goto's and lbl's. I want to start making an RPG, but I have been a little reluctant because I have a few questions that tibasicdev doesn't seem to answer for me  ??? .

1. How the heck do you create a map? And how do you put it in the code? Can someone post a link to a good, in depth tutorial?

2. What do matrices have to do with maps?

3. How should the code for an RPG be organized?

4. Do programs take up memory if they are not running?

5. How do you create a List and what are they usually used for?

6. What are strings usually used for?

Thank you for your help  ;D
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 12, 2010, 09:55:19 pm
1. TIBD has a few different places for map making here (http://tibasicdev.wikidot.com/easy-map-making) and here (http://tibasicdev.wikidot.com/maps).

2. Matrices, from what I understand so far (I'm not an expert like some of these guys), is one way of storing data for a map. I'm sure there are other uses but that is what I know.

3. Can't help ya there.

4. Yes, if you push [2nd][ + ][2][7] you can see how much memory each program takes up. RAM is your unarchived stuff (the stuff without a asterisk next to it) and you can run that directly. Archived things (archive is a much bigger piece of memory in your calculator) are things you need to un-archive first. In that screen you can just push enter to archive/un-archive programs.

5. Well there are a few things that go into that. There is setting the dimentions for the list and then the actual data. Both of which are found here (http://tibasicdev.wikidot.com/sk:lists). They do a lot. Store highscores, saved games, items, maps, etc.

6. Strings can be used for a lot of things too. Mostly, from what I've seen, for making maps and storing text.

Everyting can probably be answered on TIBD if you just look hard enough. I would advise not start with a big RPG though, bad idea for a beginner (believe me, I know haha). Hope this helps. I also probably got ninja'd by the time I post this. I didn't get ninja'd O0
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 12, 2010, 10:02:06 pm
actually, you can do a RPG as first calc project, unlike Meishe91 said, but it needs to be very small. An example would be Illusiat 1. This was my very first calc game ever. My three first calc game projects were RPGs and the 5th and 6th ones too. The best thing is to not start too big.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: trevmeister66 on March 12, 2010, 10:03:59 pm
1. You could use TI freak's RPG Starter Kit (will find link soon)

2. Matrices help store map data and help with doing hit detection

3. Write it on paper first, and organize it there, then transfer it to your calc.

4. It will only take space if it's on your calc ;) but if you keep it on your computer, then you don't have to worry about that.

5. List store data, usually (in regards to RPG's) either Item data, stats, or enemy data.

6.Strings can be used for any number of things, depending on if you know how to correctly manipulate them. Also, they tend to be smaller than Lists or Matrices, and they are usually faster to access data from.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 12, 2010, 10:05:54 pm
Oh, sorry. I didn't mean for it to sound like that. I just meant not to start with a big time RPG (since you were asking about maps and such that is what it sounded like you were thinking). Sorry about that.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 12, 2010, 10:14:01 pm
My first RPGs had very basic mapping, btw. In Illusiat 1 through 4 in dungeons, when pressing an arrow, you moved an entire room in this direction, not just one step
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 12, 2010, 10:19:02 pm
Ah ok, well I'm sorry. Wasn't aware. I should play those...been meaning to.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 12, 2010, 10:27:52 pm
Don't worry too much about it. Just wanted to make sure the overall mentality of "if you start with a RPG as first project, you will be guaranteed to fail" that some United-TI/TIBD members (mostly the older ones) have was not being carried over at Omnimaga. Someone at one of these two places dissed jsj795 TLM project when he posted there for the first time, because he only had one post and the person thought he was new. No wonder why jsj never posted about the project there again... I could find the post, hold on...

Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 12, 2010, 10:32:06 pm
Ya, I didn't mean to spread that. I just meant a big time project that you have said you shouldn't start out with. What was TLM though?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: ztrumpet on March 12, 2010, 10:33:57 pm
I need to play those too...

1: You can create a map with a matrix, list, or string.  Here's an example of each method (note that I'm using only 4*6 maps):

Matrix:
:[[1,2,1,2,1,2][2,0,0,0,0,1][1,0,0,0,0,2][2,1,2,1,2,1->[A]
:ClrHome
:For(A,1,4
:For(B,1,6
:Output(A,B,sub("=87",1+[A](A,B),1
:End
:End

List:
:{1,2,1,2,1,2,2,0,0,0,0,1,1,0,0,0,0,2,2,1,2,1,2,1->L1
:ClrHome
:For(A,1,4
:For(B,1,6
:Output(A,B,sub("=87",1+L1(6A-6+B),1
:End
:End

String:
:"8787877====88====778787->Str1
:ClrHome
:For(A,1,4
:Output(A,B,sub(Str1,6A-5,6
:End

Once these are all ran you will see
878787
7====8
8====7
787878

I think this showed how to make a map. :)

I think Meishe answered the others very well. :)
2. Matrices, from what I understand so far (I'm not an expert like some of these guys), is one way of storing data for a map. I'm sure there are other uses but that is what I know.

3. Can't help ya there.

4. Yes, if you push [2nd][ + ][2][7] you can see how much memory each program takes up. RAM is your unarchived stuff (the stuff without a asterisk next to it) and you can run that directly. Archived things (archive is a much bigger piece of memory in your calculator) are things you need to un-archive first. In that screen you can just push enter to archive/un-archive programs.

5. Well there are a few things that go into that. There is setting the dimentions for the list and then the actual data. Both of which are found here (http://tibasicdev.wikidot.com/sk:lists). They do a lot. Store highscores, saved games, items, maps, etc.

6. Strings can be used for a lot of things too. Mostly, from what I've seen, for making maps and storing text.

Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 12, 2010, 10:34:41 pm
TLM is still being worked on at http://www.omnimaga.org/index.php?board=56.0 . He lost a lot of progress today, though :(


And I found the post I was talking about: http://www.unitedti.org/forum/index.php?s=&showtopic=8988&view=findpost&p=136771

ANother similar post http://www.unitedti.org/forum/index.php?s=&showtopic=9230&view=findpost&p=140068
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Cowmaster232 on March 12, 2010, 10:35:59 pm
Thanks guys! DJ Omnimanga, I think I read about your Illusiat games on another forum :) . I'm thinking about making a small rpg like Illusiat 1.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: trevmeister66 on March 12, 2010, 10:37:42 pm
Thanks guys! DJ Omnimanga, I think I read about your Illusiat games on another forum :) . I'm thinking about making a small rpg like Illusiat 1.
That's a good idea. It's good to start off small, and then once you're comfortable with what you're doing, you can expand your project.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: ztrumpet on March 12, 2010, 10:39:20 pm
Thanks guys! DJ Omnimanga, I think I read about your Illusiat games on another forum :) . I'm thinking about making a small rpg like Illusiat 1.
That's an awesome idea!  Good luck, and we'll all help if/when you need it. :D
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: {AP} on March 12, 2010, 10:41:14 pm
1. How the heck do you create a map? And how do you put it in the code? Can someone post a link to a good, in depth tutorial?

I'm actually writing up a huge guide for this very subject. Currently, it only contains the movement code, matrix maps (making and displaying), and collision detection for those maps. Let me know if you want early access to the guide and I'll PM you a link.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 12, 2010, 10:41:50 pm
Illusiat 2 original version was actually built off Illusiat 1. This is why both game dungeons are almost the same. Illusiat 3 was also built off Illusiat 1 and 2.

Btw looking at other people's code source can help a lot during learning, too, after you checked some tutorials.And obviously, the TI-83+ guidebook, chapter about programming and the parts about boolean logic. http://education.ti.com/educationportal/downloadcenter/SoftwareDetail.do?website=US&tabId=2&appId=6124

I don't recommend taking Illusiat early games as example for coding, though, because the code is very messy. Check different author's source, maybe. As said earlier, RPG Starter kit is a good utility
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Cowmaster232 on March 12, 2010, 10:46:27 pm

Matrix:
:[[1,2,1,2,1,2][2,0,0,0,0,1][1,0,0,0,0,2][2,1,2,1,2,1->[A]
:ClrHome
:For(A,1,4
:For(B,1,6
:Output(A,B,sub("=87",1+[A](A,B),1
:End
:End

List:
:{1,2,1,2,1,2,2,0,0,0,0,1,1,0,0,0,0,2,2,1,2,1,2,1->L1
:ClrHome
:For(A,1,4
:For(B,1,6
:Output(A,B,sub("=87",1+L1(6A-6+B),1
:End
:End

String:
:"8787877====88====778787->Str1
:ClrHome
:For(A,1,4
:Output(A,B,sub(Str1,6A-5,6
:End

Once these are all ran you will see
878787
7====8
8====7
787878


Can you explain the 1's 2's and 0's?
And what purpose do the For commands serve in this situation?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: ztrumpet on March 12, 2010, 10:50:16 pm
Sure. :)

The 1s,2s,and 0s are references to the different tiles in the map.  The For loop(s) then display either a single character, or a group of 6 characters in the string example.  Basically the For loops let the sub( put the characters on the screen. :)

I'd recommend learning about the sub( command.  It's very important when dealing with strings, which happens quite frequently. :)
http://tibasicdev.wikidot.com/sub

Edit: Here's a more in depth explanation with the matrix:
:[[1,2,1,2,1,2][2,0,0,0,0,1][1,0,0,0,0,2][2,1,2,1,2,1->[A]          //Store the tile data into [A]
:ClrHome           //Clear the homescreen
:For(A,1,4            //This will loop 4 times, making A = 1, 2, 3, and 4 as it adds one to A each time
:For(B,1,6            //This loops 6 times and changes B
:Output(A,B,sub("=87",1+[A](A,B),1                   //This displays a = if the corresponding spot in the matrix is zero, a 8 if the spot is one, and a 7 if the spot is two.  It places it at a spot relying on the values of A and B. :)
:End           //Ending the For(B loop
:End            //End of the For(A loop

Does this help? ;D

Edit x2: Meishe, ninjas are quite frequent when 5 people are viewing a topic. O0
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: {AP} on March 12, 2010, 10:53:45 pm
You know, I never thought about using sub( for displaying maps before. Nice thought.
However, you're working a little too hard on displaying the string map. xP
Nevermind. ;P
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 12, 2010, 10:54:15 pm
The 0, 1, and 2's are what lists and matrices can store, they can't hold actual characters like a string. So basically what he is doing is that putting those in and then code later interprets the numbers and places a character where those would be (either an 7, 8, or = in this case). Each number is also a specific character. The For( command is used to display this information. It is running along the string with the help of sub( (you should learn that command, its quite useful if you don't know what it does). I have actually written a couple detailed explanations on movement and collision detection here (http://ourl.ca/4255) (collision detection) and here (http://ourl.ca/4231) (movement). They might help explain some things too. :)

Dang, I was ninja'd.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: trevmeister66 on March 12, 2010, 11:08:05 pm
You know, I never thought about using sub( for displaying maps before. Nice thought.
However, you're working a little too hard on displaying the string map. xP
Nevermind. ;P
That's true, but you could use sub( to do a map where it moves every time you get near the edge (instead of doing typical full screen moves seen in most RPG's). I think Tifreak's pokemon purple and his RPG Starter Kit #2 both use this setup.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Cowmaster232 on March 12, 2010, 11:32:25 pm
Sure. :)

The 1s,2s,and 0s are references to the different tiles in the map.  The For loop(s) then display either a single character, or a group of 6 characters in the string example.  Basically the For loops let the sub( put the characters on the screen. :)

I'd recommend learning about the sub( command.  It's very important when dealing with strings, which happens quite frequently. :)
http://tibasicdev.wikidot.com/sub

Edit: Here's a more in depth explanation with the matrix:
:[[1,2,1,2,1,2][2,0,0,0,0,1][1,0,0,0,0,2][2,1,2,1,2,1->[A]          //Store the tile data into [A]
:ClrHome           //Clear the homescreen
:For(A,1,4            //This will loop 4 times, making A = 1, 2, 3, and 4 as it adds one to A each time
:For(B,1,6            //This loops 6 times and changes B
:Output(A,B,sub("=87",1+[A](A,B),1                   //This displays a = if the corresponding spot in the matrix is zero, a 8 if the spot is one, and a 7 if the spot is two.  It places it at a spot relying on the values of A and B. :)
:End           //Ending the For(B loop
:End            //End of the For(A loop

Does this help? ;D

Edit x2: Meishe, ninjas are quite frequent when 5 people are viewing a topic. O0

Yes that helped ;D

I have another question that has nothing to do with maps.
How do you set up stats like health, MP, money, ect. (properly)??   Are they just variables?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 12, 2010, 11:34:54 pm
Ya I know it's easy to get ninja'd...but I wasn't paying attention to who was viewing :P

For those I'm pretty sure you're best bet is using lists. I could be wrong though.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: trevmeister66 on March 12, 2010, 11:52:58 pm
Yes, all the stats (ie health, mp, money, strength, etc) are variables, and as meishe said, Lists are a good option for that, but if you don't plan on making too big of an RPG, you can just use the built in A-Z variables, but then you wouldn't be able to easily save your stats (as in have a save feature available for your RPG). That's why you should look into using custom named lists, which are highly unlikely to get written over.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Cowmaster232 on March 12, 2010, 11:59:14 pm
Yes, all the stats (ie health, mp, money, strength, etc) are variables, and as meishe said, Lists are a good option for that, but if you don't plan on making too big of an RPG, you can just use the built in A-Z variables, but then you wouldn't be able to easily save your stats (as in have a save feature available for your RPG). That's why you should look into using custom named lists, which are highly unlikely to get written over.

Ok thx. How does saving data work? Is it archived?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: {AP} on March 13, 2010, 12:08:35 am
As stated before, lists are your best bet.

All you'd need to set it up is something like this:
{LEVEL,CURRENT_HP,MAX_HP,CURRENT_MP,MAX_MP,MONEY→LCHAR
e.g.
{1,100,100,75,75,0→LCHAR
(Note: LCHAR can be replaced with any other name, like LSTATS or just LA)

From that point on, you can refer to a stat like this:
Say, if you need to get their level...
LCHAR(1) will get it. From there, say they leveled up just do LCHAR(1)+1→LCHAR(1)
LCHAR(4) will get the current MP and you can see the pattern.

If you want to save, you'll need a separate list for that or if there's only one save, then you can just leave the list as is.
Lists are on the calc regardless of whether you're in a program or not so if you only have one save, then a new char will overwrite the original list, and continuing would just use the list as is.
With multiple saves you'd do something like this:
LCHAR→LSAVE1 (for the first slot)
LCHAR→LSAVE2 (for the second, etc.)

Loading is the opposite,
LSAVE1→LCHAR
etc.

Throughout the program, all you'll need to refer to is LCHAR for stats and such though and only mess with the save files to save or load.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Cowmaster232 on March 13, 2010, 01:12:01 am
As stated before, lists are your best bet.

All you'd need to set it up is something like this:
{LEVEL,CURRENT_HP,MAX_HP,CURRENT_MP,MAX_MP,MONEY→LCHAR
e.g.
{1,100,100,75,75,0→LCHAR
(Note: LCHAR can be replaced with any other name, like LSTATS or just LA)

From that point on, you can refer to a stat like this:
Say, if you need to get their level...
LCHAR(1) will get it. From there, say they leveled up just do LCHAR(1)+1→LCHAR(1)
LCHAR(4) will get the current MP and you can see the pattern.

If you want to save, you'll need a separate list for that or if there's only one save, then you can just leave the list as is.
Lists are on the calc regardless of whether you're in a program or not so if you only have one save, then a new char will overwrite the original list, and continuing would just use the list as is.
With multiple saves you'd do something like this:
LCHAR→LSAVE1 (for the first slot)
LCHAR→LSAVE2 (for the second, etc.)

Loading is the opposite,
LSAVE1→LCHAR
etc.

Throughout the program, all you'll need to refer to is LCHAR for stats and such though and only mess with the save files to save or load.

Thanks, now I understand lists a whole lot better!

What if two programs have a list with the same name?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 13, 2010, 01:15:57 am
variables in TI-BASIC are global, so you can use the same list everywhere
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: {AP} on March 13, 2010, 03:34:26 am
DJ Omni is right. Lists can be used even outside of a program.

However, if you mean like what if two entirely different programs somehow use the same list, then one program's info will overwrite the other or it'll just try to take information from the list which will most likely result in errors or just plain wrong information unless the lists just somehow sync up. (Example, if you made a sequel that uses the character's data from the original or if you had to separate one game into several chapters due to size.)
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 13, 2010, 05:59:28 am
But, couldn't you techinically rig the lists so you could use them for multiple games as long as your defining everythign correctly?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: trevmeister66 on March 13, 2010, 06:47:47 am
But, couldn't you techinically rig the lists so you could use them for multiple games as long as your defining everythign correctly?
Yes, but unless the games are similar or related to each other, or you make the lists extra big, you're either going to use the wrong data or over write data for other games.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: ztrumpet on March 13, 2010, 11:38:14 am
Right.  However, there are 6+26+26^2+26^3+26^4+26^5 = 12356636 different list names, so it's unlikely that two programs use the same list. :)
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Radical Pi on March 13, 2010, 03:58:29 pm
Right.  However, there are 6+26+26^2+26^3+26^4+26^5 = 12356636 different list names, so it's unlikely that two programs use the same list. :)
Most of my programs use L1 ;)
But if you're naming the lists yourself, as long as you don't use some kind of generic name like LGAME, I doubt you'll ever run into the issue of two games fighting for the same save file, or whatever similar situation could arise.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: jsj795 on March 13, 2010, 04:30:58 pm
not only 26 base, but since you can use the number after the first character, isn't it more like 6+26+36^2+36^3+36^4+36^5 which is 62193776?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: meishe91 on March 13, 2010, 05:06:16 pm
Well ya, I just meant like one game uses L1(1-9) then another program uses L1(10-16) and so on. Wouldn't that work? Or is that what you were saying that you need to make them extra big?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: trevmeister66 on March 13, 2010, 07:13:53 pm
Right.  However, there are 6+26+26^2+26^3+26^4+26^5 = 12356636 different list names, so it's unlikely that two programs use the same list. :)
Yeah that's true, but some List names are used more often than others (ie LSTATS, LGAME, LSAVE, etc.) If you don't use a common List name, then you shouldn't have a problem.
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 13, 2010, 07:41:22 pm
btw I don't recommend using customly named lists as much as possible. Only use them when you have no choice or for data that is not accessed frequently, like save files. They take considerable amouts of memory. Imagine if your code contains L1 50 times and you decide to use LFINAL instead: You waste a big 250 bytes of RAM
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: ztrumpet on March 13, 2010, 09:55:50 pm
not only 26 base, but since you can use the number after the first character, isn't it more like 6+26+36^2+36^3+36^4+36^5 which is 62193776?
Great point!  I forgot about numbers.  ;D

Oh, and there's also Theta!  :D
6+27+37^2+37^3+37^4+37^5 which is 71270173

Anyway, DJ since L1 is the same size as any one letter long list it doesn't matter there.  Actually since you can omit the little list L when storing a whole list to it, it will actually be smaller! ;D
Oh, and the L1 to L6 tokens are 2 bytes so you'd only waste 200 bytes of RAM.   :)
Does this make sense?
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 13, 2010, 10:08:10 pm
oh yeah right I forgot about removing the L thing x.x
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: Builderboy on March 13, 2010, 10:12:53 pm
...the L1 to L6 tokens are 2 bytes...

:O Wow i never knew this!  haha you learn something new every day ;D
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: ztrumpet on March 13, 2010, 10:16:03 pm
...the L1 to L6 tokens are 2 bytes...

:O Wow i never knew this!  haha you learn something new every day ;D
Actually all the tokens from the Vars menu, L1 to L6, and u, v, and w are all 2 bytes.  :)
Title: Re: Lots of Questions (I'm a newb ^_^)
Post by: DJ Omnimaga on March 13, 2010, 10:35:53 pm
i wonder why x.x