Forums

Topic: Petit Computer Tutorials

Posts 62 to 81 of 101

ChangeV

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 by ChangeV]

ChangeV

Slayer

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 by Slayer]

I have nothing really to say about myself.

ramstrong

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.

ramstrong

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 by ramstrong]

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

Let's just call a spade, a spade.

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

Gimmemorecoinz

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 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

noxuss

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

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

Gimmemorecoinz

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

ramstrong

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

Let's just call a spade, a spade.

TAINT_Zzyex

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"

X:

TAINT_Zzyex

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"

X:

GraphicGenius

@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?

Dsi_Mario

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

Koleytron2013

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

Koleytron2013

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

Koleytron2013

MechaPikachu

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.
'--------------------------------------------------------
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. 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.

MechaPikachu

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.

DR4IG

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

MechaPikachu

@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.

Please login or sign up to reply to this topic