ioi_xd Posted April 14, 2018 Share Posted April 14, 2018 (edited) https://www.youtube.com/watch?v=eaAhjlXgzH4I'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? aHere'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 April 14, 2018 by ioi_xd Quote Link to comment Share on other sites More sharing options...
Kiwi Posted April 14, 2018 Share Posted April 14, 2018 How is f being increase or decrease when there's no f=f+1 or f=f-1 anywhere in the code provided? Quote Link to comment Share on other sites More sharing options...
ioi_xd Posted April 14, 2018 Author Share Posted April 14, 2018 (edited) 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 April 14, 2018 by ioi_xd Quote Link to comment Share on other sites More sharing options...
+atari2600land Posted April 14, 2018 Share Posted April 14, 2018 (edited) 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 April 14, 2018 by atari2600land Quote Link to comment Share on other sites More sharing options...
ioi_xd Posted April 14, 2018 Author Share Posted April 14, 2018 (edited) 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 April 15, 2018 by ioi_xd Quote Link to comment Share on other sites More sharing options...
Kiwi Posted April 15, 2018 Share Posted April 15, 2018 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. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 15, 2018 Share Posted April 15, 2018 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 Quote Link to comment Share on other sites More sharing options...
ioi_xd Posted April 15, 2018 Author Share Posted April 15, 2018 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! Quote Link to comment Share on other sites More sharing options...
bogax Posted April 15, 2018 Share Posted April 15, 2018 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.