DSiWare Forum

Topic: Petit Computer Tutorials

Showing 61 to 80 of 95

AuthorMessage
Avatar

hoohooco

61. Posted:

Note- GOTO makes your program jump to which ever part you labeled. an example-
PRINT "HELLO”
GOTO @HEYO
@OOEY
PRINT "GOODBYE”
END
@HEYO
PRINT"I MUST BE OFF NOW”
GOTO @OOEY
so it would say those things in the proper order, not all messed up. P.S. group names always have to start with a @ sign. just like twitter, instagram...

hoohooco

AuthorMessage
Avatar

ChangeV

62. Posted:

I posted this at main Petit Computer thread, page 259, but I don't think anyone read it because it got lost quickly in tons of posts.

I am reposting here because it shows about detecting select button(in somewhat limited way)
it also shows idea about uninstall option in games.
example program has some cool 3d-ish scroll using CHR tile changing trick. (tiles on BG layer are not changed)


There is a way to detect select button.

If you press and hold the select button and run the program, the program will not stop.
(of course, if you let go the button and press select button again, it will stop program.)

You can use button() to read the button value. it is 2048.

Its usage limited since select button can only be detected at the beginning.
But, it can be used to activate secret hidden stuff at the start up such as debug mode, invincibility, or uninstall menu.

At the beginning of program, check BUTTON()
And if select button is detected, set some flag variable and use the flag variable in the program.

IF BUTTON() AND 2048 THEN SELECT_PRESSED=TRUE

Here is uninstall example using select button trick.

Untitled

If you run normally, it will play the Exerion look-alike.(ground pattern is from my old project. ship and mountain sprites are from arcade version)

If you hold select and run, program will GO TO @UNINSTALL section I made.
It will display uninstall menu with list of resource files used in game.
Then it will ask for deleting resources(ship sprites, mountain sprites, and ground patterns tile) then the program itself.
After go back to gallery menu, uninstall operation is completed and the program and its resources are removed from petit computer.

Edited on by ChangeV

ChangeV

AuthorMessage
Avatar

Slayer

63. Posted:

Animates a sprite through a given number of frames. The number of frames (2nd parameter) is the number of images from the original image number defined in the 2nd parameter of SPSET. For instance, the example below animates sprite images 96-99 (a total of 4). The 3rd parameter is the ticks (1/60th sec) between frames. The fourth parameter is the number of times the frame sequence is repeated. 0 is infinite loops.

EXAMPLE:
ACLS
SPSET 0,96,0,0,0,0
SPANIM 0,4,15,0

OUTPUT:
A walking wizard.
This is info on using SPANIM to animate a sprite with the given amount of frames. You also need a second sprite, if you're using custom ones.

Edited on by Slayer

"Hello sir, may I take your order?"
"Yes, I'll have a cheeseburger and fries..."
"I AM the cheeseburger and fries!"
Things you need to know about me:
I hate Texas.

AuthorMessage
Avatar

ramstrong

64. Posted:

Reposted from main thread.

I suggest that you go through the Tutorial thread, if you haven't done so. GOTO and GOSUB has to do with label, not string. Although you can specify the label as string, that's not the idea. The idea is to jump to some labelled parts of the program.

You know how programs execute one after another, right? GOTO is used to branch/jumps to another part of code. Used by itself, it's rather limited. Good for Infinite Loops. Usually, GOTO is useful in the form of IF-GOTO. In English, IF such-and-such THEN do-this .

GOSUB is just like GOTO, except there's a qualifier.
IF such-and-such THEN do-this (and come back here when you're done!)

So in terms of RPG, GOSUB is a side quest, you'll come back from. GOTO is another land, you'll never come back. ;)

GOSUB is a paired command. Just like FOR-NEXT, IF-THEN-ELSE, GOSUB-RETURN. Think of GOSUB-RETURN as a big block of code. Although you can nest GOSUB, each must be paired just like FOR-NEXT.

HTH.

Petit Computer Journal
Old site http://ramstrong.blogspot.com

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

AuthorMessage
Avatar

ramstrong

65. Posted:

This simple code is for doing on-screen keyboard. This is just a simple structure. You're supposed to change M$ to your desired values. You can use MID$ character from M$ to process your keys. Notice that you can have more than one character. You can simply select a character to represent "do nothing" to indicate empty space.

