DSiWare Forum

Topic: Petit Computer Tutorials

Showing 21 to 32 of 32

AuthorMessage
Avatar

Romano

21. Posted: Tue 6th Nov 2012 13:32 GMT

i need a tutorial on how to use the d-pad for my OS to select categories on the menu, and the A button to go into that categorie or play that game. :I

Edited on Tue 6th November, 2012 @ 14:37 by Romano

Linput-3DS friend code: 4725-8494-2702
Pokemon White 2 pal-pad code: 1979 9213 5591

I'm currently looking for some peeps to make SALLY a website, facebook, and email. If anyone does this u will be mentioned as a producer in the SALLY OS credits! :)

AuthorMessage
Avatar

Romano

22. Posted: Tue 6th Nov 2012 15:39 GMT

NVM

Linput-3DS friend code: 4725-8494-2702
Pokemon White 2 pal-pad code: 1979 9213 5591

I'm currently looking for some peeps to make SALLY a website, facebook, and email. If anyone does this u will be mentioned as a producer in the SALLY OS credits! :)

AuthorMessage
Avatar

Romano

23. Posted: Tue 6th Nov 2012 17:17 GMT

OH btw if someone could teach me how to make an AI chatting thing for my OS, that would be great. Also, could this tutorial plz be in a QR code so i can mention u in the credits of SALLY, my OS?

Linput-3DS friend code: 4725-8494-2702
Pokemon White 2 pal-pad code: 1979 9213 5591

I'm currently looking for some peeps to make SALLY a website, facebook, and email. If anyone does this u will be mentioned as a producer in the SALLY OS credits! :)

AuthorMessage
Avatar

smartman789

24. Posted: Wed 7th Nov 2012 02:02 GMT

I just made a website for Petit Computer tutorials.
Here's a link: http://petitcomputertutorials.webs.com/
I hope you guys can make it a place where people can learn a lot about programming in BASIC.

smartman789

AuthorMessage
Avatar

heatguts

25. Posted: Sat 22nd Dec 2012 15:58 GMT

to linput 14:

check my os. its inspired off of yours, and i intend to put you in "special thanks"
but yeah, it has button controls.
LOCATE 14,0
PRINT"(First menu item)"
'repeat for each item
@LOOP
B=BUTTON(1)
IF B ==1 (UP) THEN IF SEL(SEL is the selection) >1 THEN SEL=SEL-1
'same for down, with the IF SEL>1 to IF SEL<(max menu item)
LOCATE 14(I spaced out my x values),SEL(So if SEL is one, it will be one, or if two, it will locate two)
PRINT "-->"
IF B==16 THEN GOTO @SELECT
GOTO @LOOP

@SELECT
IF SEL==1 GOTO @(Menu item one)
'And so on.

Edited on Sat 22nd December, 2012 @ 15:59 by heatguts

So what if there's no Mega Mans in Metroid?
That doesn't mean we can't have metroids in Mega Man.

3DS Friend Code: 4511-1723-4299

AuthorMessage
Avatar

Philip

26. Posted: Sat 22nd Dec 2012 18:44 GMT

Alright, I'm just gonna make a quick thing on how to assign DATA to an array. (WARNING: Lengthy post.)

