Forums

Topic: Petit Computer

Posts 7,941 to 7,960 of 9,621

cigsthecat

Discostew wrote:

cigsthecat wrote:

Aha! That makes sense, thank you. I suppose using CLEAR every time right before DIM is the way to go.

CLEAR does as it says, clears the memory, which means all variables and arrays will be erased/reset. I usually put it near the start of my program so I know I'm starting with fresh memory to work with.

OK, gotcha.

ramstrong wrote:

cigsthecat wrote:

Aha! That makes sense, thank you. I suppose using CLEAR every time right before DIM is the way to go.

Well, I guess now you know why I did CLS:CLEAR on my program. Those two do different things.

Yep! I realized that.

I was looking at this Morpheel tut, and I have some questions.

Morpheel wrote:

Eh let's see...
You have
@MAP1
DATA "111111"
DATA "100001"
DATA "102201"
DATA "102201"
DATA "100001"
DATA "111111"

And you want to use that data to draw a 6*6 room using some background tiles.

LABEL$="@MAP1" 'set the label where the DATA is

As I understand it, LABEL$ is a custom string variable, yes? So it doesn't need to be LABEL$, it could be any text ending with $?

@DROOM 'a subroutine to draw a 6*6 room using DATA
RESTORE LABEL$ 'set the DATA pointer to that label

Could someone explain a bit about the RESTORE function? I have a basic understanding of GOTO and GOSUB-RETURN. How is it different from those?

Also why is it necessary to set LABEL$="@MAP1"? Couldn't you simply do RESTORE @MAP1?

FOR Y=0 to 5 'start Y for
READ L$ 'read a line of DATA

I see L$ here (short for LABEL$?). Why does this work?

FOR X=0 to 5 'start X for

Why don't we need another "READ L$" here for X?

IF MID$(L$,X,1)=="0" THEN BGPUT 0,X,Y,45,8,0,0 'draw background tile 45 if the Xth data of the Yth DATA line is 0
IF MID$(L$,X,1)=="1" THEN BGPUT 0,X,Y,54,8,0,0 'draw background tile 54 if the Xth data of the Yth DATA line is 1
IF MID$(L$,X,1)=="2" THEN BGPUT 0,X,Y,65,8,0,0 'draw background tile 65 if the Xth data of the Yth DATA line is 2

So if we imagine the 6x6 DATA square as 6 columns- is this function reading the numbers from the top to the bottom of column one, then doing the same for the others moving left to right?

NEXT X:NEXT Y 'Move on
RETURN 'Return

Here he's using a RETURN without a GOSUB. Is this just here out of habit since you'd expect to arrive at all of this code via a GOSUB as part of a larger program?

Sorry if these questions are super basic (haha), but I really like how this works and want to understand it better.

here's Morpheel's code without my interruptions:

Morpheel wrote:

Eh let's see...
You have
@MAP1
DATA "111111"
DATA "100001"
DATA "102201"
DATA "102201"
DATA "100001"
DATA "111111"

And you want to use that data to draw a 6*6 room using some background tiles.

LABEL$="@MAP1" 'set the label where the DATA is

@DROOM 'a subroutine to draw a 6*6 room using DATA
RESTORE LABEL$ 'set the DATA pointer to that label
FOR Y=0 to 5 'start Y for
READ L$ 'read a line of DATA
FOR X=0 to 5 'start X for
IF MID$(L$,X,1)=="0" THEN BGPUT 0,X,Y,45,8,0,0 'draw background tile 45 if the Xth data of the Yth DATA line is 0
IF MID$(L$,X,1)=="1" THEN BGPUT 0,X,Y,54,8,0,0 'draw background tile 54 if the Xth data of the Yth DATA line is 1
IF MID$(L$,X,1)=="2" THEN BGPUT 0,X,Y,65,8,0,0 'draw background tile 65 if the Xth data of the Yth DATA line is 2
NEXT X:NEXT Y 'Move on
RETURN 'Return

That way you can write yourself multiple DATA structures with number variations to draw different rooms using the same code.
Or something like that.

Edited on by cigsthecat

cigsthecat

ramstrong

cigsthecat wrote:

As I understand it, LABEL$ is a custom string variable, yes? So it doesn't need to be LABEL$, it could be any text ending with $?
Also why is it necessary to set LABEL$="@MAP1"? Couldn't you simply do RESTORE @MAP1?

Yes, LABEL$ is simply a string variable, and you can use anything you want. You can also do RESTORE @MAP1 directly if you want, but using string is more flexible.

