DSiWare Forum

Topic: Petit Computer Tutorials

Showing 81 to 97 of 97

AuthorMessage
Avatar

MechaPikachu

81. Posted:

@DR4IG Move your question to the main thread with a code snippet and tag me. This thread is for finished tutorials.

These are not the codes you are looking for.

AuthorMessage
Avatar

GraphicGenius

82. Posted:

@Gimmemorecoinz why did you stop the tutorials?

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens. Wait was that just a joke?

3DS Friend Code: 1478-3545-5136 | Nintendo Network ID: GreatGamer123

AuthorMessage
Avatar

Gimmemorecoinz

83. Posted:

@GraphicGenius I got very busy. Tutorials will be done soon. Don't worry :D

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

AuthorMessage
Avatar

Dsi_Mario

84. Posted:

Today I will be talking about GRAPHICS. So, let's execute two lines of code (ACLS clears everything)
ACLS
GFILL 0,0,1000,1000,5
Now, what happened? It should have filled the screen with the color 5. So, if you replace the 5 with a 1, it will fill the screen with color 1, and so on.
Let's break GFILL down.
GFILL says to your DS, "Execute the GFILL command"
The first number (0) is the x starting point.
The second number (0) is the y starting point.
The third number (1000) is the x ending point.
The fourth number (1000) is the y ending point.
The fifth number (5) is the color.
So, that line of code is making the computer fill in the screen starting at 0,0 and ending at 1000,1000.
The DS screen is 255 by 191, but you can do 1000,1000 and it will fill it all in.
If you want to see the colors of GRAPHICS, you can LOAD "GRPED" and see the colors form there.

Now, let's do GPSET.
Let's execute 2 lines of code.
ACLS
GPSET 100,100,5
So, it made a dot on the screen.
Let's break it down.
GPSET tells your DS to execute the GPEST command.
The first number (100) is the x coordinate.
The second number (100) is the y coordinate.
The third number (5) is the color.
So GPSET 100,100,5 tells your DS to make a color 5 dot at 100,100 (100,100 is about the middle of your screen. About.)

Dsi_Mario

AuthorMessage
Avatar

Mariominer

85. Posted:

I shall explain to you the differences in uses of strings and numbers. In general, a string is a collection of data of characters. We, however, can't see it like this because people realized that no one wanted to say Print 16,18,13,8,10,90. That's unmemorable, not to mention unreadable. So, we strings like this:
Print "This is a string."
Note the quotation marks. This is very important. If a string doesn't have them, it's considered a variable. Numbers are considered much differently. They have no separate data from their number, besides binary, which both characters and numbers have. In BASIC, characters and numbers are called upon with different variable types. Strings are called upon with (Variable)$ while numbers are just (variable). This means you can have a variable called A and a variable called A$. In order to turn one into the other, you can use this command for strings:
VAL(string)
You can add "&H" to the start of the string to find the value of a hexadecimal string. Like so:
VAL("&H"+string$)
To convert numbers to strings, you can do this:
STR$(number)
And it's simple as that. Note you can still print numbers, but can't do functions like MID$ or LEFT$.
Any function that ends with a $ can only be used with strings. Except functions that convert numbers to strings, like HEX$ or STR$. Now we know that strings are used in "$" functions. But what are so special about numbers?
Math. That's the answer. If you try to do this: "5"+2 you'll get an error (Don't know which one because I've never tried, but it will happen. Trust me.). This is because you're adding characters with numbers that aren't being converted to a string. If we did convert to a string, we'd still have a problem.
"5"+STR$(2)
This means you put "2" onto "5", making "52". If you turned 5 into a number, you'd make it work.
VAL("5")+2
Then you'll get 7. but you might ask me what happens if you divide/multiply/subtract from a string. Well, here's a list:
Divide: ERROR
Multiply: Makes x amount of that string, so "HI"*2="HIHI"
Subtract: ERROR
So these are the differences between numbers and strings, and my first program could've used a tutorial like this, because it took 2 keyboard inputs as string then added them. They were supposed to be numbers!

