could somebody help me with some issues in my programming?

#1DClaxPosted 7/29/2012 4:42:35 PM
so i'm just trying to do as much as i can first to have something to refer to when i start actually doing something, and my thing right now is:

CLS
ACLS
VISIBLE 1,0,1,1,1,1
@TOP
SPPAGE 0
SPSET 1,80,2,0,0,0,16,16
SPHOME 1,-5,-8
SPSET 0,70,2,0,0,0,16,16
X=120
Y=90
POSX=X
POSY=Y
BGMPLAY 19
COLOR 11
@UPDATE
SPCHR 0,70
LOCATE 0,0
PRINT" A BUNCH OF RANDOM STUFF TO SEE HOW MUCH I CAN PRINT" X23
B=BUTTON()
IF (B AND 32) THEN END
IF BTRIG()==1024 THEN GOTO @PAUSE
@UNPAUSE
IF (B AND 1) THEN GOTO @UP
IF (B AND 2) THEN GOTO @DOWN
IF (B AND 4) THEN GOTO @LEFT
IF (B AND 8) THEN GOTO @RIGHT
SPOFS 0,X,Y,1
WAIT 1
IF TCHST==TRUE THEN GOTO @TOUCH
IF TCHST==FALSE THEN GOTO @UPDATE
@TOUCH
IF TCHX<100 THEN GOTO @LEFT
IF TCHX>140 THEN GOTO @RIGHT
IF TCHY<70 THEN GOTO @UP
IF TCHY>110 THEN GOTO @DOWN
SPOFS 0,X,Y,1
WAIT 1
GOTO @UPDATE

@PAUSE
LOCATE 0,9
COLOR 11
PRINT " A BUNCH OF FANCY STUFF THAT SPELLS "PAUSE"" X7
WAIT 1
IF BUTTON(1)==1024 THEN GOTO @UNPAUSE
GOTO @PAUSE

@UP
IF Y<0 THEN Y=0
Y=Y-1
SPCHR 0,78
SPANIM 0,1,15,0
IF TCHY<24 THEN Y=Y-1
SPOFS 0,X,Y,1
IF SPHITSP (0,1) THEN GOTO @WIN

@DOWN, @ LEFT, @RIGHT ARE PRETTY MUCH THE SAME THING EXCEPT WITH DIFFERENT VARIABLES

@WIN
CLS
PRINT "STUFF"X2
IF BUTTON()==32 THEN GOTO @TOP
WAIT 1
GOTO @WIN
___________________________________________________
so i have a few problems, the first being that my sprite won't be animated when walking in a direction. it just changes to facing the right direction but it doesn't look animated.
the 2nd is that randomly by using the touch screen the sprite will move super fast, faster then its supposed to when touching the outer edges
the 3rd is that pressing "A" when i get to the end doesn't do anything, and i can still press b to end the game, which isn't supposed to happen

also, i have some questions. how do i get the Pause text to blink?
and how do i load a background image?

i actually have a ton more questions but this post will be annoyingly long if i ask then so....yeah...

thanks in advance to anyone who helps me out. i really appreciate it

and sorry for the long post and no qr to scan instead of having to read all that. i have the qr codes...i'm just not sure how to get them on the internet
---
3DS FC: 1676-3725-4140 (msg me if you add me)
#2someguy28898Posted 7/29/2012 5:48:44 PM
ok so your SPANIM CALL:

SPANIM 0,1,15,0

is telling it to animate sprite 0 1 frame after 15 ticks, and not loop. Try:

SPANIM 0,2,15,1 and I bet you'll notice the animation.

As for your touch controls, I think the problem is that it's just calling the move functions a lot because each tick you're checking if the LAST PLACE TOUCHED is > your thresholds and until you touch another point and they're not. try this, where it only coulnts if the pen is down, and only checks once every second. This code also requires you to take @TOUCH out of your main and make it a proper sub-routine, then place GOSUB @TOUCH in your main where @TOUCH used to be.

TTIMER=0 'keep track of time since last touch
TOUCHSPEED = 60 'the rate to check for touches

@TOUCH
IF TCHST==FALSE THEN RETURN
IF TTIMER < TOUCHSPEED THEN RETURN
TTIMER=0
IF TCHX<100 THEN GOTO @LEFT
IF TCHX>140 THEN GOTO @RIGHT
IF TCHY<70 THEN GOTO @UP
IF TCHY>110 THEN GOTO @DOWN
RETURN

