Forums

Topic: Petit Computer

Posts 2,501 to 2,520 of 9,620

ejamer

mystman12 wrote:

Could someone explain what DIM and DATA are for?

DIM is short for "dimension", and is used to create an array of the size you want. (An array is basically a variable with one name that can hold many different values.)

For example, if you were working on a program that would play a simple card game you might write code like the following:

DIM DECK(52);
FOR I=0 TO 51
DECK(I) = I+1
NEXT I

FOR J=0 TO 51
SWAP DECK(J), DECK(RND(52))
NEXT J

The first part would create an array the size of a deck of cards, and then gives unique values to each entry in the array. The second part "shuffles" the deck by swapping each array value with one other randomly selected array value.

Some important things to know about arrays and the DIM statement:

  • you can only use DIM once for each array, after that the array is permanently set at the specified size; trying to use DIM a second time with the same variable will cause your program to crash with an error
  • if you treat a variable like an array without using DIM, then Petit Computer acts like you used DIM arrayname(10) by default

So what is DATA all about? Well, the first thing to know is that you don't use DATA on it's own: you also need to understand the READ and RESTORE commands.

You may want to store information that doesn't change in your program Maybe this means map data, or music data, or any other kind of information that won't change. The RESTORE/READ/DATA commands come in really hand here! They let you separate all that non-changing information from the body of your coding. DATA statements don't do anything other than contain a list of comma-separated data values. They are often found at the very bottom of a program, sitting somewhere after the END statement. The real action takes place when READ is used - this command tells Petit Computer to return the next DATA value and store it in a variable, ready to be used for whatever purpose you want.

DIM SUIT$(4);
FOR I=0 TO 3
READ SUIT$(I)
NEXT I
END
DATA "Diamonds", "Hearts", "Clubs", "Spades"

One last note: if you are using READ/DATA commands, then you need to understand what value will be returned at what time. When you use READ, Petit Computer starts looking from the beginning of the program for the first DATA statement, and then takes the first value from that statement. Every time you use READ after that point in time, it just jumps to the next comma-separated value, and if there is no next value in that DATA statement it will jump to the next line that does have a DATA statement in your program. If you use READ and there are no DATA statements left to read from, an error occurs.

This brings up two interesting points: you might need to add a "dummy" value at the end of your DATA statement so you know when to stop reading, and you should understand that you can (at any time) use the RESTORE command to change where Petit Computer will look for the next DATA value.

@START
READ L$
IF L$=="-1" THEN RESTORE @LETTERS: READ L$
PRINT "Letter "; next_letter$
INPUT "Again"; q$
IF q$=="Y" GOTO @START
PRINT "Bye!"
END
DATA "a", "b", "c"
@LETTERS
DATA "d", "e", "f", "-1"

Hope this all helps.

ejamer

Nintendo Network ID: ejamer

ejamer

randomouscrap98 wrote:

...
Edit: Whoops, someone already said that!
...

So I beat you to the first question, you beat me to the second. Guess we're even?

Edited on by ejamer

ejamer

Nintendo Network ID: ejamer

mystman12

Okay, thanks, I think that helped a little, but I keep seeing stuff like "FOR I=0 TO 51", what is that for?

I like makin' games!
Future Pinball games!
Petit Computer games!!
and SmileBASIC games!
Waiting for Kirby Air Ride 2. One day, it will come. One day...

3DS Friend Code: 0259-0292-5888 | Nintendo Network ID: mystman12 | Twitter:

ejamer

mystman12 wrote:

Okay, thanks, I think that helped a little, but I keep seeing stuff like "FOR I=0 TO 51", what is that for?

Without trying to brush you off, if you don't understand how a FOR-NEXT statement works then you need to do some basic learning before asking questions.

Visit these links and read through the tutorials:
http://petitcomputerbasic.blogspot.com/
http://www.3dsbuzz.com/3ds-forum/threads/petitcomputer-tutori...
http://www.gamefaqs.com/boards/663843-petit-computer/63494042

Those are the best links I could find on short notice, although someone else might be able to point you to other online resources. Don't look for specific answers yet - just learn everything they talk about because you will need to know it all.