CLS
M$="012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
PNLTYPE "OFF"
GPAGE 1:BGPAGE 1
FOR X=0 TO 255 STEP 24:GLINE X,0,X,191:NEXT
FOR Y=0 TO 191 STEP 24:GLINE 0,Y,255,Y:NEXT
@LOOP
VSYNC 1:X=FLOOR(TCHX/24):Y=TCHY/24):S=TCHST
K=Y*11+X
LOCATE 1,1
?MID$(M$,K,1);"   "
BGCLR 1
IF S THEN BGFILL 1,X*3,Y*3,((X+1)*3)-1,((Y+1)*3)-1,3,0,0,0
GOTO @LOOP

So, just play around with M$ and see if you can use it to create your own on-screen keyboard.

Edited on by ramstrong

Petit Computer Journal
Old site http://ramstrong.blogspot.com

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

AuthorMessage
Avatar

Gimmemorecoinz

66. Posted:

Advanced program flow control structure, data, restore, arrays, and much much more.

Okay guys this is the first tutorial I'm writing because alot of people especially newbies seem to have issues understanding arrays so here goes

Part 1 :: ARRAYS

Arrays are a confusing subject for most who are new at programming. This post is to help clear up any confusion.
First, get the idea that "array" is confusing out of your head. It's not. It's very simple.
I want you to imagine your going to the shopping store and you have to write a list of things you're going to buy there.
Here's my usual list.

Milk.
Bread.
Eggs.
Oregeno
Garlic Powder
Ground Beef
Raspberry Yogurt
Jam
Butter
Bacon
Sausages
Pre cooked smokies
Wagon Wheels
Granola Bars
Corn Flakes
Raisin Bran
Pancake Mix
Apples
Oranges
Bananas
Bag of Salad
Spaghetti Sauce canned

Okay we have our huge list.
I hope you have yours? It doesn't have to be as long as this one though.
So now count how many items you have starting at 1.
1, 2, 3, 4...
Good.
Now Open up Petit Computer in Edit mode new program.
The number you got? Your going to write dim list$( ) and put the number between the brackets.
Here's what mine looks like. Dim list$(22)
You know what a string is right?

If you know what a string is you can skip ahead. If not.. read this.
a string is something that holds values.
You can hold letters and numbers, or any amount of information you want inside a string. But you only get up to a certain amount of characters.
hello_world$="hello world"
This example is a blatently clear string. The name of the string is the same as what's inside it.
now try this after typing that
print hello_world$
if you know what print is then you'll understand that if you type print and then you put a string after it, you'll get whatevers in the string.
So print hello_world$ becomes the same as print "hello world" but there's some important details here.
If you ONLY type print hello_world$ and you don't assign hello_world$ anything, you won't GET anything on the screen at all!
I hope that isn't too confusing.

If you need to understand more about strings before moving on go read about it in this tutorial thread or get help from somone. You won't be able to understand arrays until you understand strings and variables. Please do not try to learn this if you haven't got an understanding of assigning, and printing strings and variables!

okay now back to our list.
My list has 22 items.
The command dim list$(22) is just saying we want 22 strings. We want them ALL to be called list$
But we can't call 22 strings list$!
if we say list$="milk" then we say list$="bread" we lose the milk!
Try it yourself?!
list$="milk"
list$="bread"
print list$
it will only print bread on the screen.
arrays are, at best our way around this issue! Honestly! We can have as many strings named the same thing as we want...
but since they are all named the same thing how do we know which one is which?
...arrays!!!!
Since we can't use the name of the string by itself to know which one is which, they become numbered.
And then we are forced to refer to the strings of the same name by their number or what we call INDEX.
you good so far?

Let's review. We have 22 items on MY list. You should have atleast 5. on yours.
Dim list$( index)
now in your code I want you to do this.

index=22
dim list$(index)
In your code I want you to replace index=22 with the amount of items you have on YOUR list. oK? you got that. Perfect.
So next..

We have to assign list$ each item.
here's what I end up with!

index=22
dim list$(index)
list$(0)="milk"
list$(1)="bread"
list$(2)="eggs"
list$(3)="Oregeno"
list$(4)="Garlic Powder"
list$(5)="Ground Beef"
list$(6)="Raspberry Yogurt"
list$(7)="Jam"
list$(8)="Butter"
list$(9)="Bacon"
list$(10)="Sausages"
list$(11)="Pre cooked smokies"
list$(12)="Wagon Wheels"
list$(13)="Granola Bars"
list$(14)="Corn Flakes"
list$(15)="Raisin Bran"
list$(16)="Pancake Mix"
list$(17)="Apples"
list$(18)="Oranges"
list$(19)="Bananas"
list$(20)="Bag of Salad"
list$(21)="Spaghetti Sauce canned"