This way it should only check TCHX and TCHY if the screen is actually being pressed.

Getting the pause text to blink:
http://www.gamefaqs.com/boards/663843-petit-computer/63509426

Loading a background image is a simple as creating one, saving it, and having a LOAD"GRP:FILENAME",FALSE line at the start of your program. Also see this thread:
http://www.gamefaqs.com/boards/663843-petit-computer/63532931

I'm not really sure I understand your hittng A and B problem, can you clarify? or post those QR codes? Google imgur, photobucket, there are plenty of free image hosting sites. You can save your code to the SD card, put the card into your computer, open the file, copy the text to PTC utilities or

http://translate.google.com/translate?sl=ja&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http%3A%2F%2Fsmileboom.com%2Fspecial%2Fptcm2%2Fhtml_reference.php&act=url

to get the QR codes.
#3DClax(Topic Creator)Posted 7/29/2012 6:32:25 PM
http://imgur.com/V5sZO
http://imgur.com/a9Quh
ok, those are the qr codes. and what you suggested about the anim. isn't working, instead when i let go of lets say right, the character faces forward, then animates itself walking forward by 1. still trying the other stuff you suggested, thanks
---
3DS FC: 1676-3725-4140 (msg me if you add me)
#4someguy28898Posted 7/29/2012 6:39:01 PM
DClax posted...
http://imgur.com/V5sZO
http://imgur.com/a9Quh
ok, those are the qr codes. and what you suggested about the anim. isn't working, instead when i let go of lets say right, the character faces forward, then animates itself walking forward by 1. still trying the other stuff you suggested, thanks


Sorry try SPANIM 0,2,15,0
#5Fargo22Posted 7/31/2012 4:44:36 AM
Regarding the animation, I found that using a variable to "trigger" the animation is useful...

See, the problem is that when you are going into, say, the @UP subroutine using BUTTON(), you are actually calling that subroutine repeatedly. The problem with this is that the animation is bein restarted over and over. In other words, it never gets a chance to animate! Here try this code fo your up...

First, make a variable so that when up is pressed, it turns on, and when you let go of up, it turns off. Something like this...

Put this in your global variables...
CHECK=0

DIR=BUTTON(2)
IF DIR AND 1 THEN CHECK=1 ELSE CHECK=0

Now, for the UP subroutine...
CHECK=0

@UP
IF Y<0 THEN Y=0
Y=Y-1
IF CHECK ==0 THEN SPCHR 0,78
IF CHECK==0 THEN SPANIM 0,2,15,0
DIR=BUTTON(2)
IF DIR AND 1 THEN CHECK=1

IF TCHY<24 THEN Y=Y-1
SPOFS 0,X,Y,1
IF SPHITSP (0,1) THEN GOTO @WIN

Finally, you need to turn the CHECK variable off when your character isn't moving, so use a BUTTON(3) for a button release...

@UP
IF Y<0 THEN Y=0
Y=Y-1
IF CHECK ==0 THEN SPCHR 0,78
IF CHECK==0 THEN SPANIM 0,2,15,0
DIR=BUTTON(2)
IF DIR AND 1 THEN CHECK=1

DIRREL=BUTTON(3)
IF DIRREL AND 1 THEN CHECK=0

IF TCHY<24 THEN Y=Y-1
SPOFS 0,X,Y,1
IF SPHITSP (0,1) THEN GOTO @WIN

By the way, DIR stands for Direction, and DIRREL is for Direction Release :)

Uh... this is sort of how I did my animation. If it doesn't work for you, I will check back in a little while, to see if I can help.
---
GAMER 4 LIFE :P
#6Fargo22Posted 7/31/2012 4:52:36 AM
Couple of quick things while I'm thinking about them...

First, I coded my program a little differently then the way you did yours. For one, I did movement separately from animation. Animation was actually a subroutine in my uh... movement subroutine (Which is part of my main loop)

Anyways, if the code I posted above doesn't work, maybe I can help you with making sure it does! I would be happy to help :)

Also, if you do the same extra code for the other directions, it should work for them as well. Just change the number to match which direction is being pressed (right below the BUTTON(2) and BUTTON(3) commands that is).

Let me know how it works out.
---
GAMER 4 LIFE :P
#7Fargo22Posted 7/31/2012 4:55:56 AM
One more thing... A is the number "16", not "32"...

Didn't know if you knew that...
---
GAMER 4 LIFE :P