Forums

Topic: Petit Computer

Posts 9,441 to 9,460 of 9,620

TexMurphy

kunaineck wrote:

Um, newbie here, so please move this post if it's in the wrong thread.

I was wondering if anybody knew how to make a point system? Like if you wanted to let the player choose whether or not their character becomes good or evil. Or if you wanted to make a dating sim and use the system to keep track of how in love one of the bachelors and/or bachelorettes is with the player character.

I just got this program yesterday, so I'm still lost on a lot of things.

You could set a variable and check the value of the variable during the game. The IF statements could be based on a range or exact value. Different reactions could be called depending on the number.
LEVEL= 0
If player does something bad then LEVEL=LEVEL-1
IF LEVEL < 0 AND LEVEL > -3 THEN GOSUB @REACTION1
END
@REACTION1
show negative reaction
RETURN

TexMurphy

Pixelrobin

BTW for the ones here who like programming languages like smileBASIC, join octojam (octojam.com) and make chip8 games using octo. At least I am.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

Discostew

Finished the AI for the first 4 Wily bosses in MM2 PTC, and am now working on teleport mechanics. Wily bosses are not planned for use in custom levels because of how incompatible their AI mechanics are with regard to custom environments (unlike the rest that only required simple changes to make them adaptable to various environments).

Discostew

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

Francis333

How do u make it so it shows your Friend Code whenever u comment?

Francis333

3DS Friend Code: 1676-4500-0150 | Nintendo Network ID: ilovecopper

Discostew

Francis333 wrote:

How do u make it so it shows your Friend Code whenever u comment?

Edit your Profile, and select the Gaming tab.

Discostew

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

GraphicGenius

I really need your guys' help, I'm having trouble making a story for my Text RPG. So far I have about 10 different possibilities.

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

Justlink

GraphicGenius wrote:

I really need your guys' help, I'm having trouble making a story for my Text RPG. So far I have about 10 different possibilities.

choose your best story and post it here. I'm going for a degree in game design and storyboard, so I could help, or try

Do you like videogames? If so, you must know
It's dangerous to go Alone.

MyLegGuy

How can I save and load just a simple string to a grp file?

Hello.

Nintendo Network ID: MyLegGuy2

Discostew

MyLegGuy wrote:

How can I save and load just a simple string to a grp file?

Each character in a string is one byte of data (which ranges from 0 to 255, inclusive). Each pixel in a GRP is one byte of data. What you do to save a string into a GRP is convert each character in the string (you can grab individual characters with MID$) to a numerical value (via ASC), and then write that value into the GRP (via GPSET). Strings can only be up to 256 characters long. Because each string isn't exactly 256 characters, you're going to have to also write in the length of the string so what when you load it, you know how many characters to load.

'SAVE
GPAGE 0,3,0
GI=0

MYSTR$="Hello World"
GPSET GI%256,GI/256,LEN(MYSTR$)
FOR I=1 TO LEN(MYSTR$)
GPSET (I+GI)%256,(I+GI)/256,ASC(MID$(MYSTR$,I,1))
NEXT
GI=GI+LEN(MYSTR$)+1
SAVE "GRP3:MYSTR"

If you're wondering about the %256 and /256, it is because you have to address pixels in GRPs under 2D access. there is no 1D, but because the width is always 256, we use MOD for the X position so it can only range from 0 to 255, inclusive, and we divide by 256 for the Y position. GI is the index. If, for instance, GI is equal to 300, then the GRP position is <44,1>, because 300%256=44, and 300/256=1.1718 (but when using a value for GPSET, it truncates the decimal).

To load, you first grab the first byte to get the length as you wrote it, and then grab each pixel in the GRP (via GSPOIT), converting them to characters (with CHR$), and append them to a string.

'LOAD
GI=0
GPAGE 0,3,0
MYSTR$=""

LOAD "GRP3:MYSTR
MYSLEN=GSPOIT(GI%256,GI/256)
FOR I= 1 TO MYSLEN
MYSTR$=MYSTR$+CHR$(GSPOIT((I+GI)%256,(I+GI)/256))
NEXT
GI=GI+MYSLEN+1

With this method, you can save multiple strings into a GRP of variable lengths, as each string written begins with a length. the important thing to remember is that when reading/writing multiple strings, you must retain the index for the GRP pixels (which I have as GI).