Waiit wait wait... hold on! What happened! I said I had 22 items on my list.
Why is it only up to 21 in my example? Well. If you count the amount of items again
you'll see during the assignment (that's where I use '=' ) that there are actually 22 items there.
You see.. when working with arrays in petit computer 0 counts as 1.
To understand this concept better I want you to write down somewhere on a paper or on notepad
0, 1, 2
now look. how many numbers are ACTUALLY written down? Counting from 1.
you get three numbers. When working with arrays in petit computer you'll have to get
used to thinking of it this way. Because if you try to use list$(22)="milk" for instance..
You will get an error!
You have to start at 0 and work your way to the amount you gave your array but minus one.
Otherwise you'll always get an error. A cheap way around this is to give your array one MORE than you want
it to have, then start counting at 1 but you might confuse yourself.

Ok so why is this important?
Why even use arrays? Or data, or restore or any of that?
The answer is more refined managable game projects. The answer is, you're learning to become a better programmer.
The answer is that in order to achieve a better organized project layout in order to control more sprites
more efficiently, have bigger maps in your game, more items.. etc etc etc.. you'll want to use arrays to store
your information.

Back in the old programming days arrays were used ALOT when they were first introduced in order to represent lists of information.
This is still relevent today but we have more sophisticated arrays now with what's called dynamic allocation. That's where you don't have to specify a size and the array gets bigger for you the more you put in it. You never get out of range errors.

Ok so what's next then?
Simple.
We put this example to use.
I hope you've done your assignment values to your array after your dim command like I did here.

index=22
dim list$(index)
list$(0)="milk"
list$(1)="bread"
list$(2)="eggs"
list$(3)="Oregeno"
list$(4)="Garlic Powder"
list$(5)="Ground Beef"
list$(6)="Raspberry Yogurt"
list$(7)="Jam"
list$(8)="Butter"
list$(9)="Bacon"
list$(10)="Sausages"
list$(11)="Pre cooked smokies"
list$(12)="Wagon Wheels"
list$(13)="Granola Bars"
list$(14)="Corn Flakes"
list$(15)="Raisin Bran"
list$(16)="Pancake Mix"
list$(17)="Apples"
list$(18)="Oranges"
list$(19)="Bananas"
list$(20)="Bag of Salad"
list$(21)="Spaghetti Sauce canned"

The next step is to print all of these
So next I want you to add this

print "My grocery list"
for t=0 to 21
print list$(t)
next t

What you should notice if you add this code after what you already had is that all of the grocery items you put down got printed.
how does this even pertain to a game?
What if instead of groceries... items your character had in his inventory were in there? Wouldn't that be neat.
Ok were going to start from scratch now so erase everything you put.
And type this out

Dim inventory$(20) ok were going to make it so you can hold 20 items. Remember this means you can only put items up to 19 in there. Because it's 20-1

okay so next were going to fill this inventor with rpg related items.
inventory$(0)="sword"
inventory$(1)="poison bottle"
inventory$(2)="healing potion"
inventory$(3)="shield"
inventory$(4)="leather helm"
inventory$(5)="leather armor"
inventory$(6)="leather leggings"
inventory$(7)="leather shoes"
inventory$(8)="leather gauntlets"
inventory$(9)="chicken soup"
inventory$(10)="raw chicken"
inventory$(11)="bowl"
inventory$(12)="100 gold"
inventory$(13)="wood bow"
inventory$(14)="Book of saving"
inventory$(15)="scroll of town portal"
inventory$(16)="scroll of summoned dragon"
inventory$(17)="tent"
inventory$(18)="smoke bomb"
inventory$(19)="scroll of town portal"

okay. So look at that! We have filled our array with 20 in game items. this is the character's inventory.
Hopefully if you followed the tutorial this far and had no problems understanding you'll see why arrays are useful in games. But this is only
the beggining of several tutorials I'm going to write. if you have any issues understanding any of this please post to the forums and ask , or pm me, or mail me. I'm also available in the petit computer wiki live chat on most days. Around noon my time or later. into the evening.

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

67. Posted:

GimmeMoreCoinz Tutorial Part 2

Okay i'm back with another tutorial I know it wasn't that long ago since I posted my first one.
You understand arrays? Good.
You understand strings? good.
you understand print? Good
You understand dim? Good.
you understand counting ? Good.
You understand variables? Good.

Do you know SPSET or SPOFS? no? Well.. that's unfortunate if you don't. Go learn how to use those.

In this shorter tutorial I'm going to teach you how to control sprites and I'll introduce multi dimensional arrays.
What is 'multi dimensional'
A multi dimensional array is a list and each list can have it's own list.
Why would you want that?
Say you have 5 npcs.
Say each of them can say up to 10 different things.

