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).
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?
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).
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.
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...
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....
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.
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.
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!
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!
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!
Great, thanks!
Does it mean they will appear cropped on 3ds screens? Or do they extend to fill the bigger screen?
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!
Great, thanks!
Does it mean they will appear cropped on 3ds screens? Or do they extend to fill the bigger screen?
By default they'll expand to fill as much of the screen as possible without changing the aspect ratio. As the 3DS' screens are higher resolution this results in it looking a little blurry. If that bothers you, you can also make Petit Computer (and any other DS or DSiWare game) run in its original resolution by holding down Start or Select when you start the game from the 3DS Home menu.
Forums
Topic: Petit Computer
Posts 9,441 to 9,460 of 9,618
Sorry, this topic has been locked.