Me: "You're a genius!"
You: "But don't genius live in lamps?"
Me: (Facepalm)

3DS Friend Code: 1543-5315-3818 | Nintendo Network ID: Zeeman

AuthorMessage
Avatar

the5dimension

86. Posted:

well i just got petit i dont know how to program iv probably looked at about 30 tutorial and they dint help i wanted to program a rpg game but i need help learning to program is there anyone who can help me or write a tutorial or sumthing ill help me a lot

~the fifth dimension calls apond you~☆☆

AuthorMessage
Avatar

Mariominer

87. Posted:

@the5dimension, that depends on the kind of rpg you want to program. Text rpgs depend on basic math and printing, and of course input. Sprite rpgs are VERY difficult. Try to find some sprite tutorials - I don't know too much about that.

Me: "You're a genius!"
You: "But don't genius live in lamps?"
Me: (Facepalm)

3DS Friend Code: 1543-5315-3818 | Nintendo Network ID: Zeeman

AuthorMessage
Avatar

zeldafoursword

88. Posted:

hey there guys i need some help, i have understood the basics but i cant really understand how to put a sprite on the screen and make it move, could somebody please tell me how to do this? i would really appreciate

zeldafoursword

AuthorMessage
Avatar

Mariominer

89. Posted:

Here's something a little more complex-CHRSET (Or is it Setchr… Nope, definite CHRSET). If you don't understand hexadecimal, you can still read this, but in your code you can use HEX$.
So CHRSET has 3 parimeters. The setup looks like this:
CHRSET "resource name", character number, graphic string (in hexadecimal)
The resource name can be BGU(number), SPU(number) Or BGF. Character number can be from 0 to 255. For example, BGF 34 is the " character. The graphic string is the hardest part. Use a data string to make it visible what it will create in the tile, for example:
DATA "00000000"
DATA "01010101"
DATA "10101010"
DATA "02020202"
DATA "20202020"
DATA "03030303"
DATA "30303030"
DATA "00000000"
Yes, they are all numbers, so why the quotes? Because it's a graphic STRING. Strings always use quotes. Although with this command you can make quotes invisible. You can then read the data like this:
ACLS
CLEAR
DIM COLORS$(8)
RESTORE @DATA
FOR I=0 TO 7
READ COLORS$(I)
NEXT
And then the data will be read and stored on the array COLORS$. Anyway, before I get too carried away, more about the graphic string. The string represents colors on an 8*8 tile (that's how you would say it on computers). It moves horizontally, going down the column after it reaches the end. So a (clipped) string could be 888888887 And the color 7 would appear on the next line. These strings are lengthy, so it's difficult to put it on a line. Plus purely unreadable. This uses only 15 colors, 16 if you count invisibility. You can't separate the one and the 5 for 15, so you use hexadecimal. Colors 10-15 are stated with hexadecimal. A, B, C, D, E, and F represent 10-15. Again, you can use HEX$(number) to help, but it means you use different code entirely. Because of the colors, you can coordinate it with COLSET. COLSET isn't nearly as lengthy. It has these parameters:
COLSET "Color bank name", color number, and then color string (represented in HEX again).
The bank name can be "BG" (BackGround) , "SP" (Sprites), and "GRP", graphics. These change what kind of color it will change, so ensure you change the right color for your graphics. The Hex color string has the setup RRGGBB, or 2 characters allocated for each color, red, green, and blue. This will mix those colors, and set them at the point of color defined with the color number, used in each command that sets these things.

Examples of programs that put these functions to good use:
Village: Animates water and Colors depending on time.
Petit forest: Animates water and colors depending on time.
And that's all I know. Questions? Was I not clear enough?

Me: "You're a genius!"
You: "But don't genius live in lamps?"
Me: (Facepalm)

3DS Friend Code: 1543-5315-3818 | Nintendo Network ID: Zeeman

AuthorMessage
Avatar

Gimmemorecoinz

90. Posted:

@GraphicGenius I'll be starting them up again. I was very busy. I began a video tutorial series to.
https://www.youtube.com/watch?v=29bPoJFrBiI&feature=youtu.be This is episode one.
You can find episode two as well on my channel. I know I shouldn't advertise here but these ARE tutorial related. I hope the admins don't mind?

Kay cool. When I start my tutorial series it will be more advanced and itll go over creating large games. The thing that most people
really want help with is getting past print, cls.. etc. This video tutorial series if you follow it will go along basics and slowly work it's way up.
I'll also be making an intermediate video series alongside it for those who aren't newbies and i'll be releasing QR codes for each tutorial as well so you don't have to type the code yourself.

Game demos will be getting released demonstrating various things. CHeck the QR code sharing thread for one of the demos I released recently , it's a simple battle system framework. It can't really be a full game right now but you could learn from the code and the way it operates to make your own. IT DOESN'T use arrays ^_~ surprise surprise.

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

AuthorMessage
Avatar

Thecoolguy617

91. Posted:

I have a challenge ( I really need help with this though) for you all! Anyone who has the PRG: MPZL and tries to edit the file in any way, knows that it messes up Mario's Sprites. So I dare you (I'm begging, I had this issue for 2 years) to fix this and to show me how.