RESTORE isn't like GOTO/GOSUB in that the program execution does not go there. It simply tells the program, whenever you see a READ command, this is the data you want to read. RESTORE is used to select different parts of DATA section. Say you have DATA for sprites, and background data. You can write
@SPRITE
DATA ...

@BGDATA
DATA ...

And use RESTORE @SPRITE or @BGDATA to select which DATA you want to load, either sprite data or background. However, program execution does not go there. It's simply used to set which data you want to read. Think of it like a file-selector switch, instead of GOTO/GOSUB

I see L$ here (short for LABEL$?). Why does this work?

No. L$ is a normal variable, not short for LABEL$. L$ is the variable containing the data "111111", "100001", "102201" and so on. Think of READ as a substitute for INPUT. Whenever you want non-interactive INPUT, you use READ (which reads the input on DATA)

Why don't we need another "READ L$" here for X?

Because X is used to go through the characters in L$ using MID$ command. Think of it as FOR X=0 to LEN(L$)

IF MID$(L$,X,1)=="0" THEN BGPUT 0,X,Y,45,8,0,0 'draw background tile 45 if the Xth data of the Yth DATA line is 0
IF MID$(L$,X,1)=="1" THEN BGPUT 0,X,Y,54,8,0,0 'draw background tile 54 if the Xth data of the Yth DATA line is 1
IF MID$(L$,X,1)=="2" THEN BGPUT 0,X,Y,65,8,0,0 'draw background tile 65 if the Xth data of the Yth DATA line is 2

That's just a translation table. 0=45. 1=54. 2=65.

Here he's using a RETURN without a GOSUB. Is this just here out of habit since you'd expect to arrive at all of this code via a GOSUB as part of a larger program?

Part of a larger program. You see him using the word "subroutine". You use GOSUB @DROOM.

Sorry if these questions are super basic (haha), but I really like how this works and want to understand it better.

Those are good questions, so I don't mind. Of course, there's more than one way to learn. There's more than one post regarding DATA. So, it's a good idea to read all the tutorials to get an overview of things.

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

ramstrong

I updated October Petit Computer Journal. Finally. Randomous' Solitaire Depackaged is mentioned there, FYI. November is also up. I'll be working with Virtual Keyboard for November. Between main loop and user interface, I should be able to handle quite a lot of things with ease.

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

cigsthecat

Thanks ramstrong, that helps me a lot.

cigsthecat

Slayer

I am having problems with Apocalypse Rising, go figure.
I tried to display HP in the corner of the screen, but it never displays. I used LOCATE to direct the text where it should go, but it never displayed. I tried creating a variable called HP and assigned the text 100 to it, but it did nothing! It might not have worked because there is a VERY slight chance I did it the C++ way...

I have nothing really to say about myself.

Pixelrobin

@0Games you may have put a cls after the print. It needs to be vice-versa.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

Lego-Meister

@IAmAPerson why is there always green above every block an MCDS? Can I remove it somehow?

Edited on by Lego-Meister

Some programmers pride themselves on how many more lines of code they can write. I pride myself on how many less.

3DS Friend Code: 3652-1447-0455 | Nintendo Network ID: Legos-Meister

Zalkia-ent

i think it's green because IAmAPerson probibly does not have time.maybe in a future update where every block will have its own grapic on top of every block.and I thought about the same thing to

email:[email protected]
if facebook,myspace,instagram and twitter were all shut down, 90% of the teenage population would go insane. if your one of the 10% that would be laughing at them, copy&past this to your signature and hope it happens. Wait... NO!

Zalkia-ent

in a little while ill post the qr's for a progam I made called,petit madness.the program is a text progam it just tells a story that your in.it has some humer in it to!at the first one you get sucked into minecraft here are the program names.the first one is named pro3,pro stands for program.but I hope you like it

email:[email protected]
if facebook,myspace,instagram and twitter were all shut down, 90% of the teenage population would go insane. if your one of the 10% that would be laughing at them, copy&past this to your signature and hope it happens. Wait... NO!

InsertPi

@Lego-Meister well...the raycasting algorithm (the thing that draws 3D using 2D commands) only draws sides of the blocks, and not the tops or bottoms, so it's the same colour of the grass. You can't remove it unless you add something that draws the tops/bottoms of blocks/floors/ceilings, a Raytracer. I have one made by @calc84maniac, but it is way to slow. I might add it when PTC3D comes out, with 10x interpretation speed.

Edited on by InsertPi

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.

