Also, i got this error:
Subscript out of range (11)
My code is:
F(Q)=0
Whats wrong with that?
You need to ask better questions than that because there is nothing wrong with that statement. The error lies somewhere else. It is important that you write the shortest code that still demonstrate the problem. You need to figure out what the problem is and write a sample program that duplicates the same problem. If you have Duplicate Definition Error, you should write this program:
DIM A$[10]
and run it twice. Why did it fail the second time? DIM defines the variable. You cannot redefine variables here. There are different situations that can take advantage of previously defined variables, so this isn't an error. You need to figure out a way around it.
Don't take it the wrong way, but I think you should familiarize yourself with Petit Computer and type in other people's program and see how they work. Otherwise, we'd be porting your program for you, and who knows how long that will take? We're here to help, not do your homework for you. You need to have some initiative yourself.
Try to learn something new everyday, and write a small program to demonstrate your learning. Share if you do. We can use more tutorial pages!
Im sorry, its just frustrating when it doesnt work.
One more question, then im done..
Here is my full coding for a dice simulator.
LOCATE 10,1:? "Dice"
PRINT:PRINT:PRINT
DIM F(12)
PRINT "THIS PROGRAM SIMULATES THE ROLLING OF A"
PRINT "PAIR OF DICE."
PRINT "YOU ENTER THE NUMBER OF TIMES YOU WANT THE COMPUTER TO"
PRINT "'ROLL' THE DICE. WATCH OUT, VERY LARGE NUMBERS TAKE"
PRINT "A LONG TIME. IN PARTICULAR, NUMBERS OVER 5000."
FOR Q=1 TO 12
F(Q)=0
NEXT Q
PRINT:PRINT "HOW MANY ROLLS";
INPUT X
FOR S=1 TO X
A=INT(6*RND(1)+1)
B=INT(6*RND(1)+1)
R=A+B
F(R)=F(R)+1
NEXT S
PRINT
PRINT "TOTAL SPOTS","NUMBER OF TIMES"
FOR V=2 TO 12
PRINT V,F(V)
NEXT V
PRINT
PRINT:PRINT "TRY AGAIN";
INPUT Z$
IF Z$="YES" THEN 80
END
But it doesnt work:/
I tried dim F(Q), but it says duplicate definition.
Can someone help me i'm trying to use sphitsp like this IF SPHITSP (1,0) THEN GOSUB @STORE and it won't work (it is in a loop) all that happens is that the store opens as long as the store sprite is on screen.
Can someone help me i'm trying to use sphitsp like this IF SPHITSP (1,0) THEN GOSUB @STORE and it won't work (it is in a loop) all that happens is that the store opens as long as the store sprite is on screen.
You don't make it easy for us to help you, do you? Did not Cocobanana just now had trouble getting his question answered because he didn't give out enough info? From now on, unless the question is well formed, I don't want to answer. What kind of questions are good ones? Petit Tutorial Forum post#9.
In your case, though, I'd say that the store opens only when the sprite in on screen because you did not supply a Status/Flag variable that specify the store should be open when the sprite is off screen. That is:
STORE=OPEN if SPRITE=HIT
when what you want is
SHOULDOPEN=TRUE if SPRITE=HIT
STORE=OPEN if SHOULDOPEN=TRUE
That's just pseudocode. You need to do the programming yourself. You also need to specify the condition when the store should close. Be careful, you don't want to close the store when the sprite isn't hit!
okay let me reform my question because your answer didn't fix my problem.
i have a sprite in the middle of the screen that represents your character and another sprite that represents the store.
i want the store to open when your sprite hits the store sprite.
Depends on the question. Did you read the tutorial post? Here's an example:
You know how PRINT statement works, right? What if there's somebody who ask help like this: "How do you use PRINT?", following your answer with "It doesn't work."
Here's what I want to see:
When I see the words "I don't understand ..." it'd better be followed by "These are the things I tried in order to understand it."
See the difference?
Please,please, please read the tutorial post. It will make life much easier for everybody.
Is there a command that stops the computer from going through coding and waits for the user to press any key to continue(like the "sleep" command in other BASIC languages)?
This was originally on the QR Code sharing thread but people are being CATZ... and keep asking about MMLS. Use this program to make 'em much easier and implement them in your games.
I won't be able to use Petit Computer for a while until I get a new stylus and screen protector
Keep programming for me, you all.
I'm curious of how well can people copying code from text as opposed to just scan QR code. So, this will come only as source code, no QR. Let's see how well you can copy this, and hopefully understand it. I won't be explaining anything. The source code tells all!
Major bragging rights to the first person who can change P[] array to meaningful numbers. Except for Morphtroid, who can do this in his sleep!
If you have problem, you may ask for explanation, but make sure to do your homework and show your analysis of the problem, with your potential solution.
PS: I did this in 2 hours pecking at the screen with the stylus! How far can you go? Keep pushing!
@END
BEEP 7:LOCATE 18,18:?"WIN!"
FOR I=1 TO 1:VSYNC 1:I=BUTTON(3):NEXT
END
@MOVE
FOR I=1 TO 1:VSYNC 1:B=BUTTON(3):I=B:NEXT
BEEP 66
IF B AND 32 THEN G$=SUBST$(G$,CY*16+CX,1,"0")
IF B AND 16 THEN G$=SUBST$(G$,CY*16+CX,1,"1")
IF B AND 1 THEN CY=CY+15
IF B AND 2 THEN CY=CY+1
IF B AND 4 THEN CX=CX+15
IF B AND 8 THEN CX=CX+1
CX=CX%16:CY=CY%16
SPOFS 1,CX*8,CY*8
RETURN
@PANE
FOR I=0 TO 15:FOR J=0 TO 15
LOCATE J,I
IF "0"==MID$(G$,I*16+J,1) THEN ?CHR$(32) ELSE ?CHR$(224)
NEXT:NEXT
RETURN
@DISP
CLS
FOR I=0 TO 255 STEP 16
H$="":C=0
FOR J=0 TO 15
IF "1"==MID$(P$,I+J,1) THEN C=C+1
IF "0"==MID$(p$,I+J,1) THEN IF C THEN H$=H$+STR$(C):C=0
NEXT
IF C THEN H$=H$+STR$(C)
LOCATE 17,I/16:?H$
NEXT
FOR I=0 TO 15
H$="":C=0
FOR J=0 TO 15
IF "1"==MID$(P$,I+(J*16),1) THEN C=C+1
IF "0"==MID$(p$,I+(J*16),1) THEN IF C THEN H$=H$+STR$(C):C=0
NEXT
IF C THEN H$=H$+STR$(C)
FOR J=0 TO LEN(H$)
LOCATE I,16+J:?MID$(H$,J,1);
NEXT
NEXT
RETURN
Forums
Topic: Petit Computer
Posts 561 to 580 of 9,620
Please login or sign up to reply to this topic