Forums

Topic: Petit Computer Tutorials

Posts 41 to 60 of 101

GraphicGenius

Can someone please tell me how to make it so if you want it to go up,down,or let you press a?
I've been looking for the answer for about 3 weeks. I don't know why I didn't post about it here before but I just really need the answer to it so I can finish my game which I can explain (I can't post the QR code) later on and print my tips.

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

ramstrong

programmerpro wrote:

Can someone please tell me how to make it so if you want it to go up,down,or let you press a?
I've been looking for the answer for about 3 weeks. I don't know why I didn't post about it here before but I just really need the answer to it so I can finish my game which I can explain (I can't post the QR code) later on and print my tips.

Post 7 here has what you're looking for. what's your blog about? Can't be good tutorial if you're still looking for button presses.

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

cmart592

@ramstrong your tutorial about chr movement does not work it just shows on me missing operand even if I check the ingame manual to see how to make your chr really move check out YUTUNATA on youtube. he has the best tutorials ever.

Gamers will prevail.

ramstrong

cmart592 wrote:

@ramstrong your tutorial about chr movement does not work it just shows on me missing operand even if I check the ingame manual to see how to make your chr really move check out YUTUNATA on youtube. he has the best tutorials ever.

Considering that I have the program up and running in my 3DS, pardon me to be skeptical of your claim.
Can't you at least tell me what command and lines have the missing operand error? The HTML converter corrupt my source code somewhat, so it's possible that you're missing something. You need to tell me exactly what's missing, though, or else I can't help you.

EDIT:
Can't find YUTUNATA on YouTube. Do you have a link?

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

randomous

Here's part 2 of my MML tutorial. Part 1 is on page 2 of this thread. This tutorial assumes that you have a good understanding of Part 1.

...Ugh, the forum didn't let me use escaped characters for things like underscores, so I put it here instead. Hope this is useful! I know it's super verbose and might be hard to understand at times, but I tried!

Edited on by randomous

randomous

ramstrong

cmart592 wrote:

the spreads on all the d-pads buttons scripts chunks check those out.
Here is the link to yutunata:
http://www.youtube.com/channel/UC4QS28VyTy2wFh-_QxO09JA

Sorry, but I still don't know what you're talking about. I don't use SPREAD, so those aren't my bugs. Furthermore, instructions on how to use SPREAD is right on post 6, one post above mine. So, I don't see why there's a problem.

The link isn't to yutunata. It's Yutunauta. No wonder I can't find it. I don't see any good tutorials from him. He did a lot of favorites and likes, but I don't see any specific good Petit Computer tutorial. You need to link to the good tutorial video for your post to be useful. Linking an account that has generic topic isn't good. This is a Petit Computer Tutorial specific post! Please keep to the topic. See post 10 for details.

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

GraphicGenius

ramstrong wrote:

programmerpro wrote:

Can someone please tell me how to make it so if you want it to go up,down,or let you press a?
I've been looking for the answer for about 3 weeks. I don't know why I didn't post about it here before but I just really need the answer to it so I can finish my game which I can explain (I can't post the QR code) later on and print my tips.

Post 7 here has what you're looking for. what's your blog about? Can't be good tutorial if you're still looking for button presses.

I'm still learning as I work on my blog. I'm still learning some of the basic stuff so it's not a huge surprise that I don't know how to do it.

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

Discostew

Someone recently asked a question about a timer/countdown on another forum, and after answering it and not seeing something here, I figured I might as well post it.

The basics of it is to begin at a certain number, and count down until it reaches 0. With PTC, you have a couple of ways to do this, but they are all based off of increments of frames, since that is the smallest form of time that PTC can work off of. Under normal circumstances, there are 60 frames in each second, so if you started with a countdown of 1 minute, you convert that to seconds, being 60, and then convert that to frames, which is 3600, then countdown each time per frame. Frame rate is regulated with VSYNC 1, so it'll maintain a constant 60 frames per second. Here's a simple version...

CNTDWN=600
@MYLOOP
VSYNC 1
CNTDWN=CNTDWN-1
IF CNTDWN<=0 GOTO @MYEND
LOCATE 0,0RINT CNTDWN/60,
GOTO @MYLOOP
LOCATE 0,0RINT "Done",,
END

This does not take into consideration if you end up having to process so much information that it takes more than a frame to do it, which usually results in the "slow down" effect you'd see in many retro games. In that case, your countdown will slow down too. But, there is a way around this. There are two system variables that retain the current frame, even if your processing takes more than 1.

MAINCNTL and MAINCNTH

