Matth89812 Posted February 13, 2015 Share Posted February 13, 2015 How do I create some kind of code that when the game starts, the title screen will appear, and when the joystick fire is hit it starts the game. How can I do this? Any suggestions. Here is my code right here: playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX .X.X.X.X.X.X.X.X.X.X.X.X.X.X.X.X ................................ ................................ ................................ ................................ ................................ ................................ ................................ .X.X.X.X.X.X.XX.X.X.X.X.X.X.X.X. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end COLUBK = $0E COLUPF = 000 player0x = 50 : player0y = 50 player1x = 20: player1y = 20 missile0height = 4 : missile0y = 255 NUSIZ0 = 16 sprites player0: %00111100 %11111111 %11111111 %11111111 %11111111 %11111111 %11111111 %00111100 end player1: %11111111 %10000001 %10000001 %10000001 %10000001 %10000001 %10000001 %11111111 end if missile0y > 240 then goto skip missile0y = missile0y - 2 : goto draw_loop skip if joy0fire then missile0y = player0y - 2 : missile0x = player0x + 4 draw_loop drawscreen if player1y < player0y then player1y = player1y + 1 if player1y > player0y then player1y = player1y - 1 if player1x < player0x then player1x = player1x +1 if player1x > player0x then player1x = player1x - 1 player1x = player1x : player1y = player1y if joy0up then player0y = player0y - 1 : goto jump if joy0down then player0y = player0y + 1 : goto jump if joy0left then player0x = player0x - 1 : goto jump if joy0right then player0x = player0x + 1 : goto jump if collision(missile0, player1) then score = score + 1 : player1x = rand/2 : player1y = 0 : missile0y = 255 if collision(player0 , player1) then score = score - 1 : player1x = rand/2 : player1y = 0 : missile0y = 255 jump goto sprites goto draw_loop And also I keep getting this error when I ever try to compile it after I save it: --- Unresolved Symbol List pfwidth 0000 ???? (R ) 2514 bytes of ROM space left Fatal assembly error: Source is not resolvable. Errors were encountered during assembly. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 14, 2015 Share Posted February 14, 2015 If you attach your .bas file, we'll be able to see your program the way it really is without it getting mangled by the forum software. How do I create some kind of code that when the game starts, the title screen will appear, and when the joystick fire is hit it starts the game. How can I do this? Any suggestions. Check out this example program:randomterrain.com/atari-2600-memories-batari-basic-commands.html#sprite_missile_bankswitching_example Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 14, 2015 Author Share Posted February 14, 2015 Here is what I have. default.bas Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 14, 2015 Share Posted February 14, 2015 You might want to read this section of the bB page: randomterrain.com/atari-2600-memories-batari-basic-commands.html#parts_of_a_program You might also want to look at this: randomterrain.com/atari-2600-memories-batari-basic-commands.html#bq_what_is_an_alias You were using an alias without DIMing it first and trying to go to a label that didn't exist. I fixed it up enough to get it working, but I didn't fix everything that's wrong with the code: matth89812_2015y_02m_14d_0827t.bas 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted February 14, 2015 Share Posted February 14, 2015 This bit is why dingbats think goto's are so dangerous It's needlessly complicated. __Title_Screen_Loop drawscreen if !switchreset && !joy0fire then _Bit0_Debounce_Reset{0} = 0 : goto __Skip_Title_Reset_Fire if _Bit0_Debounce_Reset{0} then goto __Skip_Title_Reset_Fire goto ____Main_Loop_Setup bank2 __Skip_Title_Reset_Fire goto __Title_Screen_Loop rem we're going to loop in the title screen untill rem the first time switchreset or joy0fire is pressed rem we will keep a flag that indicates if switchreset or rem joyfire was pressed last time throught the loop rem so we can decide if this is the first time switchreset rem or joy0fire has been pressed rem the flag will be true if either switchreset or joy0fire rem was pressed last time through the loop rem if the flag is true we loop back, set the flag and rem draw the title screen rem if the flag is not true we test if either of switchreset rem or joy0fire is pressed this time. rem if switchreset and joy0fire are both not pressed we loop rem back, otherwise we fall through and get on with it __Title_Screen_Loop if switchreset || joy0fire then debounce_flag{0} = 1 else debounce_flag{0} = 0 drawscreen if debounce_flag{0} then __Title_Screen_Loop if !switchreset && !joy0fire then __Title_Screen_Loop __Main_Loop_Setup Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 14, 2015 Share Posted February 14, 2015 This bit is why dingbats think goto's are so dangerous It's needlessly complicated. I learned that trick from batari: randomterrain.com/atari-2600-memories-batari-basic-commands.html#endif You can put as much code as you want after the if-then line instead of using gosub. In your example, there are 3 if-thens running every frame when the player isn't pressing reset or fire, but only one if-then runs each frame in my version when the player isn't pressing reset or fire. Besides that, without running your code, it looks like your version screws up the whole thing. If a player presses reset during the game, there is nothing in your version from keeping the program from skipping past the title screen and jumping right to the game if reset is held down too long. The whole purpose of that bit is to keep presses from one part of a game from contaminating another part. Also, I had all kinds of mysterious problems when using smartbranching with a very long program. Switching to then goto fixed all of the weird problems, so I dropped smartbranching. I use then goto instead for any program I'm working on so I won't have to go back and add a bunch of gotos if the program becomes larger. Here is an example from the main loop of a program: _ rem **************************************************************** rem * rem * Reset Switch rem * rem * Any Atari 2600 program should restart when the reset rem * switch is pressed. It is part of the usual standards rem * and procedures. rem * rem ``````````````````````````````````````````````````````````````` rem ` If the reset switch is not pressed, turn off reset rem ` restrainer bit and skip this section. rem ` if !switchreset then _Bit0_Reset_Restrainer{0} = 0 : goto __Skip_Main_Reset rem ```````````````````````````````````````````````````````````````` rem ` If reset switch has not been released since starting the rem ` game, skip this section. rem ` if _Bit0_Reset_Restrainer{0} then goto __Skip_Main_Reset rem ```````````````````````````````````````````````````````````````` rem ` Clear the game over bit so the title screen will appear. rem ` _Bit2_Game_Over{2} = 0 rem ```````````````````````````````````````````````````````````````` rem ` Reset pressed appropriately. Restart the program. rem ` goto __Start_Restart __Skip_Main_Reset _ How would you rewrite that? Quote Link to comment Share on other sites More sharing options...
bogax Posted February 14, 2015 Share Posted February 14, 2015 (edited) Sorry, I guess I wasn't clear. It's not the use of goto's that I object to Nor do I object to reversing the condition and skipping forward It's jumping forward when you should jump back especially jumping forward and then immediately jumping back and extra especially when you're jumping forward instead of looping back only because you jumped forward just so you could jump back. I only put the extra if-then-to-set-the-debounce_flag in because I thought it made it clearer what was going on I'd use a gosub to get the junk out of the way because I think it makes the code easier to read If there was a reason not to use a gosub I'd put the code at the beginning of the loop and, if there's reason to, jump into the middle of the loop to enter the loop. As for that bit of code, hard to know how I'd rewrite it without context but something like this probably if !switchreset then _Bit0_Reset_Restrainer{0} = 0 : goto __Skip_Main_Reset if !_Bit0_Reset_Restrainer{0} then : _Bit2_Game_Over{2} = 0 : goto __Start_Restart __Skip_Main_Reset except I might reverse the sense of _Bit0_Reset_Restrainer{0} instead of using the ! and I wouldn't use those verbose names or leading underscores edit: oops missed a line Edited February 14, 2015 by bogax Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 15, 2015 Share Posted February 15, 2015 It's jumping forward when you should jump back especially jumping forward and then immediately jumping back and extra especially when you're jumping forward instead of looping back only because you jumped forward just so you could jump back. The problem I had was not knowing if a person might put code after the select/joystick button check. If we can guarantee that it will be the last code subsection in the loop, most gotos in that subsection could jump back to the beginning of the loop instead of jumping forward. As for that bit of code, hard to know how I'd rewrite it without context but something like this probably if !switchreset then _Bit0_Reset_Restrainer{0} = 0 : goto __Skip_Main_Reset if _Bit0_Reset_Restrainer{0} then _Bit2_Game_Over{2} = 0 : goto __Start_Restart __Skip_Main_Reset That wouldn't work if the game is started using the reset switch. The point of using _Bit0_Reset_Restrainer{0} is more than just telling the program what to do if the player presses reset during the game. Using your code, if the player held down and didn't let go of the reset switch at the title screen, the game would keep resetting over and over. But with my code, the player could hold down the reset switch all day long from the title screen and the game would only start once and it wouldn't keep resetting. My code restrains the reset switch. and I wouldn't use those verbose names or leading underscores I have mistakenly used keywords as variable names, so starting each variable name with an underscore fixes it so my variable names will always be safe to use. I also used simpler variable aliases years ago and I ended up repeatedly scrolling up to the explanatory REMs to figure out what a variable did or what bit it used. For an alias like _Bit0_Reset_Restrainer, the _Bit0 part tells me what bit it uses so I don't have to keep looking it up and the _Reset_Restrainer part tells me exactly what it does or what it is for. Everything I need to know is right there in front of me. I'm sure people without bad memories and learning disabilities don't need the extra help, but it saves me a lot of time and eliminates unnecessary frustration. Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 15, 2015 Author Share Posted February 15, 2015 Ok. But what about the error I keep getting when I try to compile it? How do I fix it? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 15, 2015 Share Posted February 15, 2015 Ok. But what about the error I keep getting when I try to compile it? How do I fix it? Did you download the version I posted and try to compile that? If you did and it didn't compile, are you using the latest version of bB: randomterrain.com/atari-2600-memories-batari-basic-commands.html#gettingstarted 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted February 15, 2015 Share Posted February 15, 2015 I have mistakenly used keywords as variable names, Me to And it's worse than that. At least for some stuff if you use a keyword as the beggining of a variable name bB will get confused. so starting each variable name with an underscore fixes it so my variable names will always be safe to use. But that's not the fix I'd choose. I also used simpler variable aliases years ago and I ended up repeatedly scrolling up to the explanatory REMs to figure out what a variable did or what bit it used. For an alias like _Bit0_Reset_Restrainer, the _Bit0 part tells me what bit it uses so I don't have to keep looking it up and the _Reset_Restrainer part tells me exactly what it does or what it is for. Everything I need to know is right there in front of me. I'm sure people without bad memories and learning disabilities don't need the extra help, but it saves me a lot of time and eliminates unnecessary frustration. That statement was not meant as criticism only to note that I do these things differently. (if it were serious criticism I wouldn't have stuck my tongue out ) This is an ages old debate. And it's not just people with bad memories and learning disabilities that prefer your "style" (style in quotes because I think, as in your case, it's something more than just style) I find it very wearying and distracting if a variable name is a sentence I have to parse. That wouldn't work if the game is started using the reset switch. The point of using _Bit0_Reset_Restrainer{0} is more than just telling the program what to do if the player presses reset during the game. Using your code, if the player held down and didn't let go of the reset switch at the title screen, the game would keep resetting over and over. But with my code, the player could hold down the reset switch all day long from the title screen and the game would only start once and it wouldn't keep resetting. My code restrains the reset switch. That should be !_Bit0_Reset_Restrainer{0} Since I goofed something else and edited I may have inadverntently fixed that too. Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 15, 2015 Author Share Posted February 15, 2015 Thanks! Now everything works now! Now all I have to do is to work on the sound effects, the game over screen and the lives. I might need help with that. Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 15, 2015 Author Share Posted February 15, 2015 Anything on how can I add the sound effects, lives and the game over screen? Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 15, 2015 Share Posted February 15, 2015 Anything on how can I add the sound effects, lives and the game over screen? Have you check out these sections of the bB page yet? randomterrain.com/atari-2600-memories-batari-basic-commands.html#sound_examples_no_data randomterrain.com/atari-2600-memories-batari-basic-commands.html#sound_example_no_bank randomterrain.com/atari-2600-memories-batari-basic-commands.html#pfscorebars randomterrain.com/atari-2600-memories-batari-basic-commands.html#sprite_missile_bankswitching_example Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 16, 2015 Author Share Posted February 16, 2015 Interesting. Can you try adding it for me? I don't know to much about coding. When the missile hits the enemy it gets a point sound. But if the enemy hits the player 3 times, it plays the dead sound and then the game over screen appears. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted February 16, 2015 Share Posted February 16, 2015 Interesting. Can you try adding it for me? I don't know to much about coding. This is a little like: Gimme Da Codez or I Can Haz Codez? People in this forum will usually go out of their way to help, but they're not going to make a game for you. Before batari Basic existed, people had to do it the hard way using assembly language. Until somebody produces a Click & Create GameMaker style program for making Atari 2600 games, batari Basic is about as easy as it can get, especially with all of the example programs that are available. If you know very little about BASIC programming, you might want to check out these links before continuing with batari Basic: atariarchives.org/basic/ msdn.microsoft.com/en-us/library/ms172579%28v=vs.90%29.aspx Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 16, 2015 Author Share Posted February 16, 2015 Sorry. I just want some help but your right. Quote Link to comment Share on other sites More sharing options...
Matth89812 Posted February 16, 2015 Author Share Posted February 16, 2015 Also I am trying to add the health when the enemy hits the player, the health decreases but there is an error. Herre is what I have: rem sets up life bar pfscore2 = 255 pfscore2 = %11111111 pfscore2 = pfscore4/4 : rem * If using a lives bar on right side. if collision(player0, player1) then pfscore2 = pfscore2 - 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.