Please.

Thecoolguy617

AuthorMessage
Avatar

Gimmemorecoinz

92. Posted:

GimmeMoreCoinz' A more Comprehensive study of petit computer in relation to gaming.
This will be a brand new tutorial series focusing on educating you newbies and non newbies alike about GAME Mechanics.

Since So many people I've spoken to who are newbies still seem lost.
So let's start with the basics ALLLLLL over again.

What is a type?
A type is a variable, a string, a flag, or a boolean, or any type of "data" but not to be confused with the DATA statement and command.
Got it? Ok?
Cool
If not, we'll cover it in more detail so dont' worry your heads about this :3

Okay so what's important about this is the following.
A mechanics in a game is basically something that happens or can be done.
I'm sure all of you know about the deep mechanics of some games.
I'm going to create a butt load of tutorials to try to illustrate how to think as a programmer, not just "how to do this or that" but HOW TO THINK as a programmer.

IT's a type of skill not everyone has don't worry if you don't have it naturally you can develop it.
Programming is just problem solving so to understand the problem we have to find out what would happen if the problem was solved.
In fact in professional coding, that's what some programs are referred to as. Solutions.

So anyways. The mechanic we're going to look at today is running, and jumping!
A basic plat former needs running and jumping! Then later we'll look at maybe adding a weapon, or maybe two weapons and the ability to switch them.
I'm sorry I haven't done tutorials like this before but I ASSUMED these types of things were pretty straightforward once you know what commands to use.
I realize sometimes people don't always know what they're doing.

=THE MECHANICS=

RUN
JUMP
WALK

Okay so we have our three major mechanics.
There are a few hidden mechanics in the running, and jumping as well as walking. Let's look at that again.
In order to jump... there needs to be a button.. and in order to run or walk again there needs to be falling (Gravity)
Well okayyyyy gravity should be easy right it's just a single variable? Gravity_ON or Gravity_OFF
Well that's kind of correct but no! NO NO NO ITS ALL WRONG!!!!!
It's not JUST a variable you guys!! I'll show you!!

Player_x=100
Player_y=192-16 'Player Y bottom of screen but add 16 pixels to it so its feet touch the bottom we'll use 16X16 sprites
falling=false
jumping=false
landed=true
jumptime=0

==Explanation 1==