MAINCNTL maintains track of time in frames since the program started (not your actual program, but the program environment that your program runs under, either by WRITE PROGRAM or selecting a program under VIEW GALLERY). It is read-only. Because the highest value that can be held in any variable is about 524287, they rounded out the number to 522000 (which is 145 minutes), and then extended that value to MAINCNTH, which increments by 1 every time MAINCNTL reached 522000 and resets itself to 0. So, the combination of MAINCNTL and MAINCNTH would be able to read a time value of about 144 years just on frames, so there's no need to worry about if your program will reach some form of time limit any time soon.

Now, here's how you use MAINCNTL for a timer (you won't need MAINCNTH). Start with a number in frame-form (remember, 60 frames in a second). Read the value of MAINCNTL into a variable (so we have a point to start with). Now, with each cycle of your code, grab the difference between MAINCNTL and the variable you stored MAINCNTL before. If you use VSYNC 1 each cycle, and you do all your processing within a single frame of time, the difference will most likely be 1. Right after, store MAINCNTL again in the variable you stored it in before (so it can be used for the next cycle). Here's an example...

MYTIME=MAINCNTL
@MYLOOP
VSYNC 1
MYDIF=MAINCNTL-MYTIME
MYTIME=MAINCNTL
LOCATE 0,0RINT MAINCNTL,MYDIF,,,
GOTO @MYLOOP

Now, this works, but there is a problem. Because MAINCNTL resets when it gets to 522000, this could mess with MYDIF, so, we make a check for when MAINCNTL resets, which is simply checking if MYTIME is greater then MAINCNTL, then offset by the max value that MAINCNTL can be, which is 522000. The value will likely be negative in this case, but that's ok.

MYTIME=MAINCNTL
@MYLOOP
VSYNC 1
IF MYTIME>MAINCNTL THEN MYTIME=MYTIME-522000
MYDIF=MAINCNTL-MYTIME
MYTIME=MAINCNTL
LOCATE 0,0RINT MAINCNTL,MYDIF,,,
GOTO @MYLOOP

So, now we have a difference, but how do we use it? Simple. Subtract the difference from the value that holds your countdown value. You can then convert to seconds, minutes, or whatever you wish after that. Here is an example of a 10 second countdown.

CNTDWN=600:' 10 seconds
MYTIME=MAINCNTL
@MYLOOP
VSYNC 1
IF MYTIME>MAINCNTL THEN MYTIME=MYTIME-522000
MYDIF=MAINCNTL-MYTIME
MYTIME=MAINCNTL
CNTDWN=CNTDWN-MYDIF
IF CNTDWN<=0 GOTO @MYEND
LOCATE 0,0RINT "Countdown (in seconds) - ";CNTDWN/60
GOTO @MYLOOP
@MYEND
LOCATE 0,0RINT "Countdown has ended...........",,
WAIT 120
END

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

ramstrong

Discostew wrote:

Someone recently asked a question about a timer/countdown on another forum, and after answering it and not seeing something here, I figured I might as well post it.

An easier method would be to use moving sprites. By setting the sprite to motion and using interpolation time option, you can simply check whether or not the sprite is still moving. When the sprite stops moving, then the timer has expired. Note, you don't need to worry about the previous sprite location as this trick will still work when the sprite is "moving" to the same location.

'Sets Timer Sprite
SPSET 1,64,0,0,0,3
'Start moving the sprite
SPOFS 1,0,-20,600

@LOOP
IF SPCHK(1)==0 THEN ?"Timer ends!":END
GOTO @LOOP

Simple as that.

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

Discostew

[quote=Discostew][quote]Someone recently asked a question about a timer/countdown on another forum, and after answering it and not seeing something here, I figured I might as well post it.

ramstrong wrote:

An easier method would be to use moving sprites. By setting the sprite to motion and using interpolation time option, you can simply check whether or not the sprite is still moving. When the sprite stops moving, then the timer has expired. Note, you don't need to worry about the previous sprite location as this trick will still work when the sprite is "moving" to the same location.

'Sets Timer Sprite
SPSET 1,64,0,0,0,3
'Start moving the sprite
SPOFS 1,0,-20,600

@LOOP
IF SPCHK(1)==0 THEN ?"Timer ends!":END
GOTO @LOOP

Simple as that.

Well, ain't that a kick in the pants? you can even use that for reading how much time is left.

CLEAR:ACLS:SPSET 1,64,0,0,0,3
CNTDWN=3*60*60:' 3 minutes
SPOFS 1,CNTDWN,-64
SPOFS 1,0,-64,CNTDWN
@MYLOOP
VSYNC 1
IF !SPCHK(1) GOTO @MYEND
SPREAD(1),CNTDWN,Y:LOCATE 0,0RINT CNTDWN/60,,
GOTO @MYLOOP
@MYEND
END

Unfortunately, it seems the value from SPREAD is limited to 15-bit integer, 1-bit sign, meaning the most distant value from 0 would be -32768, which in this case, is equivalent to about 9.1 minutes. That's the most you can have while being able to read the time left with some decimal places. A variation of that can increase the time if you divide by the number of frames per second in the initial SPOFS, and then not divide during the printing. This, however, gives you second-by-second updating with no fraction, but up to 145 minutes, just under the overflow value.