okay so npc 1 can say "hello nice day isn't it?" --" What do you want?" --" I saw a fish in the river yesterday... it was big"--"One day I'll buy that sword from you"-- and so on. Ok so npc number one can say multiple phrases.
Now if you know about your arrays from the past we could do it two ways.

dim town_kids_phrases$(10)
dim bar_tenderers_phrases$(10)
and so on for each npc in your game

you can do this... just like we did with our grocery list and with our rpg items.
OR
you can do this
amount_of_npc=5
dim npc_phrases$(5, 10)

what just happened? what does the comma mean!
I'll tell you. to the left inside the brackets ( ) we have a five. and to the right of the comma inside the brackets we have a ten.
now if you think about this, the array is able to hold STRINGS.
And we have a list of a list. So. What we have now is this
npc_phrases$(0, 0)
npc_phrases$(0, 1)
etc
Whatever the number is on the left of the comma is which npc were reffering to.
and whatever is on the right, is which of it's phrases we're trying to access.

Let me show you an example if I do
npc_phrases$(2, 0)
as long as that 2 is a 2 were talking about npc number 3 in our array.
And if the 0 changes to a 1, it can go all the way to 9.
Like this
npc_phrases$(2, 9)
Why though? Dont question it! just understand that all were doing is COUNTING.
Let's review. We have 5 npcs.
Let's choose the first phrase for EACH of those npcs to say
npc_phrases$(0, 0)="hi welcome to town" 'this is the town boy.
npc_phrases$(1, 0)="Hello, want a drink?" ' this is the bar tender
npc_phrases$(2, 0)="hi there I was just thinking of selling something" 'npc shop keep
npc_phrases$(3, 0)="hello cutie" 'npc girl 1
npc_phrases$(4, 0)="get out of the way!" 'npc castle guard

notice how the 0 didn't change? that's because it's the first phrase of each npc and 0 is the first phrase if it's on the right side of the comma.
now the reason this may seem confusing to you is because arrays can hold ANY data . you make up what the data means.
Here are a few other useful uses for arrays.
Player inventory
player stats
the world map of your game
The items contained inside a building or dungeon
the locations of items contained inside a building or dungeon
the location on the map of each npc
the location on the map of each sprite in your game
the status of a sprite "dead, alive, it's amount of hp, it's damage, it's damage resist, it's magic resist" etc

Arrays are really great if you have alot of things that do the same thing in your game.
IE "my game has 100 slime on the world map "
" my game has 25 knight enemies you have to fight and each one is on the screen at the same time and each one has hp damage bonus magic damage it can hold items " and so on..
these are the cases where using arrays is most useful!
other uses for arrays including sequencing of positions. Ie creating paths for enemies or AI in your game. We'll get into this section of using arrays later.
But basically I'm trying to teach all of you how you can begin using arrays in your games to make more sophisticated and complex game play.

Edited on by Gimmemorecoinz

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

noxuss

68. Posted:

THANK. YOU. Gimmemorecoinz, best tutorial ever on arrays. Please keep posting more, and I'm curious how the stats would work, I would like to see that :)

noxuss

AuthorMessage
Avatar

Gimmemorecoinz

69. Posted:

Hey everyone I'm back with another tutorial. This time we'll discuss using arrays with the spofs command and spset command.

I'll teach a simple method but I won't be able to test the example code right away.

Coinz Tutorial Part 3: Arrays with SPOFS AND SPSET

Remember all that stuff I taught you from last time? I hope you do. If not please go review it.

Introduction:
I'm going to teach you more about arrays.
Here's a technique called replacement.
index=10
chrnum=5
chrx=100
chry=100
Spset index, chrnum, 0, 0, 0, 0
Spofs index, chrx, chry, 0 'do it immediately
what I've just done here ! What? you can use VARIABLES in place of numbers??
Yes.

Why is this relevent?
It's relevent if you have multiple sprites to place and each one has a specific number or index that's unique to it and each one also has it's own X and it's own Y and you want the AI of each sprite to be able to behave as if it wasn't the same as every other sprite.
This is important.

Ok let's set up a basic table array. This table will contain information that tells our "example" game engine about the game
First do this

Dim sprites_data(10, 5)
'0 is going to be their index
'1 is going to be their X
'2 is going to be their Y
'3 is going to be their chrnumber
'4 is reserved

'in this case index means control number . yes that's right the control number of the sprite CAN be different from where in the array it's stored

Consider this
sprites_data(0, 0)=5 'when we use this in our example it will use the control number 5 for this sprite, even though in our array it's listed as sprite # 0
'because when we do spset like so
for temp=0 to 9
this_index=sprites_data(temp, 0)
X=sprites_data(temp, 1)
Y=sprites_data(temp, 2)
spset this_index, 0, 0, 0, 0, 0
SPOFS this_index, X, Y, 0 ' do it instantly with the zero at the end means no waiting
next temp