okay So here let me explain these , you see? it's not just one variable. It isn't so simple.
falling=false. If this were set to true at the start of the program or game, the player would fall only to stop falling instantly.
jumping=false. Well they aren't even jumping right now so yeah.
jumptime=0. This is the amount of time the player jumps for not in time but in 1/60th of a second. (however fast ptc can run this)
landed=true. This is set to true. If jumping is set to true then landed is automatically set to false.
When jumptime reaches zero again, it will check if landed is true and if jumping is also true it will set jumping to false, and falling to true.
Then it will check later if landed is false and if falling is true, and if jumptime is 0. If these values are exactly this, then the player_Y will equal itself, minus gravity. Which will be the amount of pixels the player falls each time it checks. This happens very fast so if gravity is set too high then the player will fall VERY quickly, which will basically give a wierd moon jump like effect where the player glides up slowly then falls fast. We don't want that so I'll explain a formula using jumptime.
Jumptime will be used to basically divide the jumptime by 4, and that is how high the player can move each time.
You could use another value like 1.5. Basically it works to scale the jump based on how much jump power is left.
If you subtract 2 from jumptime each time the player moves in frames then the player will jump in an odd way.
Let me write out the full code for you now so you can see it in action. This is untested and not gaurenteed to work.
I will NOT use sprites.
SO here we go!

player_X=0
player_Y=192-16
jumping=false
falling=false
landed=true
gravity=1
jumptime=0
jump_height=15 'in cycles NOT in pixels try tweaking this later
@Main

B=button()
if B==16 and landed==true then landed=false: jumping=true: jumptime=15: falling=false
if jumping==true then jumptime=jumptime-1: player_y=player_y-2
if jumping==true and jumptime==0 then jumping=false:falling=true:landed=false
if falling==true and player_y<192-16 then player_y=player_y+gravity
if falling==true and player_y=>192-16 then player_y=192-16: falling=false:landed=true 'this is important. Here we use the players Y coordinate to check if they landed or not and we change falling to false if they have.
if B==4 then player_x=player_x-2 'here we move the player on the X axis left or right
if B==8 then player_x=player+x+2

'draw the player

gbox player_x, player_y, player_x+16, player_y+16, 5 'blue ish box is the player

vsync 1
gcls
goto @main

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

AuthorMessage
Avatar

Gimmemorecoinz

93. Posted:

GimmeMoreCoinz' A Comprehensive study of petit computer in relation to gaming part 2

Hello Everyone and welcome to part two. I'm sorry I've been a little slack on writing tutorials but I've had a few -ahem- minor tooth issues..
I also caught a nasty flu recently. Anyways on with the tutorial!

In this section of the tutorial we're going to add as promised a bit of fun to the mix. That's right , a bullet!
a ... SINGLE bullet.
How will we do this? Oh it's magical.
It will be fun. Just trust me and follow along.

So as a study of the mechanics what is a bullet? Like most things it's an object.
The bullet will have a few properties which we will store in variables.
Please think about the properties of any object in your game, and then think of what variables may be needed.
Take a minute to think of some other real life objects around you that you can quickly think of their properties.
One example, is a bowl.
What is a bowl? Well it's a container that's round, it has an open top, it can hold any solids or fluids. If tipped over the fluids spill out of it.
This may be a bit too detailed for our purposes so let's use a simpler object.
How about, a ball. What can a ball do? Well a ball is round, it rolls. It's affected by gravity! Perfect.
For all purposes let's just say right off the bat that every object must have an X and a Y coordinate.

For more information about 2d coordinates I'll post a link about them later.

Coordinates explained

What is a coordinate?
Please follow along with me. Take a piece of paper A blank one.
Put it flat on your table or desk and get a pen or pencil.
Now I want you to try to put a dot in the middle of the page. The very center.
Did you do it? Good.
Next, try to imagine that this dot, could potentially move in any direction. It could move up, or it could move down.
It could move left, or right.. or even move in a circular fashion around the page. But it can't go off of the page.
Are you doing it? if you have a hard time imagining it then try to imagine how a ball might roll on a flat surface with borders once tilted.
Basically this surface is like your screen. And the dot's position, on that surface is the balls coordinates.
Ok now try to imagine a grid of dots. Spaced out about 1 inch apart each.
This grid of dots form dotted lines along the page that are spaced going both up and down (like grid paper but with no solid lines)
Now.. put another dot just an inch to the left of the current one.
To illustrate this. There are now two dots on the page.
one is in the very center, and one is about an inch to the left of the dot in the center.
We'll call the dot in the center position A and the dot to the left of that dot position B
So to recap, the dot in the center of your paper is A and the one to the left of it is B.
Write A and B down beside each dot. Not too big but readable.