Discostew

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

MyLegGuy

When I tried out the grp saving code I got an error on the ASC(MID$(MYSTR$,I,1)). After some printing I figured out that its trying to get the ASC value of a character that's not in the string because it goes past the end of the string. So then I tried making the for loop go to LEN(MYSTR$)-1, and it got to the end of the code and it let me save. I made the loading code print out MYSTR$ at the end. When I ran it I got: ello world.

So, could you fix it for me please, because I can't seem to fix it.

Hello.

Nintendo Network ID: MyLegGuy2

Discostew

MyLegGuy wrote:

When I tried out the grp saving code I got an error on the ASC(MID$(MYSTR$,I,1)). After some printing I figured out that its trying to get the ASC value of a character that's not in the string because it goes past the end of the string. So then I tried making the for loop go to LEN(MYSTR$)-1, and it got to the end of the code and it let me save. I made the loading code print out MYSTR$ at the end. When I ran it I got: ello world.

So, could you fix it for me please, because I can't seem to fix it.

Ah yes, I changed the code mid-typing to go from "0 TO LEN(MYSTR$)-1" to "1 TO LEN(MYSTR$)" because I wanted the adjustment of the 1st byte to represent the string length (and therefore not have to do GI=GI+1 prior to the GRP writing loop), but I forgot to adjust reading the characters with MID$ by -1. So change the line with MID$ to this...

GPSET (I+GI)%256,(I+GI)/256,ASC(MID$(MYSTR$,I-1,1))

See if that works.

Discostew

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

MyLegGuy

How can I use data, read, and restore to check if a certain variable equals one of the values in a giant data block? I want something like this:

@mydata
data 1
data 7
data 48
data 5387
data 482
data 1

IF ARR(0,5)== (somehow check all the values in @mydata) THEN (do stuff here)

Any help is appreciated!

Hello.

Nintendo Network ID: MyLegGuy2

Discostew

MyLegGuy wrote:

How can I use data, read, and restore to check if a certain variable equals one of the values in a giant data block? I want something like this:

@mydata
data 1
data 7
data 48
data 5387
data 482
data 1

IF ARR(0,5)== (somehow check all the values in @mydata) THEN (do stuff here)

Any help is appreciated!

RESTORE @mydata
READ myval
IF ARR(0,5)==myval THEN .......

That's the basics for it, but since you want to traverse your entire set of values, you will need something to indicate its size, whether than be at the beginning (like its length), or an terminating value (like 0). For the former....

@mydata
data 6
data 1, 7, 48, 5387, 482, 1

RESTORE @mydata
READ mydatalen
FOR I=0 TO mydatalen-1
READ myval
IF ARR(0,5)==myval THEN.......
NEXT

Of course you may want to stop looping after you found what you were looking for, but this set-up doesn't exactly allow that unless you set the iterating variable to be the data length after you done your stuff. If there's a lot of things you want to do if the IF statement is true, then you'll likely use a GOSUB statement. But, as you exit the IF line, you'd need to set that iterating varaible to the length, so when it loops around again, it'll break out of that loop and continue execution onward.

Discostew

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

MyLegGuy

Thanks for the help! I really appreciate it!

Hello.

Nintendo Network ID: MyLegGuy2

Discostew

Francis333 wrote:

@Discostew, why havent you added me yet?

Sorry. I've been very engaged in my project (because I want to get it out before the end of this year). I haven't even exited PTC to get back to the 3DS Home menu in weeks, not even shutting it off, but leaving it in sleep mode and getting it charged each night so I can resume immediately when I can.

Discostew

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

If_Then_Else

Hi, I'm new here and I have a question: up to now, I developed with Petit Computer on a DSi. If I want to share my programs with friends on 3DS, is it correct that the only modification I have to do is changing the background size? Or is this not even necessary?
Thanks in advance for your help!

If_Then_Else

CinnamonRobin

3hibouks wrote:

Hi, I'm new here and I have a question: up to now, I developed with Petit Computer on a DSi. If I want to share my programs with friends on 3DS, is it correct that the only modification I have to do is changing the background size? Or is this not even necessary?
Thanks in advance for your help!

That won't be necessary. The 3DS runs DSiWare titles at their original resolution, so you can share your programs as they are with no problems!

CinnamonRobin

Please login or sign up to reply to this topic