Jump to content

Photo

Character's moving animation stops when I move diagonally.


8 replies to this topic

#1 ioi_xd OFFLINE  

ioi_xd

    Space Invader

  • 13 posts

Posted Fri Apr 13, 2018 7:24 PM



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, Sat Apr 14, 2018 1:16 PM.


#2 Kiwi OFFLINE  

Kiwi

    Stargunner

  • 1,606 posts

Posted Sat Apr 14, 2018 8:37 AM

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



#3 ioi_xd OFFLINE  

ioi_xd

    Space Invader

  • Topic Starter
  • 13 posts

Posted Sat Apr 14, 2018 1:02 PM

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, Sat Apr 14, 2018 1:16 PM.


#4 atari2600land OFFLINE  

atari2600land

    Channel F Viewer

  • 11,521 posts
  • Location:Salem, Oregon

Posted Sat Apr 14, 2018 1:41 PM

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, Sat Apr 14, 2018 1:42 PM.


#5 ioi_xd OFFLINE  

ioi_xd

    Space Invader

  • Topic Starter
  • 13 posts

Posted Sat Apr 14, 2018 3:52 PM

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, Sat Apr 14, 2018 6:22 PM.


#6 Kiwi OFFLINE  

Kiwi

    Stargunner

  • 1,606 posts

Posted Sat Apr 14, 2018 10:26 PM


 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.



#7 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,797 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Sat Apr 14, 2018 10:30 PM

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

 

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

 

 

Be sure to check out these links too:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#gettingstarted

 

randomterrain.com/atari-2600-memories-batari-basic-vbb.html#install_vbb



#8 ioi_xd OFFLINE  

ioi_xd

    Space Invader

  • Topic Starter
  • 13 posts

Posted Sat Apr 14, 2018 10:52 PM


 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!



#9 bogax OFFLINE  

bogax

    Dragonstomper

  • 782 posts

Posted Sun Apr 15, 2018 4:05 PM

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

 

That should be 

if SWCHA<240 then f=f+1





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users