Okay. Good.
Now I want you to draw a line just below both dots that goes straight across the middle of the page horizontally.
Imagine that this line, goes on forever. Or atleast till the end of your page and it starts at the beggining.
Your page should look something like this : http://imgur.com/ZVE2jVT

You see? Two dots one in the middle called A and one to the left of it called B. I put that diagram there just in case people have a hard time
visualizing it.

Ok so this is important because what if I told you that the dot called B is imaginary and the dot called A isn't.
This is because the dot called B is a potential location of the dot called A.
Now here's a piece of code that will blow your mind.
Ball_X=Ball_X-25 'please assume that the distance between each dot is 25 pixels

So what just happened there?
Well in simple terms, the dot called A just moved to the position of the dot called B.
This is generally how movement in games works. You have variables that determine the X position of an object.
The X position is the line at the bottom. So this "dot" can move into any position along this line.
The higher the number, the further to the right this "dot" has moved.
The lower the number, the further to the left this "dot" has moved.
So if we placed a third imaginary dot, to the right of the dot called A, same distance.
It would be 25 pixels to the RIGHT.
When something moves right you always ADD numbers to the X value.
When something moves LEFT you always SUBTRACT numbers FROM the X value

Here's a simple format
X=X-10
X=X+10
X=x+35

Excercise:
If I said to you that the ball_X is equal to itself plus 100, how far along that line do you suppose it might move? Try to visualize it.
Additional: download the image and place a dot called C , beside the dot called A , the distance away from A where you think it would be.
It should be to the RIGHT of the dot called A , and it should be a fair distance away.

Fact: All objects in these examples will move based on pixel distance. If you want to get a good feel for pixel distance then look at some of petit computer's sprites.
The 8X8 sprites are 8 pixels apart from eachother.
5 sprites over is 40 pixels.
10 sprites over is 80 pixels.
20 sprites over is 160 pixels.
And so on.

Now, there is also a Y coordinate but we won't touch on this today if you want to understand something the Y coordinate is an imaginary line at the middle of your object that moves up or down.
If you imagine your object having a cross hair that goes infinitely up and down or left and right with the object being in the center of it.
like a giant plus sign. Then your object can always move up or down those lines.
It can also move up or down those lines simultaneously to create angled movement.
Everything in the game projects we will discuss will be reffered to as an object from now on but don't worry the objects will also be given names.

Now moving on from coordinates ( and don't worry if you don't understand)

The real concept

Our projectile will also be an object with it's own X and Y coordinate.
The projectile will get it's initial X and Y coordinate from the player's X and Y coordinate, that way when fired, it starts out as being near the player
making it appear as though it is coming from the player.
Projectile_X=Player_X
Projectile_Y=Player_y

That is all we need to set up the projectile. Believe it or not.
Then, to draw it we can use
Gcircle Projectile_X, Projectile_Y, 5, 5 'creates a circle at the projectile's current location

now if we want the projectile to move and not just stay on the screen we do this:
projectile_X=projectile_x+projectile_Speed 'this is a nice way to make the projectile system more dynamic
'instead of telling it to use a real number we tell it to use the value of projectile_speed
Speed is definitely a property of projectiles and what if we want the player to change weapons later?
We certainly would not want the projectile speed to be the same for every single weapon used right? Or the projectiles those weapons fire
Now for switching weapons we can do something like this as an example real quick
If weapon_equipped==1 then projectile_speed=1 'oh look the normal gun doesn't fire that fast.
if weapon_equipped==2 then projectile_speed=3 'what could this weapon be?