Post question when stuff doesn't make sense, but you'll need to make an effort to get started. The good news: it's worth the effort, and you'll be programming in no time if you take the time to walk through some of these tutorials!

ejamer

Nintendo Network ID: ejamer

mystman12

Okay, thanks! I do know about some of the basics (Such as variables, printing, GOTO, etc.) and I have started learning about sprites, but I guess there is sill a lot more to go! I'll start reading all of this!

Edit: Oh, wait! I've actually used one of those tutorials before, and now some of the stuff I've forgotten is coming back to me!

Edited on by mystman12

I like makin' games!
Future Pinball games!
Petit Computer games!!
and SmileBASIC games!
Waiting for Kirby Air Ride 2. One day, it will come. One day...

3DS Friend Code: 0259-0292-5888 | Nintendo Network ID: mystman12 | Twitter:

ejamer

mystman12 wrote:

... variables, printing, GOTO, etc. ...

Great start! Add in subroutines, IF-THEN conditions, and FOR-NEXT loops and you've got a pretty good background for simple programs.

Sprites and graphics are really a whole leap above that. Not that they are hard - Petit Computer makes it pretty easy to start working with sprites, actually - but there is another layer of learning involved and plenty of trial-and-error moments. I'm a complete novice in that regard.

ejamer

Nintendo Network ID: ejamer

steriaca

Anybody thinking of a date simulater game? (Or prehaps a hibread game with date simulater aspects like Sakura Wars) That is one gendra of game I have yet seen in Petit Computer.

My Friend Code is 3368-1310-0690.

Hairmanban19

randomouscrap98 wrote:

If anyone's getting tired of me polluting this thread with all these songs, please let me know. Here's the Underwater theme from Super Mario Bros.

Untitled

More great music! I would never get tired of you making music!

...

3DS Friend Code: 3136-7615-5907

Gimmemorecoinz

Wow suddenly after waiting 16 hours i finally got reply, thanks to everyone who commented on my question.
I didn't realize.. that the second dimension in the multidimensional array would start at 0 by default.. everything is offset by 1 >.< That makes it confusing.
That's usually why in these languages I Just cheat by making my arrays one size larger than they need to be, and when that didn't work I made it even bigger...
guess that I forgot to account for the second dimension of that array.. figures i guess o.0

I'm making an AI still and it's slowly coming along but I need help writing code which helps me to parse some input. I think I know where I went wrong now though with my last scripting thing.

@randomouscrap I'd be thrilled if you could manage to do a dkc gb mix remake thing.
Has anyone here played with fami tracker i'm finding it hard to use but I used to use it and I was ok with it. I found more out about it today then ever before..
I'm thinking of doing some 8 bit chiptune related stuff.. unfortunately it doesn't have an option to export to MML I don't think.
Are there any trackers that can export to MML?

who here wants to help with my lttp thing?
I'm sorry that I haven't still looked at Coral Maze yet u_u I've been busy. But I'll take a look at it today. I'm really good at programming logic so it shouldn't take me more than a few minutes to figure out how it works, and then I can spend a few hours adding to it yay! ^^;

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

Hairmanban19

ejamer wrote:

mystman12 wrote:

Okay, thanks, I think that helped a little, but I keep seeing stuff like "FOR I=0 TO 51", what is that for?

Without trying to brush you off, if you don't understand how a FOR-NEXT statement works then you need to do some basic learning before asking questions.

Visit these links and read through the tutorials:
http://petitcomputerbasic.blogspot.com/
http://www.3dsbuzz.com/3ds-forum/threads/petitcomputer-tutori...
http://www.gamefaqs.com/boards/663843-petit-computer/63494042

Those are the best links I could find on short notice, although someone else might be able to point you to other online resources. Don't look for specific answers yet - just learn everything they talk about because you will need to know it all.

Post question when stuff doesn't make sense, but you'll need to make an effort to get started. The good news: it's worth the effort, and you'll be programming in no time if you take the time to walk through some of these tutorials!

Thank you for posting this! It is really helping me to learn BASIC!

Edited on by Hairmanban19

...

3DS Friend Code: 3136-7615-5907

VincentFaraday

