Jump to content
IGNORED

Character's moving animation stops when I move diagonally.


ioi_xd

Recommended Posts

https://www.youtube.com/watch?v=eaAhjlXgzH4

I've been getting into VirtualBB programming recently (ended up using the official docs as a guide) and I seem to have run into a problem. Whenever I move diagonally, or press two joystick buttons at once, there's a chance that the moving animation just freezes for a couple of seconds. I'm not sure what causes this problem. Can somebody help? a

Here's the code. If this can be simplified I'd greatly appreciate it.

 rem Generated 4/12/2018 5:43:58 PM by Visual bB Version 1.0.0.548
 rem **********************************
 rem *<filename>                      *
 rem *<description>                   *
 rem *<author>                        *
 rem *<contact info>                  *
 rem *<license>                       *
 rem **********************************
 playfield:
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

 f=0

 set tv
 x=75 : y =75
main
 COLUP0 = $00
 COLUP1 = $00
 COLUBK = $0E

 player1x=x
 player1y=y

 if f=10 then player1:
 %00000000
 %00011000
 %00011000
 %01111110
 %01111110
 %00011000
 %00011000
 %00000000
end

 if f=20 then player1:
 %00000000
 %00110000
 %00110110
 %00011110
 %01111000
 %01101100
 %00001100
 %00000000
end

 if f=30 then player1:
 %00000000
 %01100110
 %01100110
 %00011000
 %00011000
 %01100110
 %01100110
 %00000000
end

 if f=40 then player1:
 %00000000
 %00001100
 %01101100
 %01111000
 %00011110
 %00110110
 %00110000
 %00000000
end

 if f=40 then f=0
 drawscreen
 player1x=x :  player1y=y
 if joy0right then x=x+1
 if joy0right then f=f+1
 if joy0left then x=x-1
 if joy0left then f=f+1
 if joy0up then y=y-1
 if joy0up then f=f+1
 if joy0down then y=y+1
 if joy0down then f=f+1
 goto main

Edited by ioi_xd
Link to comment
Share on other sites

How is f being increase or decrease when there's no f=f+1 or f=f-1 anywhere in the code provided?

Apologies. I removed that from the code for reasons forgotten and I forgot to add it back in. Keep in mind the video was recorded with this code in.

 

edit: I seem to be having more problems with the updated code so I know this probably isn't the code I used. Please stand by while I update it.

 

edit 2: code updated, this time with more info

Edited by ioi_xd
Link to comment
Share on other sites

This bit of code can be simplified:

 if joy0right then f=f+1
 if joy0left then f=f+1
 if joy0up then f=f+1
 if joy0down then f=f+1

to this:

if SWCHA>0 then f=f+1

Also you might want to change this:

if f=40 then player1:
 %00000000
 %00001100
 %01101100
 %01111000
 %00011110
 %00110110
 %00110000
 %00000000
end
 
 if f=40 then f=0

to this:

if f=40 then f=0 
if f=0 then player1:
 %00000000
 %00001100
 %01101100
 %01111000
 %00011110
 %00110110
 %00110000
 %00000000
end

Also, the set tv statement in line 25 should be "set tv pal" or non-existant, since its default setting is NTSC.

Edited by atari2600land
Link to comment
Share on other sites

This bit of code can be simplified:

 if joy0right then f=f+1
 if joy0left then f=f+1
 if joy0up then f=f+1
 if joy0down then f=f+1

to this:

if SWCHA>0 then f=f+1

Also you might want to change this:

if f=40 then player1:
 %00000000
 %00001100
 %01101100
 %01111000
 %00011110
 %00110110
 %00110000
 %00000000
end
 
 if f=40 then f=0

to this:

if f=40 then f=0 
if f=0 then player1:
 %00000000
 %00001100
 %01101100
 %01111000
 %00011110
 %00110110
 %00110000
 %00000000
end

Also, the set tv statement in line 25 should be "set tv pal" or non-existant, since its default setting is NTSC.

Thanks! Most of the code was created by the program itself so that's why it was so complicated.

 

edit:

 

"if SWCHA>0 then f=f+1" causes it to animate 24/7. I only want it to animate when it's moving.

 

Edited by ioi_xd
Link to comment
Share on other sites


 if joy0right then x=x+1
 if joy0right then f=f+1
 if joy0left then x=x-1
 if joy0left then f=f+1
 if joy0up then y=y-1
 if joy0up then f=f+1
 if joy0down then y=y+1
 if joy0down then f=f+1
 goto main

When you move diagonal, there's 2 branches open up that increase the f variable by 2. For example up and left together will activate joy up and joy left branches. This cause it to miss the if = branches that update the graphics for the character.

You can probably do

 if joy0right then x=x+1
 if joy0left then x=x-1
 if joy0up then y=y-1
 if joy0down then y=y+1

 if joy0right then f=f+1:goto animationinc
 if joy0left then f=f+1:goto animationinc
 if joy0up then f=f+1:goto animationinc
 if joy0down then f=f+1:goto animationinc
 animationinc:

This way you can still move diagonal, and have the f variable increase by 1 to skip the additional branch so it doesn't take a second branch to increase the f variable again.

Link to comment
Share on other sites

Link to comment
Share on other sites

 if joy0right then f=f+1:goto animationinc
 if joy0left then f=f+1:goto animationinc
 if joy0up then f=f+1:goto animationinc
 if joy0down then f=f+1:goto animationinc
 animationinc:

That works! Thank you.

 

In case you missed it, batari Basic has its own forum:

 

atariage.com/forums/forum/65-batari-basic/

 

Just bookmarked, that will be very helpful in the future! Thank you!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...