SuperNESFreak Posted December 30, 2010 Share Posted December 30, 2010 (edited) Hi, I'm trying to make a game called Going Dotty - where you control a titular dot as it is chased by... another dot. You must find powerups and make fake dots appear to distract your enemy. Anyway, I haven't gotten anywhere near the gameplay yet. When I try to put in my playing field: pfcolors: $02 $04 $06 $08 $0A $0C $0A $08 $06 $04 $02 end playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X.............X..X.............X X.............XXXX.............X X..............................X X.............XXXX.............X X.............X..X.............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end VbB tells me the syntax with the colours is wrong. At this point, an idea hits me: to save space and to give each round a different look, why not have the playing field change colour? My resulting code for messing around was: playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X.............X..X.............X X.............XXXX.............X X..............................X X.............XXXX.............X X.............X..X.............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end level = 1 COLUPF = level*2 COLUBK = 0 scorecolor = 14 draw_loop drawscreen goto draw_loop But then I had ANOTHER idea. Why not simply make it so that each time the level advances, COLUPF = COLUPF+2? Anyway, I'm nowhere near getting any of this. My question is how do I make variables? I want the dots not to fly around the screen at a constant pace, so I want to make playerhspeed/playervspeed variables. Is it simply a matter of doing just that or am I missing something? Sorry for jabbering, thanks in advance. EDIT: One more thing, when I try to make these variables, not only does vBb not like those, but suddenly it gets a syntax error from the drawscreen line? Edited December 30, 2010 by SuperNESFreak Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted December 30, 2010 Author Share Posted December 30, 2010 Hurray for not looking at the manual... sorry for double posting, but for some reason I can't reedit my first post. Anyway, here is my code now: playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X.............X..X.............X X.............XXXX.............X X..............................X X.............XXXX.............X X.............X..X.............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end player0: 011000 100100 %01011010 %10100101 %10100101 %01011010 100100 011000 end COLUBK = 0 COLUPF = 2 COLUP0 = 138 scorecolor = 14 a = 75 rem playerx b = 75 rem playery c = 0 rem playerhspeed <---- The syntax error comes here d = 0 rem playervspeed main a=a+c : b=b+d drawscreen player0x = a : player0y = b if joy0up then a=a-0.2 if joy0down then a=a+0.2 if joy0left then b=b-0.2 if joy0right then b=b+0.2 goto main Sorry for sounding like I want to be baby fed, but what am I doing wrong here? Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 30, 2010 Share Posted December 30, 2010 (edited) You need to put "rem" on its own line, or at least put a : between the command and the remark. (the latter doesn't work in all cases) [edit - also, you might want to post future bB questions in the bB forum instead of this one.] Edited December 30, 2010 by RevEng Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted December 30, 2010 Author Share Posted December 30, 2010 You need to put "rem" on its own line, or at least put a : between the command and the remark. (the latter doesn't work in all cases) [edit - also, you might want to post future bB questions in the bB forum instead of this one.] Whoops! Okay, I removed the rem lines just to be safe, but the program is still objecting to me using the d variable. COLUBK = 0 COLUPF = 2 COLUP0 = 138 scorecolor = 14 a = 75 b = 75 c = 0 d = 0 <--- error here main a=a+c : b=b+d Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 30, 2010 Share Posted December 30, 2010 I didn't see it before because I was browsing on my phone, but you also need to indent every single command with a space or a tab. Only labels should be directly on the left margin. Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted December 30, 2010 Author Share Posted December 30, 2010 I didn't see it before because I was browsing on my phone, but you also need to indent every single command with a space or a tab. Only labels should be directly on the left margin. HURRA- shat, it doesn't work. Now the screen just flickers, maybe the loop isn't working properly? By the way, vBb tries to unindent END commands. rem Going Dotty, SuperNESFreak score = 0 a = 25 : rem playerx b = 25 : rem playery c = 0 : rem playerhspeed d = 0 : rem playervspeed e = 100 : rem enemyx f = 100 : rem enemyy g = 0 : rem enemyhspeed h = 0 : rem enemyvspeed i = 0 : rem animations main playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X.............X..X.............X X.............XXXX.............X X..............................X X.............XXXX.............X X.............X..X.............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end if i = 0 then player0: 011000 100100 %01011010 %10100101 %10100101 %01011010 100100 011000 player1: %10000001 %01011010 100100 011000 011000 100100 %01011010 %10000001 end if i = 2 then player0: 000000 011000 100100 %01011010 %01011010 100100 011000 000000 player1: 000000 %10000001 %01100110 011000 011000 %01100110 %10000001 000000 end COLUBK = 2 COLUPF = 4 COLUP0 = 138 COLUP1 = 68 scorecolor = 14 a=a+c b=b+d i=i+1 player0x = a player0y = b if joy0up then a=a-0.2 if joy0down then a=a+0.2 if joy0left then b=b-0.2 if joy0right then b=b+0.2 drawscreen goto main Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 30, 2010 Share Posted December 30, 2010 Ah sorry, the "end" statements are the exception to the rule - they don't get indented either. Also, you were adding/subtracting 0.2 to your position variables. Adding decimals only works if you use fixed point variables. One more suggestion - use dim to give yourself variable names with meaning. Here's the fixed code, using 1 for the position changes instead of 0.2... rem Going Dotty, SuperNESFreak score = 0 a = 25 : rem playerx b = 25 : rem playery c = 0 : rem playerhspeed d = 0 : rem playervspeed e = 100 : rem enemyx f = 100 : rem enemyy g = 0 : rem enemyhspeed h = 0 : rem enemyvspeed i = 0 : rem animations main playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X.............X..X.............X X.............XXXX.............X X..............................X X.............XXXX.............X X.............X..X.............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end if i = 0 then player0: %00011000 %00100100 %01011010 %10100101 %10100101 %01011010 %00100100 %00011000 end player1: %10000001 %01011010 %00100100 %00011000 %00011000 %00100100 %01011010 %10000001 end if i = 2 then player0: %00000000 %00011000 %00100100 %01011010 %01011010 %00100100 %00011000 %00000000 end player1: %00000000 %10000001 %01100110 %00011000 %00011000 %01100110 %10000001 %00000000 end COLUBK = 2 COLUPF = 4 COLUP0 = 138 COLUP1 = 68 scorecolor = 14 a=a+c b=b+d i=i+1 player0x = b player0y = a if joy0up then a=a-1 if joy0down then a=a+1 if joy0left then b=b-1 if joy0right then b=b+1 drawscreen goto main Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted December 30, 2010 Author Share Posted December 30, 2010 (edited) Brilliant! Couple of things that are still not working: the speed variables don't work, aka the dot still moves around at a constant pace. Also, I put in a line of code so that the fire button will change the playfield when the fire button is pressed ( if joy0fire then COLUPF = COLUPF+2) and moved the original COLUPF line to the beggining, but the screen only changes colour once. Also put in some code for the animations to make them work. Looking amazing! If you could help me with these things, I'd really appreciate: 1) Fluid motion Hurrah for not looking at your own code carefully enough, fixed. Argh! Negative variables! 2) Bouncing off the walls (collision with playfield?) Thanks alot! EDIT: The fluid motion is proving to be tricky. I think the problem is with me telling the program to test for negative variables. How can I cap the v/h speeds to 3/-3? Edited December 30, 2010 by SuperNESFreak Quote Link to comment Share on other sites More sharing options...
Nukey Shay Posted December 30, 2010 Share Posted December 30, 2010 COLUPF is the system register for storing the playfield color. Reading it will not return the value of the current color being sent to the display, but the positive/negative status of paddle 0 (INPT0). The 2600 features many such registers that deal with different things depending on if they are read from or written to. If you want your screen color to be updated, you'd need to keep track of it yourself. Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 30, 2010 Share Posted December 30, 2010 Brilliant! Couple of things that are still not working: the speed variables don't work, aka the dot still moves around at a constant pace. Also, I put in a line of code so that the fire button will change the playfield when the fire button is pressed ( if joy0fire then COLUPF = COLUPF+2) and moved the original COLUPF line to the beggining, but the screen only changes colour once. COLUPF is a write-only hardware register - you can't read from it. Instead use your own "playcolor" variable, and do something like "playcolor=playcolor+2:COLUPF=playcolor" Argh! Negative variables! The 6507 uses something called two's compliment to represent negative numbers. The upshot is, negative numbers are the same thing as larger positive numbers... +3=3 +2=2 +1=1 +0=0 -1=255 -2=254 -3=253 So to test for a range between -3 and 3, you can do something like... if speed>252 || speed<4 then goto dosomething. 2) Bouncing off the walls (collision with playfield?) If you save the x and y positions before your last position changes, you can do something like the following... if collision(playfield,player0) then player0x=oldplayer0x:player0y=oldplayer0y Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted December 30, 2010 Author Share Posted December 30, 2010 (edited) Awesome. Is this two's compliments always like this, (ie. I don't have to tell the variable to be two's compliments?) For the speed things, I put in this code: if joy0up then c=c-1 if joy0down then c=c+1 if joy0left then d=d-1 if joy0right then d=d+1 if c>252 then c = 252 if c>3 then c = 3 if d>252 then d = 252 if d>3 then d = 3 No dice. Am I being repeatedly stupid here, am I just a complete newb, or both? Edited December 30, 2010 by SuperNESFreak Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 31, 2010 Share Posted December 31, 2010 (edited) Awesome. Is this two's compliments always like this, (ie. I don't have to tell the variable to be two's compliments?) Yup. Nothing to do on your part, except to keep them in mind when you're writing comparisons. [edit - answer added for your edit addition] Try this... if c>127 && c<252 then c = 252 if c>3 && c<127 then c = 3 if d>127 && d<252 then d = 252 if d>3 && d<127 then d = 3 Edited December 31, 2010 by RevEng Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted December 31, 2010 Author Share Posted December 31, 2010 Okay: this is my code for slowing down the dot. It works when going right or down, but not when going left or up, so I've got something wrong with the negatives again. This is the code: if joy0up then c=c-2 if joy0down then c=c+2 if joy0left then d=d-2 if joy0right then d=d+2 if c>127 && c<251 then c = 251 if c>3 && c<127 then c = 4 if d>127 && d<251 then d = 251 if d>3 && d<127 then d = 4 if d>0 && !joy0down then d=d-1 if d>127 && !joy0up then d=d+1 if c>0 && !joy0right then c=c-1 if c>127 && !joy0left then c=c+1 Quote Link to comment Share on other sites More sharing options...
RevEng Posted December 31, 2010 Share Posted December 31, 2010 This should fix it... if joy0up then c=c-2 if joy0down then c=c+2 if joy0left then d=d-2 if joy0right then d=d+2 if c>127 && c<251 then c = 251 if c>3 && c<127 then c = 4 if d>127 && d<251 then d = 251 if d>3 && d<127 then d = 4 rem *** the following is true if d is positive or negative (which is also >0) rem if d>0 && !joy0down then d=d-1 rem *** the fixed version... if d>0 && d<127 && !joy0down then d=d-1 if d>127 && !joy0up then d=d+1 rem *** same fix for c... rem if c>0 && !joy0right then c=c-1 if c>0 && c<127 && !joy0right then c=c-1 if c>127 && !joy0left then c=c+1 ...keep at it! You've made a fine start so far - it just takes a while to get used to the "big numbers are also negative" thing. Quote Link to comment Share on other sites More sharing options...
SuperNESFreak Posted January 1, 2011 Author Share Posted January 1, 2011 (edited) Okay. I'm away from home at the moment so I can't check this but I'll upload the code so I can get it from here later. If anyone would like to try it and see if I've made any mistakes that would be really great: rem Going Dotty, SuperNESFreak score = 0 a = 25 : rem playerx b = 25 : rem playery c = 0 : rem playerhspeed d = 0 : rem playervspeed e = 100 : rem enemyx f = 100 : rem enemyy g = 0 : rem enemyhspeed h = 0 : rem enemyvspeed i = 0 : rem animations main playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X.............X..X.............X X.............XXXX.............X X..............................X X.............XXXX.............X X.............X..X.............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end if i = 0 then player0: %00011000 %00100100 %01011010 %10100101 %10100101 %01011010 %00100100 %00011000 end if i = 0 then player1: %10000001 %01011010 %00100100 %00011000 %00011000 %00100100 %01011010 %10000001 end if i = 4 then player0: %00000000 %00011000 %00100100 %01011010 %01011010 %00100100 %00011000 %00000000 end if i = 4 then player1: %00000000 %10000001 %01100110 %00011000 %00011000 %01100110 %10000001 %00000000 end COLUBK = 0 COLUPF = 2 COLUP0 = 138 COLUP1 = 68 scorecolor = 14 a=a+c b=b+d e=e+g f=f+h i=i+1 player0x = a player0y = b player1x = e player1y = f if i=8 then i=0 if joy0up then c=c-2 if joy0down then c=c+2 if joy0left then d=d-2 if joy0right then d=d+2 if c>127 && c<251 then c = 251 if c>3 && c<127 then c = 4 if d>127 && d<251 then d = 251 if d>3 && d<127 then d = 4 rem *** the following is true if d is positive or negative (which is also >0) rem if d>0 && !joy0down then d=d-1 rem *** the fixed version... if d>0 && d<127 && !joy0down then d=d-1 if d>127 && !joy0up then d=d+1 rem *** same fix for c... rem if c>0 && !joy0right then c=c-1 if c>0 && c<127 && !joy0right then c=c-1 if c>127 && !joy0left then c=c+1 if a<e then g=g-2 if a>e then g=g+2 if b<f then h=h-2 if b>f then h=h+2 if g>127 && g<251 then g = 251 if g>3 && g<127 then g = 4 if h>127 && h<251 then h = 251 if h>3 && h<127 then h = 4 if collision(playfield,player0) then a=j:b=k:c=0-c:d=0-d if collision(playfield,player1) then e=l:f=m:g=0-g:h=0-h j = a : rem oldplayerx k = b : rem oldplayery l = e : rem oldenemyx m = f : rem oldenemyy drawscreen goto main By the way, how does the code know when checking the animation variable when to end the if? I don't think at the moment the code will make the enemy sprite animate. Fixed. Edited January 1, 2011 by SuperNESFreak 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.