I'm planning on making a program this summer that can solve differential equations by building onto my quadratic solver. I know that petit computer can't float very many numbers, but I thought that this would be a fun thing to do this summer. When it comes to math, I have finished Calculus and I have just finished a course on differential equations. If anybody here has an expertise in this area of programing/mathematics, then let me know. :]

I wish I was on the Enterprise.

3DS Friend Code: 1048-8460-1195

Hairmanban19

@Swordx will Dungeon Adventure have a saving function?

...

3DS Friend Code: 3136-7615-5907

VincentFaraday

VincentFaraday wrote:

I'm planning on making a program this summer that can solve differential equations by building onto my quadratic solver. I know that petit computer can't float very many numbers, but I thought that this would be a fun thing to do this summer. When it comes to math, I have finished Calculus and I have just finished a course on differential equations. If anybody here has an expertise in this area of programing/mathematics, then let me know. :]

I forgot to mention that the reason that I am going to build on my quadratic solver (which is on the qr sharing page) was so that I could use that program to find the roots of characteristic equations of certain DEs.

I wish I was on the Enterprise.

3DS Friend Code: 1048-8460-1195

Gimmemorecoinz

VincentFaraday wrote:

VincentFaraday wrote:

I'm planning on making a program this summer that can solve differential equations by building onto my quadratic solver. I know that petit computer can't float very many numbers, but I thought that this would be a fun thing to do this summer. When it comes to math, I have finished Calculus and I have just finished a course on differential equations. If anybody here has an expertise in this area of programing/mathematics, then let me know. :]

I forgot to mention that the reason that I am going to build on my quadratic solver (which is on the qr sharing page) was so that I could use that program to find the roots of characteristic equations of certain DEs.

Wow you're picking one project to do? I've got atleast 12 lined up o.o but not all for petit computer and I'm constantly in over my head with trying to learn stuff xD

Got a project? PM ME on here!
Youtube: lostkitty64x
Want help with coding? PM ME! PM ME PM ME!! XD
FC: WIll post later.
Systems I own: ds lite, 3DS, PC/gaming, steam platform. I play alot of games. Just ask ! Minecraft anyone? :D

randomous

@VincentFaraday You know, I was planning on making a graphing application myself. One of the things I need in order to make it work a little more nicely is a DE solver. If you manage to make it work, it would be really cool if I could use it for the grapher.

randomous

VincentFaraday

randomouscrap98 wrote:

@VincentFaraday You know, I was planning on making a graphing application myself. One of the things I need in order to make it work a little more nicely is a DE solver. If you manage to make it work, it would be really cool if I could use it for the grapher.

Well, a DE solver won't help you graph anything, but it could save you some time when dealing with homogenous linear equations (which is what I want to work on first). I'm also interested making graphing software for petit computer, but as I am sure you know petit computer can't handle it when x>10^6 (I found this out when I wrote a program that could calculate factorials and the program crashed at 10!) and that it can't float very many numbers. In spite of all this it is possible to create a semi-decent graphing program. I thinks it's great that there is someone else out there that is working on math applications for this software.

I wish I was on the Enterprise.

3DS Friend Code: 1048-8460-1195

randomous

@VincentFaraday I was going to use the DE solver to calculate min/maxes for equations. What I want to be able to do is analyze an equation and try to best determine an appropriate range for it. Otherwise, the user would have to set a range for each equation. For instance, if I have:

y=sin(X)

VS:

y=17sin(x)

One of those is going to look ugly if the same range is used for both.

randomous

VincentFaraday

randomouscrap98 wrote:

@VincentFaraday I was going to use the DE solver to calculate min/maxes for equations. What I want to be able to do is analyze an equation and try to best determine an appropriate range for it. Otherwise, the user would have to set a range for each equation. For instance, if I have:

y=sin(X)

VS:

y=17sin(x)

One of those is going to look ugly if the same range is used for both.

Oh, I understand. You are planning on using the first derivative test to find max /min. Yeah, I can see how you would want a program that can calculate derivatives. If I can write a program that is fairly good at finding dy/dx I'd be glad to share it with you.

I wish I was on the Enterprise.

3DS Friend Code: 1048-8460-1195

Please login or sign up to reply to this topic