3DS Friend Code: 2148-9259-0831 | Nintendo Network ID: IAmAPerson620 | Twitter:

Lego-Meister

IAmAPerson wrote:

@Lego-Meister well...the raycasting algorithm (the thing that draws 3D using 2D commands) only draws sides of the blocks, and not the tops or bottoms, so it's the same colour of the grass. You can't remove it unless you add something that draws the tops/bottoms of blocks/floors/ceilings, a Raytracer. I have one made by @calc84maniac, but it is way to slow. I might add it when PTC3D comes out, with 10x interpretation speed.

A raytracer? Wow. Where could I get the QRs for this?

Some programmers pride themselves on how many more lines of code they can write. I pride myself on how many less.

3DS Friend Code: 3652-1447-0455 | Nintendo Network ID: Legos-Meister

boot

I think @morpheel completely abandoned petit computer. I was just on his page and 5 hours ago he commented n a different page. I hope that he comes back to this page!

Just your average talking boot. FC: 0791-4881-1672 for Smash and Pokemon.

3DS Friend Code: 0791-4881-1672

ramstrong

boot wrote:

I think @morpheel completely abandoned petit computer. I was just on his page and 5 hours ago he commented n a different page. I hope that he comes back to this page!

Haven't seen him since Pokemon came out. I don't think we'll see him anytime soon, TBH. He'll be back right around Petit Computer 3D.

I was scanning tutorial page and only 2 people are active there recently: Me, and Gimmemorecoinz. Except, Coinz left (Does anybody know why she left?). So, there's only me. If there's only me, then I won't be posting there anymore. I'd rather do it on my blog instead.

Of course, I don't have a tutorial blog. It's a journal, not tutorial. So, it won't be as educational as it can be. Either I'll have to start something else, or you'll have to suffer my journalistic style. Sigh.

Any volunteer to post on Tutorial thread?

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

boot

ramstrong wrote:

boot wrote:

I think @morpheel completely abandoned petit computer. I was just on his page and 5 hours ago he commented n a different page. I hope that he comes back to this page!

Haven't seen him since Pokemon came out. I don't think we'll see him anytime soon, TBH. He'll be back right around Petit Computer 3D.

I was scanning tutorial page and only 2 people are active there recently: Me, and Gimmemorecoinz. Except, Coinz left (Does anybody know why she left?). So, there's only me. If there's only me, then I won't be posting there anymore. I'd rather do it on my blog instead.

Of course, I don't have a tutorial blog. It's a journal, not tutorial. So, it won't be as educational as it can be. Either I'll have to start something else, or you'll have to suffer my journalistic style. Sigh.

Any volunteer to post on Tutorial thread?

coinz left because some fights and pposts on the live chat on the wiki. shes back now but not often. and w/ the knowledge I have on petit computer I could post there sometimes. i know about sprites, input and output, some music, mem, and other things.

Just your average talking boot. FC: 0791-4881-1672 for Smash and Pokemon.

3DS Friend Code: 0791-4881-1672

Meowpheel

Oh hi sorry.

Since I have nothing relevant to say in this thread (other things and games got in the way and I just lost interest in PC again), I simply haven't posted.
This is not a casual chat or pokemon thread after all!

Yeah, I'll probably be all about PC again when or after the new version comes out!

Meowph, that's right!

Oh look! A Morphloggery.
Oh! eShop Gurus.

3DS Friend Code: 0173-1330-0080 | My Nintendo: Abgarok | Nintendo Network ID: Abgarok

boot

Morpheel wrote:

Oh hi sorry.

Since I have nothing relevant to say in this thread (other things and games got in the way and I just lost interest in PC again), I simply haven't posted.
This is not a casual chat or pokemon thread after all!

Yeah, I'll probably be all about PC again when or after the new version comes out!

YAY ur not dead after all... im glad we now u will be back!

Just your average talking boot. FC: 0791-4881-1672 for Smash and Pokemon.

3DS Friend Code: 0791-4881-1672

TAINT_Zzyex

also with that gosub question according to the crappy manual (this is untested) return returns to the first tag it passes...
oh and about coins, ask twin about that, its a delightful story.

Edited on by TAINT_Zzyex

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

Twitter:

Pixelrobin

RETURN goes back to the line that called it.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

TAINT_Zzyex

Untitled
inspiration at its finest. Want me to tell you whats happening during election day tommarow? ADVANCE WARS WWII GAME heck yeah

Edited on by TAINT_Zzyex

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

Twitter:

Top

Please login or sign up to reply to this topic