What?! What is "temp" what is "INDEX?! " SLow down! COINS!!! Your confuuuuzing meeeee!!

Well okay...

I'm sorry

I'll explain.
this_index is a variable were using. You see how it's used in SPSET and SPOFS?
We are storing the control number of the sprite in the array, along with that sprite's properties.
This means that the sprite number itself.. in our array and the ACTUAL control number it's assigned to can be seperate.
WHY WOULD YOU WANT THAT?!
Well because guys.. then you don't have to worry about counting from exactly one location. Plus it means you can plan out what sprite id numbers
in the game are for what types of sprites. This is important to if you want to make a sophisticated project. :3
But now we're way off topic.
The SPSET and SPOFS commands are being used in a way where the numbers that represent the control number for the sprite, and the chr number for the sprite are saved in variables which we got from our array by doing this:
this_index=sprites_data(temp, 0)
X=sprites_data(temp, 1)
Y=sprites_data(temp, 2)

Let me explain what temp is now.
Temp means temporary it's just a short word for a counter variable.
If you don't understand what a counter is. I want you to start a new ptc project in edit mode and do this
for temp=1 to 25
print temp
next temp

You'll see the numbers from 1 to 25 printed on your screen.
That's ALL this is doing is counting. Which is why I said in my previous tutorials, arrays are not confusing all they are is counting.
Arrays are meaningless without giving them values
dim myarray(100)
for temp=0 to 99
myarray(temp)=temp
next temp

this gaurentees that myarray(1) will be equal to 1
myarray(2) will be equal to 2
you can pretty much gaurentee the numbers stored in the array myarray() will be the same as the index of that array
By this I mean myarray(index) =index
so if myarray(2) has a value what would it be? it would be 2
because 2 is the index. Index just means that this is the "current one" we are looking at. It doesn't mean anything past that or anything more complex.
Just remember kids.. we are ALWAYS counting with arrays. It's just a matter of what you are counting.
You make up what you count.
So what items do you want in your game? what stats? ..
well arrays can be used to help you count them.
So back to our example now with SPOFS that i've explained a bit more

Try this full working example that i coded up (it might be buggy sorry if it is)

Dim sprites_data(10, 5)
'0 is going to be their index
'1 is going to be their X
'2 is going to be their Y
'3 is going to be their chrnumber
'4 is reserved

for t=0 to 9 'set up the data for the boy sprites
sprites_data(t, 0)=t 'this is their control number
sprites_data(t, 1)=rnd(256) 'their X
sprites_data(t, 2)=rnd(192) 'their Y
sprites_data(t, 3)=193 'this should be the boy sprite from SPU1 'chr number

next t

gosub @place_boys 'take a look at this subroutine don't ignore it
'it starts the spanim and places the sprites
'we set up above

@main

gosub @movesprites '' now we're going to move these sprites and draw them ok?

vsync
goto @main

@movesprites
for t=0 to 9
x=sprites_data(t, 1)
y=sprites_data(t, 2)
this_boy=sprites_data(t, 0)
x=x+2 'This is what actually moves him but it still needs
'to go back into the array

if X>256 then X=1 'this line of code screen wraps him so he
'comes back if he goes off screen
sprites_data(t, 1)=x 'we re assign this to the array since
'later X will become what's in it
'if we change X now
' and we dont do this
'then it wont count
spofs this_boy, X, Y, 4 'move the sprite in four frames

next t

return

@place_boys
for t=0 to 9
x=sprites_data(t, 1)
y=sprites_data(t, 2)
this_boy=sprites_data(t, 0)
chrnum=sprites_data(t, 3)
spset this_boy, chrnum, 0, 0, 0, 0
spanim t, 4, 8, 0 'animate this current boy sprite
'do this without stopping the animation
'this should be the boy walking left
next t
return

This code above demonstrates how somone would USE arrays, and combine them with commands such as SPSET
It's pretty straightforeward and if you read my previous two tutorials about arrays and if you read this tutorial carefully you'll start to understand.

Here's a quick review.
A multi dimensional array is just a list of a list.

If I wanted to have five bobs, and I wanted each one to have it's own X and it's own Y, and it's own "chrnumber" and it's own control number.
The ordering of the array would go like so.
traits=4
Dim bobs(5, traits)

Okay now we have five bobs, and each of them has 4 traits.
The traits are X, Y, Control Number and CHR number.

We can store them in any order we want
just make it up
For example..
if we want the X to come first
we do this make sure to comment in your code what the trait is
Bobs(0, 0)=10 'The first bob's X
Bobs(0, 1)=100 'the first bob's Y