A quick run down on arrays:
Let's say, if you set an array like this:
DIM WIT$(20)
(hehehe, dim wit)
Then in the WIT$ variable, you could store 20 values, from WIT$(0) to WIT$(19), as PTC starts counting from zero.
If you set it like this:
DIM WIT$(20,20)
Then you'll have 20 values each within those 20 values. Let's see it like this:
20x20=400 values
If you set WIT$ like above, then set a value:
WIT$(19,0)="derp"
Then the first value of the 20th first value (I call it that as I can't think of anything else to call it) would be set to "derp".
Now, if you then did this:
WIT$(19,1)="herp"
Then the second value of the 20th first value would be "herp".
Now, do this:
PRINT WIT$(19,1)" "WIT$(19,0)
If you did it correctly, "herp derp" should appear on the console.
Remember: You can't set an array to the same variable twice! This will result in an error. In order to set another array to the variable, use a CLEAR command to wipe out all variables.
Now that you (hopefully) now know how arrays work, let's get on to the main entree.
First, set an array:
DIM VNAME$(X,Y)
Where 'VNAME' is the name of your array, X is the first dimension and Y is the second.
For this tutorial, let's just use one dimension to keep things simple. Also, our array needs a name of course... well, you can't go wrong with "MARIO"!
DIM MARIO$(3)
Now we can set 3 values to MARIO$. Now, for the DATA!
DATA "NES"
DATA "SNES"
DATA "N64"
(Yes, those are the names of Nintendo's classic consoles.)
Now, let's use a FOR-TO-NEXT loop:
FOR I=0 TO 2
This will repeat the loop 3 times until I=2. Confusing?

Code in loop being executed 1st time: I=0
Code in loop being executed 2nd time: I=1
Code in loop being executed 3rd time: I=2

Remember, as I said before, PTC starts counting from zero.
Now, to set the DATA to MARIO$.
FOR I=0 TO 2
READ MARIO$(I)
NEXT
Now, before I confuse you too much, let me explain READ.
READ will read a piece of DATA and assign the DATA to a variable. A single READ command will read a single string of DATA. That's why we need to use several READ commands to read several strings of DATA, and this is best done with a FOR-TO-NEXT loop.
Say, we omitted the FOR-TO-NEXT loop altogether and only left the READ command. It would only read the first DATA statement, and since I=0 because there's no FOR-TO-NEXT loop, MARIO$(I) will result in MARIO$(0), and the READ command will assign the "NES" data to MARIO$(0), leaving MARIO$(1) and (2) blank.
Remember, X variables will record numbers, and X$ variables are alphanumeric, so they record strings. Blank X variables will have a value of 0, and blank X$ variables will simply be blank, period.
If we make the READ command happen another time, it will advance to the next DATA statement, and set "SNES" to MARIO$(1), provided we set the READ command to set it to (1) and not (0), either manually or though the FOR-TO-NEXT loop. Repeat it a third time, "N64" will be set to MARIO$(2), following the same rules as mentioned before.
Also, you should set a CLEAR command at the beginning of the code, so you can run the program more than once and not confuse PTC with a duplicate definition. Our code should now look like this:

CLEAR
DIM MARIO$(3)
DATA "NES"
DATA "SNES"
DATA "N64"
FOR I=0 TO 2
READ MARIO$(I)
NEXT

Now, in order to see if it worked, we should print out the MARIO$ variable's values. Change te FOR-TO-NEXT loop to this:
FOR I=0 TO 2
READ MARIO$(I)
PRINT MARIO$(I)
NEXT

Now, run the program. If you did this correctly, you should get this:

NES
SNES
N64
OK

I could go into more detail, but my brain hurts too much. And if you still don't understand what I'm saying, I don't blame you. I'm terrible with words.

Edited on Sat 22nd December, 2012 @ 18:47 by Philip

Veeveeveeveeveevee

3DS Friend Code: 0559-7022-5853

AuthorMessage
Avatar

Romano

27. Posted: Wed 2nd Jan 2013 17:04 GMT

Wow based off mine? That's awesome! Anyways, could somebody help me with a breakout game I'm making? It won't have the bricks to break at the top, it's just to help me learn to make games. I need help with the sprites. I don't know how to move them with the d-pad, and don't know how to make he sprites different sizes (like the ball and the paddle). I ALSO don't know how to do sprite collisions or make the ball act like, well, a ball. :/

Linput-3DS friend code: 4725-8494-2702
Pokemon White 2 pal-pad code: 1979 9213 5591

I'm currently looking for some peeps to make SALLY a website, facebook, and email. If anyone does this u will be mentioned as a producer in the SALLY OS credits! :)

AuthorMessage
Avatar

snoremac

28. Posted: Sat 19th Jan 2013 04:20 GMT

sorry linput14 but i only know ANSII art but as i get learning on sprites i could help you then if someone hasnt already
BTW i am trying to update my DIRECTORY OS by putting buttons in and i dont know how either

Cameron Stover VVVVVVVVVVVVVV ALSO VVVVVVVV and i like trains (BOOM!) also minecraft and trollface!

3DS Friend Code: 4854-7026-5042

AuthorMessage
Avatar

-Angel-

29. Posted: Sun 27th Jan 2013 01:38 GMT

I'm writing tutorials for PetitComputer, and they start with the BASICs (get the pun?) then go to the more complex stuff. Depending on when you read it, it might be unfinished, or done. I'm adding to it as I learn, myself. Here's the URL:

http://www.petitcomputerbasic.blogspot.com

Also, here's the first part to it, to get you started. But, I won't post EVERYTHING here, just the first part, then you can just visit my blog. :D

PART 1 Learning Some Basic Commands For Your First Program:

In this tutorial you will be learning SMILEBASIC, a programming language. SmileBoom says that you are using BASIC, but they're wrong. BASIC is a family of programming languages, many versions that are very similar to each other have been created. SMILEBASIC was created by SmileBoom, but it's very similar to other BASIC programming languages. So, if you were to write a program with something that used another type of BASIC, then you'd probably still be able to understand most of it.

So, let's start with the basics (< See the pun there? The programming language is SMILEBASIC.) then we'll keep working up until it gets to the really complex, complicated stuff. So, you're basically about to learn a different language, in fact, you are, this is just a programming language. So, this will be different than just simply learning "Hola" means "Hello." But, once you get the hang of it, and you are able to control your DS and make something happen, you'll feel like you are so powerful, and can do anything with that little stylus in your hand!
So, I bet you're wanting to learn how to do, and get started, on something! Well, let's start with one very simple command: the print command. This command is used to print text in your little program. So, pull out your DS, open PetitComputer, and go into Edit mode. In the first line type this:

print "I'm learning my first command!"

Don't forget the quotes, because if you just have, "print I'm learning my first command!" then there'll be an error. So, after you've typed this, go into Run mode. Chances are, nothing happened. Well, that's because you need to run your little program you've got started. You can do this by typing, "Run" then pressing the A button, or pressing Enter. Then this should pop up:

I'm learning my first command!
OK

So there you have it! You did it! But don't worry, if this didn't happen, that's okay. Just go back and make sure you did everything correctly. If you want something other than "I'm learning my first command!" to pop up, then just replace the words below:

print "Type whatever you want here"

Way to go! You've learned one of the many, many commands on PetitComputer! :D
Well, I'm sure you're getting annoyed with the:

PetitComputer ver2.2
SMILEBASIC 1048576 bytes free
(C)2011-2012 SmileBoom Co.Ltd.
READY

What this is is just what version of PetitComputer it is, the programming language, how much space is free, and the copyright. Lastly the, "READY" is just stating that the program is ready to operate. If you want to get rid of this, and all other text on your program, type in in run mode:

CLS

That's all you have to do. Then, all that text will disapear, and only, "OK" will be left. But be careful! It'll get rid of ALL the text, so if there's something important you want to keep, don't do this! (I honestly don't know what you would want to keep on your DS screen though :P) So, if you wanted to have everything erased, then some text to pop up you would type this in edit mode:

CLS
print "I don't know what to put in these quotes"

Then go into run mode and run it. Then all you should be left with is:

I don't know what to put in these quotes
OK

Now that's much neater isn't it? No I'll show you how to save and load your program. First, make sure everything's the way you want it in Edit Mode. Once everything's proofread, go into Run Mode and run it. Then type in:

Save "Test"

I saved it as "Test" but, you can call it whatever you like. Then to load your program simply type in Run Mode:

Load "Test"

It's as simple as that! If you forgot your file name, then press the X on the upper right and return to the Home Menu (But make sure you saved your work first if you were doing something; if you don't it'll be lost!). Then click View Gallery and all your programs, along with the sample ones, are in there. So if you called your program "Test" You'll see it as, "PRG : Test".

I think that'll be all for the first part of this tutorial! Thank you for reading, I hope this has helped you on your quest to making programs! :D

Try to accomplish this before going to the next part:

1. Clear your screen
2. Print something on your screen with the print command
3. Save your program
4. Be happy that you made a program! ^-^

Edited on Sun 27th January, 2013 @ 01:44 by -Angel-

-Angel-

AuthorMessage
Avatar

ChangeV

30. Posted: Wed 20th Feb 2013 05:47 GMT

Here are 3 simple ways to slide text window.
all 3 shows basic idea of using different methods(sprite, BG layer, Graphic layer)

they simply put(and slide) window on top of grass field(which is rear BG layer).
and text output is simply done by PNLSTR command.

press any button to open and close text window.

here is sprite version.
Untitled

ACLS
CLEAR

'turn off bottom panel.
PNLTYPE "OFF"

'make some grass field.
BGPAGE 1
BGFILL 1,0,0,31,23,33,8,0,0

'select lower screen for sprites.
SPPAGE 1

'make 64x32 sprite with white color (&HF).
'sprite bank name for lower screen is "SPS0" and "SPS1".
'64x32 size sprite is 32 blocks of tile.
CHRINIT "SPS0"
FOR I=0 TO 31
CHRSET "SPS0",I,"F"*64
NEXT

'setup 2 big 64x32 sprites.
'set order of priority to the behind of console.
'so text will appear on top of sprites.
SPSET 0,0,0,0,0,1,64,32
SPSET 1,0,0,0,0,1,64,32

'scale 200%
SPSCALE 0,200
SPSCALE 1,200

'put them outside of bottom part of screen.
SPOFS 0, 0,192
SPOFS 1,128,192

@MAINLOOP

'wait for button press
FOR I=0 TO 1:I=BUTTON():NEXT

'move sprites up slowly using interpolation time.
SPOFS 0, 0,128,10
SPOFS 1,128,128,10

'wait until sprite has finished moving.
FOR I=0 TO 1:I=!SPCHK(0):NEXT

'put some text
PNLSTR 1,18,"This is first line.",14
PNLSTR 1,20,"This is second line.",14
PNLSTR 1,22,"This is third line.",14

'wait for button press.
FOR I=0 TO 1:I=BUTTON():NEXT

'erase text with blank
PNLSTR 0,18," "*32,14
PNLSTR 0,20," "*32,14
PNLSTR 0,22," "*32,14

'move sprites down slowly using interpolation time.
SPOFS 0, 0,192,10
SPOFS 1,128,192,10

'wait until sprite has finished moving.
FOR I=0 TO 1:I=!SPCHK(0):NEXT

GOTO @MAINLOOP

it uses 2 big (64x32) sprites and they act as window.
sprite's priority has changed, so window sprites appear under the text.
by the way, you can set/change/load sprite for bottom screen.
sprite bank name for bottom screen is "SPS0" and "SPS1"
for example: LOAD "SPS0:MYSPRITE"
(note:unlike upper screen which has 512 sprites, bottom screen has only 118 different sprites.)


here is Graphic version.
Untitled

ACLS
CLEAR

'turn off bottom panel.
PNLTYPE "OFF"

'make some grass field.
BGPAGE 1
BGFILL 1,0,0,31,23,33,8,0,0

'select lower screen for Graphic.
GPAGE 1

'set Graphic priority to the behind of console
'so text will appear on top of Graphic layer.
GPRIO 1

@MAINLOOP

'wait for button press
FOR I=0 TO 1:I=BUTTON():NEXT

'start drawing line from bottom part of screen.
'fill upward.
'since filling with single line is too slow,I used x4 thick filled line.
FOR I=192 TO 128 STEP -4
GFILL 0,I,255,I+3,15
VSYNC 1
NEXT

'put some text
PNLSTR 1,18,"This is first line.",14
PNLSTR 1,20,"This is second line.",14
PNLSTR 1,22,"This is third line.",14

'wait for button press.
FOR I=0 TO 1:I=BUTTON():NEXT

'erase text with blank
PNLSTR 0,18," "*32,14
PNLSTR 0,20," "*32,14
PNLSTR 0,22," "*32,14

'erase window by drawing line with clear color 0.
'starting from top part of window. erasing downward.
'it will look like window is moving down.
'for speed, i used x4 thick filled lines.
FOR I=128 TO 192 STEP 4
GFILL 0,I,255,I+3,0
VSYNC 1
NEXT

GOTO @MAINLOOP

it simply draws white filled box on bottom.
as you draw more filled box upward, it will look like sliding window.
window box is erased with another box with clear color 0
Graphic layer's priority has changed, so Graphic window appears under the text.


here is BG version.
Untitled

ACLS
CLEAR

'turn off bottom panel.
PNLTYPE "OFF"

'select lower screen for BG.
BGPAGE 1

'make some grass field on rear BG layer..
BGFILL 1,0,0,31,23,33,8,0,0

'make window box just outside of bottom part of screen.
'use foreground BG layer, so it will hide grass field.
'using white blocks.
BGFILL 0,0,24,32,31,15,0,0,0

'and you can add cool window border frame if you want..
BGPUT 0,0,24,532,1,0,0
BGFILL 0,1,24,30,24,536,1,0,0
BGPUT 0,31,24,533,1,0,0
BGFILL 0,0,25,0,30,539,1,0,0
BGFILL 0,31,25,31,30,537,1,0,0
BGPUT 0,0,31,535,1,0,0
BGFILL 0,1,31,30,31,538,1,0,0
BGPUT 0,31,31,534,1,0,0

'this BG layer will wait outside of bottom part of screen and is ready to scroll up.

@MAINLOOP

'wait for button press
FOR I=0 TO 1:I=BUTTON():NEXT

'scroll foreground BG layer up slowly using interpolation time.
BGOFS 0,0,64,10

'wait until foreground BG layer has finished moving.
FOR I=0 TO 1:I=!BGCHK(0):NEXT

'put some text
PNLSTR 1,18,"This is first line.",14
PNLSTR 1,20,"This is second line.",14
PNLSTR 1,22,"This is third line.",14

'wait for button press.
FOR I=0 TO 1:I=BUTTON():NEXT

'erase text with blank
PNLSTR 0,18," "*32,14
PNLSTR 0,20," "*32,14
PNLSTR 0,22," "*32,14

'scroll foreground BG layer down slowly using interpolation time.
BGOFS 0,0,0,10

'wait until foreground BG layer has finished moving.
FOR I=0 TO 1:I=!BGCHK(0):NEXT

GOTO @MAINLOOP

it uses foreground BG layer and use it as window.
draw window box just outside of bottom of screen.
(you can add cool frame on window layer if you want)
it waits outside and will scroll up/down as needed.

ChangeV

AuthorMessage
Avatar

randomouscrap98

31. Posted: Sat 30th Mar 2013 05:41 GMT

So @ramstrong said I should put this here instead of on the main thread, so here it goes.

Untitled

I made an auto-formatted dialog-box function set with a demo for Petit Computer. You know when you have a bunch of text that you want to output, but if you just keep printing and printing, it gets cut off at ugly places (like the middle of words) and just doesn't look right? This program is an example of how to make text fit within a box without knowing the contents of said text. This example code contains some functions which allow you to:

-Bring up a dialog box @SHOWDIALOGBOX
-Hide the dialog box @HIDEDIALOGBOX
-Clear the dialog box @CLEARDIALOG
-Make the dialog box wait @WAITDIALOG
-Show the text contained within SAY$ @MAKEDIALOG
-Show a yes/no box which "returns" the user's choice @YESNOCHOICE

Basically, showing/hiding/clearing/waiting aren't very exciting (but still necessary). The part that really does what you want is MAKEDIALOG. To use MAKEDIALOG, just put the text you want to print into the variable SAY$ and then use GOSUB @MAKEDIALOG. MAKEDIALOG will then "parse" (kind of) the variable SAY$ and figure out where it needs to cut off the dialog and move to the next line, and when it needs to halt and wait for the user to continue when the box is full. YESNOCHOICE can simply be called with GOSUB @YESNOCHOICE. After it is run, the variable CHOICE will contain the user's action. 1=yes, 0=no. The code contains a short demo which shows how to use the various functions and such. The demo will run just by starting the program, so don't feel like you have to add anything in order to see something happen. Feel free to use it for any of your games.

UntitledUntitledUntitled

The image shown at the top can be done by simply storing the entire saying into the string SAY$, for instance:

SAY$="Here is an example of some really long text. This is all just one long thing located in SAY$."
GOSUB @MAKEDIALOG

Notice that what I actually put in SAY is longer than what appears in the picture. This is because the dialog box saw that it could not fit the entire string into the box, and so it is waiting for user input (A or B) before printing the rest of the contents of SAY$. After you set the variable, just call MAKEDIALOG, like I've done above.

Edited on Mon 1st April, 2013 @ 22:36 by randomouscrap98

randomouscrap98

AuthorMessage
Avatar

TexMurphy

32. Posted: Sun 21st Apr 2013 23:42 BST

Scolling background under sprite can be accomplished with two two-dimensional arrays. This is accomplished by copying one side of the first array and placing it on the opposite side in the second array. Then copy what is left of the first array. The sprite remains stationary in the center of the screen. This example makes the sprite look like its walking right, but the background is scrolling left under his feet. But, there must be a simpler way?

CLEAR: BGCLR: ACLS: SPCLR 'Clean up the screen
WID=20: DEP=20
DIM BMAP(WID, DEP)
DIM CMAP(WID, DEP)
GOSUB @READARY: GOSUB @DRAWBG: GOSUB @DRAWSP
SPOFS 0,70,70

@MAIN
IF BUTTON()==8 THEN GOSUB @MOVERIGHT
WAIT 10
SPANIM 0,1,5
GOTO @MAIN

'SETUP BACKGROUND MAP
@READARY
RESTORE @BGDATA
FOR Y=0 TO DEP-1
FOR X=0 TO WID-1
READ BMAP(X,Y)
NEXT X
NEXT Y
RETURN

@BGDATA
DATA 32,32,32,194 '...Continue with a total of 20 columns and 20 rows of background DATA
RETURN
@DRAWBG
FOR I=0 TO DEP-1
FOR J=0 TO WID-1
BGPUT 0, J, I, BMAP(J,I),8,0,0
NEXT J
NEXT I
RETURN
@MOVERIGHT
FOR Y=0 TO DEP-1
CMAP(DEP-1, Y) = BMAP(0,Y)
NEXT Y
FOR X=0 TO WID-2
FOR Y=0 TO DEP-1
CMAP(X,Y) = BMAP(X+1,Y)
NEXT Y
NEXT X
GOSUB @COPYMAP: GOSUB @DRAWSP: GOSUB @DRAWBG
RETURN

@COPYMAP
FOR Y=0 TO DEP-1
FOR X=0 TO WID-1
BMAP(X,Y) = CMAP(X,Y)
NEXT X
NEXT Y
RETURN

@DRAWSP
SPSET 0,64,0,0,0,0
SPANIM 0,4,5
SPOFS 0,70,70
RETURN

Edited on Sun 21st April, 2013 @ 23:51 by TexMurphy

TexMurphy