From here you can start to see how different values relate, and of course at the start of the program we would do this.
default_projectilespeed=1
then in our code we'd have this
if projectile_speed==0 then projectile_speed=default_projectilespeed
This would make sure that without a doubt the projectile speed starts at 1. That if statement might save you a few glitches. So make sure to include it.

Phew. That was alot to cover. I'll go over how to integrate all of this into the first example in the next section. Take a break and try to digest all of this.
You don't have to read this tutorial all at once.
Try creating a circle object in a seperate program.
Type this example

circle_x=0 'the left edge of the screen
circle_y=floor(192/2) 'the middle of the screen
@main

if fired==true then gcircle circle_x, circle_y, 5, 5 'creates a roughly blue circle with a radius of 5
'only draw the circle if the button's been pressed

B==button()
if B==16 then fired=true
if fired==true then circle_x=circle_x+1
if circle_x>256 then fired=false:circle_x=0

vsync 1
gcls
goto @main

Later on we'll look at how to integrate THIS example with the example in the first tutorial so that it works with the player.
I hope you've learned something and as always try the examples and please try to toy with them a little bit in order to learn.
It's all about learning and having fun while learning to code so knock yourself out, I'm usually on the ptc wikia chat at random times.
If you really have any questions and you want an answer FAST, go on the ptc wikia chat and try to message me. I may or may not respond though and I'm really sorry if I don't.
I really really hope someone can gain meaningful knowledge or understanding from my tutorials that's why I keep writing them.
Good luck and have fun!

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

AuthorMessage
Avatar

GraphicGenius

94. Posted:

What exactly does spread do?

If Facebook, Myspace, Twitter, Instagram, and Snapchat were all destroyed, 90% of teens would go insane. If you're one of the 10% that would be laughing at them, copy & paste this into your signature and hope it happens. Wait was that just a joke?

3DS Friend Code: 1478-3545-5136 | Nintendo Network ID: GreatGamer123

AuthorMessage
Avatar

kid_code

95. Posted:

now I can not wait for the aus release to see what the Australians can do... that's if it ever makes it here.

hi there. :P

AuthorMessage
Avatar

kid_code

96. Posted:

petitprogrammer wrote:

To load sprites and make them move use this coding. PS.CLS clears the screen of text so it's good to use at the start of programs.PPS.First you need to make sprites in PRG:CHU0. And set it to sprite mode also you'll notice the numbers 0-7 on the bottom where i put 0 just change it depending on what one you use and filename is what you sved it as.NOTE USING FALSE WHEN LOADING A PROGRAM WILL STOP IT FROM POSTING THE OK MESSAGE AT THE BEGINNING ON THE TOUCH SCREEN.
CLS
LOAD"SPU0:FILENAME",FALSE
SPSET 0,LOCATION,0,0,0,0,16,16
PRINT "Use the d-pad to move.
@LOOP
IF BTRIG()==1 GOTO @UP
IF BTRIG()==2 GOTO @DOWN
IF BTRIG()==4 GOTO @LEFT
IF BTRIG()==8 GOTO @RIGHT
GOTO @LOOP
@UP
SPREAD(0)X,Y
SPOFS 0,X,Y-16,60
GOTO @LOOP
@DOWN
SPREAD(0),X,Y
SPOFS 0,X,Y+16,60
GOTO @LOOP
@LEFT
SPREAD(0)X,Y
SPOFS 0,X-16,Y,60
GOTO @LOOP
@RIGHT
SPREAD(0)X,Y
SPOFS 0,X+16,Y,60
GOTO @LOOP

ummm.... how do you get onto the sprite editor? do you put it in the code or something?

that's just something I need to know

hi there. :P

AuthorMessage
Avatar

kid_code

97. Posted:

how can you do walk cycles?

hi there. :P