Discostew

3DS Friend Code: 4425-1477-0127 | Nintendo Network ID: Discostew

GraphicGenius

I currently want to know how to do 3 things:
Use GCIRCLE, be able to print things on the touch screen, and actually get sprites TO MOVE!

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

ramstrong

programmerpro wrote:

I currently want to know how to do 3 things:
Use GCIRCLE, be able to print things on the touch screen, and actually get sprites TO MOVE!

Dude, Post 54 (the one above yours) shows you how to move the sprite. Geez.
Ask your questions in the main thread, please. This thread is strictly for finished tutorials.

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

ramstrong

This is part of "variable" concept. Also Indirection. :http://en.wikipedia.org/wiki/Indirection

The computer is just a bunch of numbers. A variable will occupy one of those numbers (or memory address). So, when you do something like A=10, that means somewhere in memory, say address#4532, it will have a value of 10. Also somewhere else, there will be an entry "&A=4532" <- this here is a pointer (indirection).

An array is simply a bunch of variables together. An example would be a row of ducks, Solar panel arrays, string is an array of characters, etc. A lot of times, we want a group of variables to denote the same thing, with several different elements. Taking an example of ducks, we can say, "Shoot the 3rd duck from the left" which something like DUCK[2]=TRUE. 3 is the reference number. If we take memory address of DUCK is #3231, then
&DUCK[0]=3231
&DUCK[1]=3232
&DUCK[2]=3233
&DUCK[3]=3234
&DUCK[4]=3235
and so on...

DUCK[2] because array starts from zero.

However, the computer will need to know how many DUCK variables are there, because, eventually, you want to put another variables after it. So, we use DIM, as in DIM DUCK[5], which means "Let there be 5 DUCK variables going from 0 to 4". BASIC takes care of the internal memory allocations so you don't have to worry about it. But you do need to declare how many elements an array have before it can be used. This is also why you can't resize the DIM because you'll be in danger of overwriting other variables. So, you CLEAR the memory first, before allocating variables using DIM.

The nice thing about it is that we can use a variable as reference. That means we can do this:
FOR I=0 TO 4
DUCK[I]=TRUE
NEXT
In this case, variable I is changed with in the loop, so DUCK[0],DUCK[1]...DUCK[4] are all set to TRUE.
We can also do this:
INPUT "CHOICE",N
CHOICE[N]=TRUE

Why variable "I"? It's tradition, same as we use the term "Debug" when we mean correcting errors. "Debug" means getting rid of bugs, in this case a moth. The variable I is used as convention because in FORTRAN, variable I to N defaults to integer, and we use integers (as opposed to real) in loops.

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

ramstrong

Example of using Sprite Collision. Note that SPHITNO is set by the system automatically.

ACLS:CLEAR
MAXSP=19
SPSET 0,96,0,0,0,0
SPHOME 0,8,8
FOR I=1 TO MAXSP
SPSET I,64,0,0,0,0
SPHOME I,8,8
SPOFS I,255+RND(245)+5,RND(180)+5
NEXT

@LOOP
VSYNC 1
SPOFS 0,TCHX,TCHY

FOR SPNUM=1 TO MAXSP
IF SPCHK(SPNUM)==0 THEN GOSUB @MOVE
NEXT

IF SPHIT(0) THEN GOSUB @FLING
GOTO @LOOP

@FLING
BEEP 61
SPREAD(SPHITNO),X,Y
SPCHR SPHITNO,92
SPOFS SPHITNO,X+RND(225),Y+RND(95)-40,40
RETURN

@MOVE
SPREAD(SPNUM),X,Y
TX=TCHX:TY=TCHY
DX=TX-X:DY=TY-Y
DR=SQR(DX*DX+DY*DY)
SPOFS SPNUM,TX,TY,DR
SPCHR SPNUM,72
RETURN

Edit:
Fixed Distance formula. Thanks @Discostew for pointing it out.

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

GraphicGenius

ramstrong wrote:

Example of using Sprite Collision. Note that SPHITNO is set by the system automatically.

ACLS:CLEAR
MAXSP=19
SPSET 0,96,0,0,0,0
SPHOME 0,8,8
FOR I=1 TO MAXSP
SPSET I,64,0,0,0,0
SPHOME I,8,8
SPOFS I,255+RND(245)+5,RND(180)+5
NEXT

@LOOP
VSYNC 1
SPOFS 0,TCHX,TCHY

FOR SPNUM=1 TO MAXSP
IF SPCHK(SPNUM)==0 THEN GOSUB @MOVE
NEXT

IF SPHIT(0) THEN GOSUB @FLING
GOTO @LOOP

