Forums

Topic: Petit Computer

Posts 8,241 to 8,260 of 9,620

Master2112

Greetings! I recently got Petit Computer for my 3DS, and after some playing around in it, there's one thing i'd like to be able to do.
Object Oriented programming somewhat spoiled me in modern languages, but what i'd like to be able to do is create some sort of object that can contain it's own set of variables. An enemy object for example, which has it's own health amount, and a name or something.

I have no doubt that this is doable in some way, but i haven't been able to find something on it so far. I'm guessing it could have something to do with the DATA command, but i'm not sure.

Is there anyone that is willing (and able, or we'd be stuck at the same point) to explain if and how i can do this?
Ideally, i'd like to be able to make an extremely simplified version of the text-based Rogue, and being able of just "instantiating" another random enemy dude which then has it's own health value and "sprite" (which is one of the smiley characters in the petit computer keyboard or something), or any other related values.

"You either die a hero, or live long enough to see yourself become TRWTF."
I'm a Game Developer! View my creations and experiments on my website: http://timfalken.com/

GraphicGenius

@IAmAPersson the screenshot you posted is amazing! It's OK if you quit for a while, but you have to come back once your done with all that. By the way I got the new update and it's amazing! I wish there was less lag though.
@Randomous I just downloaded Village and it's amazing! I said that I was going to China LOL.
@swordx you haven't been on this forum for a long time. What were you doing? Also, what about that sprite game you were making a while ago? IS it done? Have you released it? Are you still working on it?

Edited on by GraphicGenius

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

swordx

GraphicGenius wrote:

@IAmAPersson the screenshot you posted is amazing! It's OK if you quit for a while, but you have to come back once your done with all that.
@Randomous I just downloaded Village and it's amazing! I said that I was going to China LOL.
@swordx you haven't been on this forum for a long time. What were you doing? Also, what about that sprite game you were making a while ago? IS it done? Have you released it? Are you still working on it?

I've been playing games, going to school, running Cross Country, hanging with friends, and watching the Game Grump. I work on my game every now and then. I happen to be working on it right now. Maybe I'll actually get stuff done. I want it to be really great, so I only work on it when I know I have a lot of time. If you're wondering what progress I've made, I added a Game & Watch arcade to it.

Edited on by swordx

swordx

Pixelrobin

@Master2112 are you familiar with sprites? They're kind of like "objects" and can store about 8 variables each. But you can only have 100 sprites at once. 23 of which that are rotated or scaled. You can test for collision between sprites and move them and stuff.

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

Master2112

@Bluerobin2 Haven't tried those, no.
If i were to use a sprite only as a container for an object, how would i set that up?
What's most important for me is being able to create and destroy while the game is running. Preferably in an array, so i can loop over them and decide what to do. (though it would be a lot better if each sprite is running it's own update loop, though i think that's asking too much for now)

For example, in a c# thingy i'd do enemy[someRandomIndexValue] = new EnemyObject() (If i made an EnemyObject class of course!)

and then i could manipulate that with this:

enemy[index].x = 10
enemy[index].health -= 10

if(enemy[index].health <= 0)
<destroy the enemy in some way>

How would i do something like that in Petit Computer?

Edited on by Master2112

"You either die a hero, or live long enough to see yourself become TRWTF."
I'm a Game Developer! View my creations and experiments on my website: http://timfalken.com/

GraphicGenius

@Randomous yea it's actually pretty fun but it took me 20 minutes to scan the QR codes

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

TexMurphy

@Master2112 You can set up several arrays or a two dimensional array in PTC. There are tutorials on how to create an array in the tutorial thread. I did something similar with a program called FOLLOW4 (page 163). I have multiple bullets that can be moved in different directions. They track their own path. Others here have used GRP files to record data as pixels 0-255. They then save as a GRP file. You can use the row y OR column x value as an index to the data stored in that row or column.
PTC does not have methods and properties like OOP. Except for the variables in SPSETV and SPGETV() for sprites.

Edited on by TexMurphy

TexMurphy

ramstrong

Master2112 wrote:

enemy[index].x = 10
enemy[index].health -= 10
How would i do something like that in Petit Computer?

I hate doing dynamic memory allocation, even in OO. So, I'm not to thrilled in creating objects on the fly. PTC has limited characters for variable names, but otherwise, you can easily mimic the structure with globals:
ENEMY_X[INDEX] = 10
ENEMY_HEALTH[INDEX] = ENEMY_HEALTH[INDEX]-10
Practically speaking, I find there's very little difference between structures and globals. enemy.health and ENEMY_HEALTH may be two different things internally, but practical usage is about the same anyway. You can also simulate method calls by doing this:
COMMAND=2
...
ON COMMAND GOSUB @CMD1,@CMD2,@CMD3
Or something like that. In OO implementations, that's done with pointer/reference. But little practical difference than computed GOTO/GOSUB IMHO.
PTC also allows strings as label, so you can easily do this, too:
COMMAND$="@FIRE"
GOTO COMMAND$

Or even this:
INDEX=3:COMMAND$="@ENEMY_FIRE"
GOTO COMMAND$

Note that those are examples. Variable name length is extremely limited in PTC.

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

TexMurphy

@ramstrong
So if I got this right, you can say
FOR J=0 TO 10
COMMAND$="@FIRE" + J
GOSUB COMMAND$
NEXT

TexMurphy

ramstrong

TexMurphy wrote:

@ramstrong
So if I got this right, you can say
FOR J=0 TO 10
COMMAND$="@FIRE" + J
GOSUB COMMAND$
NEXT

Yes. Alternatively, you can set up an array like so:
GOSUB COMMAND$[J]

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

noxuss

I'm fairly certain there's a command for positioning the console for text, but is there any way to detect where the console is currently printing to? I want to make a console that if it gets too far down the page, it will reset itself at the top of the textbox.

EDIT: I just realised I use locate all the time, but I still haven't figured out my question. Also how can I change which screen it appears on? (The Console)
EDIT EDIT: Figured out the screen thingy, PNLSTR plus VAR() and STR$().

Edited on by noxuss

noxuss

Pixelrobin

@noxuss problem solving is a wonderful thing isnt it?

Everybody do a chirp. CHIRP.

3DS Friend Code: 3007-9228-5126

ramstrong

REM SNAKES AND LADDERS
CLS:CLEAR
DIM SQ[150]:'100 SQUARES
DIM P[4]:'NUMBER OF PLAYERS
CP=0:'CURRENT PLAYER
'SNAKES/LADDERS
SQ[RND(80)+10]=RND(80)+10
SQ[RND(80)+10]=RND(80)+10
SQ[RND(80)+10]=RND(80)+10
SQ[RND(80)+10]=RND(80)+10
SQ[RND(80)+10]=RND(80)+10
SQ[RND(80)+10]=RND(80)+10

@LOOP
REM ROLL DICE
D=RND(6)
?”PLAYER “;CP;” ROLLS “;D
P[CP]=P[CP]+D
?”PLAYER “;CP;” MOVES TO SQUARE “;P[CP]
IF SQ[P[CP]]==0 GOTO @LOOP1
IF SQ[P[CP]] < P[CP] THEN ?”SNAKE! MOVE BACK TO “;SQ[P[CP]]
IF SQ[P[CP]] > P[CP] THEN ?”LADDER! MOVE UP TO “;SQ[P[CP]]
IF SQ[P[CP]]==P[CP] THEN ?”WHEW! FALSE ALARM.”
P[CP]=SQ[P[CP]]
@LOOP1
REM WINNING CONDITION
IF P[CP] > 99 THEN ?”PLAYER “;CP;” WINS”:GOTO @END
CP=(CP+1)%4
WAIT 60
GOTO @LOOP

@END
?”GAME OVER”
END

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

Let's just call a spade, a spade.

3DS Friend Code: 1091-7596-4855

boot

@IAmAPersson great job! i really like the update! how would i make it so the raytracer is automaticly off so i dont have to turn it off, and how would i make it so mods it automaticly on? also is herobrine in the game? @twin great job on the mod! its the first harmful mob!

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

3DS Friend Code: 0791-4881-1672

twinArmageddons

boot wrote:

@IAmAPersson great job! i really like the update! how would i make it so the raytracer is automaticly off so i dont have to turn it off, and how would i make it so mods it automaticly on? also is herobrine in the game? @twin great job on the mod! its the first harmful mob!

you would have to edit some code, herobrine is not in the game yet, and the creeper isn't really harmful it's just annoying XD

get in loser we're going titan hunting

3DS Friend Code: 2879-0639-8952 | Nintendo Network ID: merp_aottg

Espurr

Bad news: No NetHack. I am trying simpler things, so now I am doing COIMS. It means Character Overworld Inventory Management System.

Edited on by Espurr

"The heart has reasons the mind knows nothing of."-Blaise Pascal
Pokemon X Friend Code:3883-5184-5725
Safari: Grass
Pokemon: Pansage, Sawsbuck (Spring), Gogoat.

damolii

I've been gone a little too long O.o......

I don't have a 3DS so what do I put here? -Damolii

InsertPi

For those of you who haven't been on the Wiki, I made my first compiled language in PTC. Its name? Mindcrush! (No, not the kind from Yu Gi Oh). It's very similar to brainf*ck in the ways of its simplicity. There are 9 commands:

">" increase pointer
"<" decrease pointer
"+" add 1 to cell
"-" subtract one from cell
"/" print contents of cell or input character if cell is empty
"&" return a yes/no value on condition
"[" start infinite loop
"]" end infinite loop (you can have loops inside of loops inside of loops and so on to infinity)
"." marks a "check" in the program

Here's a simple program that prints "HI!"

---------/-/[-].++++/[]

Here's a simple Quine program (repeats user input directly as output)

[//&->].[<].[&/>].[]

Here's a simple calculator (only works with one digit numbers)

+/--/+//>-//+++/---/+//<[&.->+<].>>-/</[]

Will release compiler tomorrow.
Also, I'm doing interpreters for anyone who wants one! Give me some commands and their syntax and I'll make an interpreter for it! Just post on my PTC Wikia message wall.

EDIT: Since Mindcrush and Brainf*ck are so similar, I tweaked my Mindcrush compiler to become a Brainf*ck compiler. You guys are probably more interested in the Brainf*ck compiler, but I'll release both anyway. Brainf*ck compiler includes:

  • 30,000 slots in the "tape" (storage array)
  • 1,000 lines, each supporting space for about 30 characters
  • Each cell can hold any number from -127 to 128. If it goes outside of these boundaries, it wraps around (-127 minus 1 becomes 128)
  • All commands and functions that the original brainf*ck compiler had
  • Full 100% portability of code
  • Glitch-free (as far as I can tell)

EDIT EDIT: @boot change the RSS$ string (I think) default value to "Off" instead of "On"

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:

Discostew

A little update, but I got an additional entity working in my project.

Untitled

The reason why this is special is because this worked somewhat different from all the other entities, relying on the background layers alongside sprites, which required having to make numerous alterations to the game engine and editor. What makes this news to report is that these entities are not limited to a particular stage like they were in the original game. You can place them in any stage you want in your custom levels. This is leading towards making other background-based entities like the Hot Dog (in Woodman's stage), and the Anko (in Bubbleman's stage), as well as some Wily bosses.

Discostew

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

Please login or sign up to reply to this topic