Forums

Topic: Petit Computer

Posts 776 to 795 of 9,620

bloodofgore

Another question, how do I make buttons that can be activated with the stylus?

bloodofgore

Eel

Are you loading it like:
LOAD"MEM:NOTE"
?

That should change the contents on the local MEM$ variable with the contents on the MEM file named NOTE.
It will not automatically assign the values stored on it to the correct variables, it all will go to MEM$ and it is your job to reassign the values.

There's something about this in the Tutorials thread too, if you want to read more.

Bloop.

<My slightly less dead youtube channel>

SMM2 Maker ID: 69R-F81-NLG

My Nintendo: Abgarok | Nintendo Network ID: Abgarok

tiger667

@bloodofgore
as far as touch buttons go you can't technically make them, but we can fake it.
first you need to get rid of the keyboard with PNLTYPE "OFF"
then put an image on the bottom screen, I usually use background drawing for this; BGPAGE 1;BGFILL L,X1,Y1,X2,Y2,NUM,PAL,HR,VR
L=layer, you can put it on layer 0 or 1; X1Y1= starting x/y coordinates; (top left) X2Y2=ending X/Y coordinates(bottom right); NUM=character number in the background image database (which can be customized, but that is for later); PAL=pallet to use for the image; HRVR=horizontal/vertical rotation (0 for none, 1 to flip along that axis)
now you have the "button" on the screen we need to set up recognition for the touch.
you need to create a loop (or add to a loop you already have) a check for if the screen is touched (with multiple buttons it can speed up performance if you set this as an initial check so it doesn't have to go through the rest if the screen is not touched) then compare the TCHX and TCHY variables to the location of the button (use floor(TCHX/8) and same for Y to get direct number, because TCHX and Y use pixel numbers). Here is an example
PNLTYPE "OFF"
BGPAGE 1;BGFILL 0,15,15,17,17,4,0,0,0
@LOOP
IF !TCHST THEN GOTO @LOOP
TX=FLOOR(TCHX/8);TY=FLOOR(TCHY/8)
IF (TX>=15 AND TX<=17 AND TY>=15 AND TY<=17) THEN GOSUB @PRESSBUTTON
GOTO @LOOP

if you need to do other things you can add the TCHST and TCHX/Y to whatever loop you already have doing things. I personally use a seperate gosub to check for touches when I am doing lots of other checks or manipulations. I read that PETIT COMPUTER can read 2000 lines of code in a single frame, so you don't really have to worry about it not catching the touch unless you have lots of code in your loop.

Advanced trick: this is what I use now, it lets the user change their mind by not considering the button touched unless they lifted the stylus from the button (if they touch it and move off it it does nothing). just showing the loop

R=0
@GETTOUCH'(THIS IS CALLED INTO AS A GOSUB)
TOUCH=0
TX=FLOOR(TCHX/8)
TY=FLOOR(TCHY/8)
IF TCHST THEN R=1:RETURN '(IF TCHST is short for IF TCHST==TRUE
IF !R THEN RETURN'(IF !R is short for IF R==0)
R=0
IF (TX/TY BOUNDS AS ABOVE) THEN TOUCH=1
'REPEAT ABOVE FOR EACH BUTTON, WITH DIFFERENT TOUCH=
RETURN
@CHECKTOUCH'(THIS IS CALLED INTO AFTER GETTOUCH)
IF !TOUCH THEN RETURN
IF TOUCH==1 THEN GOTO @BUTTON1'(make sure button 1 has return, it will return to where checktouch was called)
'REPEAT ABOVE FOR EACH BUTTON'S TOUCH==

I use two subs so save time when there is no touch, it will only fall through the entire sub if it has to.

tiger667

portealmario

How do you delet files in the "write program" mode?

meng 😐
3ds friend code:1762-2769-7142

portealmario

Ok, good!

meng 😐
3ds friend code:1762-2769-7142

swordx

I just came up with a great idea for Dungeon Adventure. Expect PART of the final boss to be real time, and not turn based. It should be interesting...

swordx

koopatroopaX

ok then if this is a better place to put my comment in... I think that i might be having trouble with the money system in Petit farm. i had planted about 15-16 carrots in the garden, and waited for a couple weeks for them to finally grow. when this happened, and i cashed them all in. for some reason my money counter didn't stop at 99999, it completely deleted all my money, i can still get more money over time through that fruit a day section thank goodness, but i lost all of the 99999 money i spent so much time working for. is this a simple overflow of the 5 digit barrier so it deleted the information, or is it a bug that happens when you put in more money then the system can handle that it deletes it all? anyone have any ideas?

koopatroopaX

Eel

Well, literally, all the game does is:
IF MONEY>99999 THEN MONEY=99999

Carrots give 11,200 each, so shipping more than 8 at once is actually sightly wasteful, but they totally shouldn´t empty your wallet.

I'll check it myself later and see where is the possible error

Bloop.

<My slightly less dead youtube channel>

SMM2 Maker ID: 69R-F81-NLG

My Nintendo: Abgarok | Nintendo Network ID: Abgarok

81Rambler

Well I'm showing my hand a bit early, but I just had a query regarding line lengths and if there's anyone with an idea on how to clean up my code a bit.

To simplfy things, here's a basic display code I got together for the game I'm working on. I'm sure most of you will be able to figure out what I'm going for here, although I'll be changing a few of the graphics here and there once I get the basic engine running.

Untitled

My problem comes with the last portion of the code in line 35 used for writing the characters from the CELL$ string. While in all function it works quite fine I find the use of a dedicated GOTO to skip the first three lines of the 'Bucket' image for the top three rows of sprite groups a little less than elegant. The most obvious solution is to move the IF statement into the same line as the GPUTCHAR, unfortunatly it's at this point I hit the character-per-line limit as the GPUTCHAR is bulky enough on it's own, incorperating the mathmatics of pulling the right characters from the CELL$ string.

-
READ CELL$
FOR DRAWY=5 TO 22
IF (DRAWY-5)%3==2 AND DRAWY<=13 THEN GOTO @SKIPBRRL
FOR DRAWX=5 TO 28
GPUTCHAR DRAWX*8,DRAWY*8,"BGF0',ASC(MID$(CELL$,(DRAWX-5)%4+(DRAWY-5)%3*4,1)),6,1
NEXT
@SKIPBRRL
NEXT
-

Really this is a minor bother, I just try to be as minimalist as possible when it comes to coding and using as few varitables and loop tags as possible (see my Queens game where I use game function varitables for calculating the player's final score). I'm just curious how other people would do it.

In the meantime I'll start working with sprites for the character displays (although i may stick with ascii for some elements, like score, the bombs, etc), but any input would be appreciated

Edited on by 81Rambler

81Rambler

steriaca

Just to let eveyone know, my first two programs are up on the Petit Computer Wikia ( http://petitcomputer.wikia.com ).

Feal free to coment on them.

My Friend Code is 3368-1310-0690.

portealmario

I am having alot of trouble with data statements, and it seems like I can barely make a proper game w/o them, can any of you help me?

meng 😐
3ds friend code:1762-2769-7142

neoxid500

@Morphtroid
When do I clean my cows?
And also for anyone who needs more energy, by those egg things; they up your max energy (I bought 6 )

neoxid500

GrabSomeEyes

So. I decided to work on my just started OS today.
It's nearing completion at this point... SO. Will likely be posted either late in the night tonight, or sometime in the day tomorrow.
I think my biggest challenge was trying to think of a name for it.
Anyway, features: Nothing special.

Eos OS: http://conlogxl.forumotion.com/t12-eos-os-v10
3DS FC: 3695-0514-5044

Eel

neoxid500 wrote:

@Morphtroid
When do I clean my cows?
And also for anyone who needs more energy, by those egg things; they up your max energy (I bought 6 )

Once a day is fine. They don't really need it, but it makes them happy.

Bloop.

<My slightly less dead youtube channel>

SMM2 Maker ID: 69R-F81-NLG

My Nintendo: Abgarok | Nintendo Network ID: Abgarok

GrabSomeEyes

I started "Red OS" with a hundred lines of coding today.
I ended with "Eos OS" at six-hundred eighty-eight lines of coding.
Well, I'm not sure whether I should be proud of myself or if I should regret how long I worked (I also managed to lose my stylus twice in the process).
Anyhow, the QR codes will be up on the QR code forum in just a few minutes.

Eos OS: http://conlogxl.forumotion.com/t12-eos-os-v10
3DS FC: 3695-0514-5044

portealmario

Finished my os a while ago, but due to internet problems, it isn't coming until after october 20.

meng 😐
3ds friend code:1762-2769-7142

GrabSomeEyes

portealmario wrote:

Finished my os a while ago, but due to internet problems, it isn't coming until after october 20.

Do you still have the QR codes for your most recently uploaded version? I don't think anyone could get them to work, so if you have those, perhaps you could get the post fixed so we have something for the wait.

Eos OS: http://conlogxl.forumotion.com/t12-eos-os-v10
3DS FC: 3695-0514-5044

Shadow1364

I think there is a bug on petit farm... When I went to feed my cows, I saw there was already hay in front of cow#3, so I ignored feeding it. The cow died the next day and its hay is still there, and when I tried to feed cow #2, the hay disapeared the first time I threw it on the ground, but not the second time.
By the way, my new game is in beta stage, and will finish up soon when I add some music and make it more user-friendly

Edited on by Shadow1364

FC: 1934-1622-0902

Please login or sign up to reply to this topic