@FLING
BEEP 61
SPREAD(SPHITNO),X,Y
SPCHR SPHITNO,92
SPOFS SPHITNO,X+RND(225),Y+RND(95)-40,40
RETURN

@MOVE
SPREAD(SPNUM),X,Y
TX=TCHX:TY=TCHY
DX=TX-X:DY=TY-Y
DR=SQR(DX*DX-DY*DY)
SPOFS SPNUM,TX,TY,DR
SPCHR SPNUM,72
RETURN

This did not work @ramstrong
It said Illegal function call at the SQR part.(Line 28)

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

randomous

Um, here's some basic sprite info.

SPSET Control number, sprite character number, palette number, horizontal rotation, vertical rotation, order of precedence

This will make a sprite which you can come back to and identify with "Control number" (0-99). You pick this number, so remember it later. The "sprite character number" is the number of the sprite in the sprite sheet. You can use the default sprites if you want to; they have their sprite number listed below them in the "Help" section of Petit Computer. Palette number will color the sprite based on a palette. You're only allowed 16 palettes (0-15) and they're all preset, so try them out. Horizontal rotation just flips the sprite horizontally, much like vertical rotation flips it vertically. Order of precedence tells the sprite where to appear. The screen has many different layers, so this number places it "between" two of them (unless it's at the front). You can place it one of four locations (0-3), where 0 is right in front, and 3 is near the back.

This sprite will now just appear in the corner of the screen. You can move it around with SPOFS:

SPOFS control number,x,y [,interpolation time]

The square brackets mean that the thing inside is optional. The control number is that ID we gave the sprite with SPSET; that first number, remember? X and Y are the screen positions; hopefully you know about that (and if you don't, you can test it out). Interpolation time is optional (you can stop at y) and it allows you to specify how many frames it would take for that sprite to get to the new position. If you don't include this number, it is instant. Note that if you try to use SPOFS with interpolation, then immediately after (before it's finished moving) try to move it again, it will give you odd results.

If you want to animate your sprite, you use

SPANIM control number, number of frames, time between frames

There's that control number again... it's a good thing we gave the sprite an ID to identify it. The number of frames is how many frames this animation will be. SPANIM uses the sprites that immediately follow the sprite you originally chose (plus the one you chose) as the animation. The time between frames is the amount of time (in screen frames/fps, not sprite animation frames) that is inserted between each frame of animation. A higher number gives you a slower animation, while 1 gives you the fastest animation. 0 is an error, so don't do that.

If you want to get rid of this sprite later, it's as easy as:

SPCLR control number.

If you forgo the control number, you'll just erase all sprites. Be careful!

randomous

ramstrong

Reposting from main forum
You have a character(sprite 1) who shoots a bullet (sprite 2), and you want the bullet to go from the character (sprite 1) to somewhere (could be the direction he's facing, or maybe a particular enemy, or touch screen in stylus.)

You need:
1. Create the sprites SPSET for both the character and the bullet.
2. Read the current position of the character SPREAD
3. Get the desired destination coordinates, and the time (in frames) to get there. Use SPOFS.

For example: Here's a boy (1)shooting a fireball(2) 200 pixels away to the right in 100 frames.
SPSET 1,64,0,0,0,0
SPSET 2,142,0,0,0,0

'PUT THE BOY AT COORDINATE 30,50
SPOFS 1,30,50
WAIT 300

'READ BOY POSITION
SPREAD(1),X,Y
'SET FIREBALL TO BOY POSITION
SPOFS 2,X,Y
'SHOOT FIREBALL TO DESIRED DESTINATION AND TIME FRAME
SPOFS 2,X+200,Y,100

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

ramstrong

Reposting from QR Sharing thread so it doesn't get lost. This is an example game using sprites, if you want to see how sprites work in a game.

ramstrong wrote:

Hey guys,
I made a simple game using SPRITE commands. I did it in about 3 hours, and intentionally use as many SPRITE commands as possible. There's no background music, minimal scoring, no background, so hopefully, there's nothing distracting you from learning how to use the SPRITE command.

I assume that you can read the documentation provided in the help menu, but here's a little note about sprite collision:
When you call SPHIT, it will return TRUE or FALSE depending on the collision. However, the program sets the SYSTEM VARIABLE SPHITNO, SPHITX, SPHITY when there is collision. That is why, there is no specific code that deals with collision data, because the data is set automatically.

I did this in about 3 hours, relying mostly on SPRITE behavior. Usually, I'd put in modes for enemy behavior. In this game, I totally ignore that and simply use SPRITE command.

Hopefully, you can read the source code and expand upon it. Will somebody add background (preferably scrolling), music, new sprites, or perhaps a better gameplay? Feel free!

WITCH 0.5

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

Please login or sign up to reply to this topic