no? don't like that?
Try this..
Bobs(0, 0)=192 'the first bob's chrnumber

WAIT!? WHAT DID YOU DO COINSZ!!!
I'l ltell you what I did.
I'm showing you that the "order " of how you list your traits for npcs doesn't matter! NO ! it doesn't
just as long as when you go to check for those traits, you remember the order you store them in.
here's a example
if you did

Dim bobs(10, 4)
bobs(0, 1)=100 'the first bob's X
bobs(0, 2)=10 ' the first bob's y
and then later did this

BobsY=bobs(0, 1)
BobsX=bobs(0, 0)

spset Bob1, BobsX, BobsY, 0 'your bob's X and Y values would be mixed up together.
You dont want your bobs X's and Y's to be mixed up. that's bad..

So I hope that this tutorial has been clearer on helping you get a grip on multi dimensional arrays.
Hopefully you have some idea of how they can actually be helpful now and they don't seem to confusing.
There'll be more exercises and examples in my tutorials showing you just what multi dimensional arrays can do and how powerful they can be.
And plenty of reviews and reminders, and examples that apply to the real world to help you find your way through the confusing buggers.

In the next tutorial I write we'll be creating a simple text based RPG so if you want to get ready for my tutorial I suggest you go learn about things like mid$() and input and that sort of thing. Things you'll want to learn by my next tutorial will be MID$() left$() trim$() (I think that's a command?) , locate, and GCOLOR , Line , GFILL, and those types. Also look up the GPRIO command as it may be important.

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

70. Posted:

This post reserved for tutorial entry # 4.
You can still reply to the other tutorials if you want with questions just please dont quote them as their super long.

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

ramstrong

71. Posted:

Here's a sample code to manipulate a player character, and shooting. So many people just write the moving/shooting code on the button reading. For simple games, okay. For more sophisticated games, I like to separate the two. Note: It's better if I use array, but Coinz's tutorial notwithstanding, I'm keeping it simple for now.

ACLS
SPSET 1,68,0,0,0,0
SPOFS 1,128,96
SPSET 10,40,0,0,0,0
SPANIM 10,2,6
SPOFS 10,-50,-50

@INIT
PD=0:'PD=PLAYER DIRECTION. 0=STOP.1234=UDLR
BB=0

@LOOP
' PROCESS INPUT
VSYNC 1:TX=TCHX:TY=TCHY:TS=TCHST:TT=TCHTIME
B=BUTTON(0)
SPREAD(1),PX,PY

IF (B AND 1) THEN PD=1
IF (B AND 2) THEN PD=2
IF (B AND 4) THEN PD=3
IF (B AND 8) THEN PD=4
IF (B AND 16) THEN PA=1 ELSE PA=0:'PLAYER ACTION: SHOOT

'ACT ON INPUT
'THIS SECTION IS THE IDLE SECTION
IF (SPCHK(1) AND 1) GOTO @LOOP ELSE GOSUB @PMOVE
IF (SPCHK(10) AND 1) THEN BB=1 ELSE BB=0

IF !BB THEN SPOFS 10,-50,-50
IF PA AND !BB THEN GOSUB @PSHOOT:PD=0
GOTO @LOOP

@PMOVE
IF PD>4 OR PD<0 THEN PD=0
ON PD GOTO @MSTOP,@MUP,@MDOWN,@MLEFT,@MRIGHT
@MSTOP
SPCHR 1,68
SPANIM 1,1,0
RETURN
@MUP
SPCHR 1,76
SPANIM 1,4,15
SPOFS 1,PX,PY-16,60
RETURN
@MDOWN
SPCHR 1,68
SPANIM 1,4,15
SPOFS 1,PX,PY+16,60
RETURN
@MLEFT
SPCHR 1,72
SPANIM 1,4,15
SPOFS 1,PX-16,PY,60
RETURN
@MRIGHT
SPCHR 1,64
SPANIM 1,4,15
SPOFS 1,PX+16,PY,60
RETURN

@PSHOOT
IF PD>4 OR PD<0 THEN RETURN
ON PD GOTO @PSTOP,@PUP,@PDOWN,@PLEFT,@PRIGHT
@PSTOP
GOTO @PDOWN
RETURN
@PUP
SPCHR 10,46
SPOFS 10,PX,PY,0
SPOFS 10,PX,PY-160,160
RETURN
@PDOWN
SPCHR 10,42
SPOFS 10,PX,PY,0
SPOFS 10,PX,PY+160,160
RETURN
@PLEFT
SPCHR 10,44
SPOFS 10,PX,PY,0
SPOFS 10,PX-160,PY,160
RETURN
@PRIGHT
SPCHR 10,40
SPOFS 10,PX,PY,0
SPOFS 10,PX+160,PY,160
RETURN

Petit Computer Journal
Old site http://ramstrong.blogspot.com

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

AuthorMessage
Avatar

TAINT_Zzyex

72. Posted:

PART 1 IN 2 PARTS
@ramstrong said there has been little particapation. I have decided to help by giving a rather simple tutorial on X+Y, how it can be used for EVERYTHING!!! (movement, health, leavels, mana, money, etc.).
part 1
So lets start it off with a timer.
do-
@tick
CLS
'Clears screen of text
WAIT 60
'waits 60 frames. 1 frame=1 millasecond.
PRINT ""Y""":"""X""
'@can be changed to wutever
X=X+1
'Change X and Y to wutever
IF X==60 THAN Y=Y+1
GOTO @TICK
This makes a timer, every 60 seconds it adds 1 minute. "Cool!" You say "How does this help us in anyway with health or any other thing listed above or out of my imagination?"
Because these are limitless up to the syntax of math in ptc. Any crap involving numbers can be done! So say mana goes up 10 per second, and you can upgrade mana rate. To do this, you need the following...
part 2
MANALVL=1
'Keep this outside of loop...
@MANALOOP
MANA=MANA+MANARATE
MANARATE=10*MANALVL
IF COIN==100*MANALVL THEN MANALVL=MANALVL+1
PRINT ""MANA""
WAIT 60
CLS
GOTO @MANALOOP
This makes Mana increase at a steady rate. "But wait..." "Where does all of this coin come from?" No where. Not yet. Wait till tommorow. Be patient. Even I have to sleep. Just wait. STOP PRESSURING ME!!! T-T

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter: MetricCat

AuthorMessage
Avatar

TAINT_Zzyex

73. Posted:

Part 1.5
put a-
IF X==60 then X=X-60
-right under the IF X==60 Y=Y+1
or it will be messed up.

"Did somebody say Aincrad?"
"No, go back to your own game!"
"awwww"
"And make out with Asuna."
"Aww-I mean YAY"

Twitter: MetricCat

AuthorMessage
Avatar

GraphicGenius

74. Posted:

@Gimmemorecoinz never stop making 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

Dsi_Mario

75. Posted:

I have something to do with MEM files. MEM$ needs to be modified.
Let's do this:
MEM$="Hello World"
SAVE "MEM$:FAR"
This will save a mem file called "FAR" and it will have the text "Hello World" in it.
Now, if you want to save variables in it...
EXAMPLE$=STR$(VARIABLE)
MEM$=MEM$+EXAMPLE$
SAVE "MEM$:EX"
Now to load MEM$...
LOAD "MEM$:EX"
VARIABLE=VAL(MEM$)
PRINT VARIABLE
END
I hope you understood this.
If you didn't, Say so.

Dsi_Mario

AuthorMessage
Avatar

Koleytron2013

76. Posted:

Ok, I am new at BASIC coding, and I have created a few programs. Now I am trying to make this app called "SupaChat", Where you can talk to your friends. You will get to customize your own username, and chat via wireless. I do not know if you can create a program involving internet. I would like some help in making it. I will also give 99% credt of whoever helped m.
If you ould like to help, please do not hesitate.

Koleytron2013

AuthorMessage
Avatar

Koleytron2013

77. Posted:

Sorry aout th typos. I'm using Windows XP. :(

Koleytron2013

AuthorMessage
Avatar

MechaPikachu

78. Posted:

Hi.
Let's continue Gimmemorecoinz' tutorial on Dim, arrays, and such and add in DATA statements. Woo! What's a data? To keep it simple, DATA is like that folder you have on your desktop that holds certain information. Now. The main keywords that you will be using in this tutorial will be:
-DIM
-DATA
-RESTORE
-READ
-BGPUT
Let's begin. :D
'--------------------------------------------------------
First of all, ALWAYS start your program off with a 'CLEAR' command if you are using 'DIM.' This clears all variables from storage from the past program. So.

ACLS:CLEAR
'I always like to preset my variables in case I mess up so that all I have to do is change the variable
A=6:B=6 'Array sizes
G=1:R=2 'Our 'colors' or 'character numbers for our BGPUT

DIM P(A,B)

'Hurrah! Here comes the fun!
'RESTORE sorta sets your data in that certain spot so READ (which reads the DATA)
'Doesn't have to search for your DATA statements. Sooo..
RESTORE @DATA
FOR I=0 TO A-1
FOR J=0 TO B-1
READ P(I,J)
NEXT
NEXT

'OKAY. Now that our DATA is read, we can BGPUT on our predetermined locations
'(IF DATA 'IS' (?) THEN BGPUT specified bg)
FOR I=0 TO A-1
FOR J=0 TO B-1
IF P(I,J)==1 THEN BGPUT 0,J,I,R,0,0,0
IF P(I,J)==2 THEN BGPUT 0,J,I,G,0,0,0
NEXT
NEXT

'Now we can set our stored DATA to be RESTORE-d
@DATA
DATA 1,2,1,2,1,2
DATA 1,2,1,2,1,2
DATA 1,2,1,2,1,2
DATA 1,2,1,2,1,2
DATA 1,2,1,2,1,2
DATA 1,2,1,2,1,2

'--------------------------------------------------------

So, now when we run the program, the top left of the screen has a 6x6 block filled with red and gray stripes. Neat! Sounds useless, huh? Not at all! You can use this method for all types of things, including maps, number sets, mazes, etc.
With using DATA and RESTORE, you can also use this for string or text. Just put "$" after your array variable (I.e. P$(10) ) and be sure to put your string in quotations in those DATA statements. ;D If you just want to print said string then just use something like:
LOCATE J,I:PRINT P$(VAR)
Or, you can just use that DATA to store text for later. Remember the 1st dimension selects which data statement and the 2nd dimension selects which string/number on the row in which the 1st was selected:
P$(2,2)

DATA "THIS","IS"
DATA "AN","EXAMPLE"

So, P$(0,0) would be "THIS" while P$(1,1) would be "EXAMPLE".

I'm terrible at explaining things so I hope I helped somebody out. :D Might make more if people enjoyed this.
Arrays are our friends. If anyone has any questions or corrections, tag me of message me.

These are not the codes you are looking for.

AuthorMessage
Avatar

MechaPikachu

79. Posted:

Okay. Understand DATA a bit more? I hope so because now we're tackling MML but a few things you should know first
-Only 8 tracks can be played at a time
-It'd be better if you knew note names and the basics of sheet music
-I don't know what I'm doing
And with that, I'll go ahead and give you a sample in this tutorial, which is the intro to "Subverse" by "This Or The Apocalypse." So, no. Not my song. Please don't sue me.

'--------------------------------------------------------

CLS
BGMSETD 128,@SONG
'Few things. BGMSETD just saves the your DATA for use later, much like RESTORE did in my last
'tutorial. The first number is your song number. Much like a control number, this
'just labels your song for BGMPLAY and lastly, @SONG is the label for your MML DATA
BGMPLAY 128:BGMVOL 127

@SONG
' Here is where the magic happens. I would refer to the in-game manual for the little stuff
'but on your first DATA line stating your track number, always start it off with a ":"
'T is your tempo @(?) is your instrument number and O(?) is your octave
DATA ":0T140@80O5"
DATA "[C#8>G#8E8G#8A8E8G#8E8&E8<C#8>G#8E8F#8E8G#8E8<C#8>G#8E8G#8"
DATA "A8E8G#8E8&E8<C#8>G#8E8D#8E8D#8>B8]4[R1]4
DATA ":1T140@80O3"
DATA "[C#8R1B8R2R4A8R1F#8R2R4]4"
DATA ":2T140@80O4"
DATA "[R1]8[[C#16]16>[B16]16<[D#16]16[E16]8[D#16]8]2D#1&D#1"
DATA 0

'--------------------------------------------------------

Whew, okay. I'll give you a basic list of what's here:
-"[]" these are your loops. Like FOR ~ TO ~ STEP nested loops it repeats whatever is on the inside of these brackets the amount of times stated on the outside. (Nothing for an infinite loop)
-"&" This is a tie. this just means that you're combining two notes into one (E8&E8 would be the same as E4)
-"<" means up an octave
-">" means down an octave
-"R" this is a rest. (R8 is an eighth rest)

Scope down the manual for more options and all that. This may have a few misplaced notes (I hope not) so if anybody finds something wrong, tell me and I'll fix it. Hope this helps. :3 like before, any corrections or questions, ask away or message me.

These are not the codes you are looking for.

AuthorMessage
Avatar

DR4IG

80. Posted:

I've been following the few tutorials I could find that deal with things I didn't already know about BASIC, But I've stumbled into a curious bit of trouble. It's probably something really simple, But I have a list of tiles that I'm using for the background, And a working loop to draw the map based off DATA statements but instead of drawing the full 16x16 tile, It's only drawing little 8x8s. How would I go about drawing the full 16x16 assembled block rather than just an 8x8?

I can post what I have so far in the example, But I'd have to port it through pcutils first.

DR4IG