Rabbit 2600 Posted October 11, 2012 Share Posted October 11, 2012 I've read some documents on batari basic but I can't learn just by reading, I need people to talk too and being able to ask questions. So I'll be asking my questions in this thread and hopefully be able to make something simple. First question: When I try too compile my program I get an error saying: Environment variable bB not set! Precompilation failed, aborted at 2012-10-11 22:09:34 How do I fix this? Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 11, 2012 Share Posted October 11, 2012 First off, have you followed through on this video? Got VisualbB all up and in there? http://www.atariage.com/forums/topic/123849-visual-bb-1-0-a-new-ide-for-batari-basic/ You may want to move this thread over to the batari Basic section too. I think this section is mostly assembly. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 11, 2012 Author Share Posted October 11, 2012 (edited) Ah, wonderful! I missed that one! Now things are running along very well! I can now compile, but when I test it out I get an error saying "could not locate default.bas.bin and could not recompile. Please make sure it was compiled correctly." How do I go about this one? And how would I move this thread?^^' Edited October 11, 2012 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 I managed to fix all the errors. Yay me! However, I have a problem with placing the character sprites on screen. I get a syntax error at this part of the code: player0x=50:player0y=50 My whole code: rem ************************************************************************ rem generated 2012-10-12 01:09:25 by Visualdb Project Wizard Version 1.0.0.3 rem ************************************************************************ playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end COLUBK = $00 COLUPF = 38 end player0x=50:player0y=50 player0: %00100100 %00100100 %00011000 %01011010 %00111100 %00000000 %00011000 %00011000 end player1: %00100100 %00100100 %00011000 %10111101 %11111111 %00000000 %00011000 %00011000 end draw_loop drawscreen goto draw_loop Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 12, 2012 Share Posted October 12, 2012 It looks like the forum removed any spacing you had at the beginning of each line, or maybe it was missing in the first place. Try adding a space to the beginning of each line, except for the "end" and "draw_loop" lines. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 That fixed it, thanks! Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 (edited) Okay, I'm experimenting with player movement and it works great, however I can't get the playfield to show, what am I doing wrong here? rem ************************************************************************ rem generated 2012-10-12 01:09:25 by Visualdb Project Wizard Version 1.0.0.3 rem ************************************************************************ x=50 y=50 main playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end COLUBK = $F4 COLUPF = 38 end player0: %00100100 %00100100 %00011000 %01011010 %00111100 %00000000 %00011000 %00011000 end player1: %00100100 %00100100 %00011000 %10111101 %11111111 %00000000 %00011000 %00011000 end rem Put the player on the screen at X position 50. Valid Range is 1 to 159 player0x=x rem Put the player on the screen at Y position 50. Valid Range is 1 to ~90 player0y=y rem this command instructs the program to write data to the TV screen. drawscreen rem Make the guy move if joy0right then x=x+1 if joy0left then x=x-1 if joy0up then y=y-1 if joy0down then y=y+1 goto main draw_loop drawscreen goto draw_loop Nevermind fixed the problem, was a color issue. =) Edited October 12, 2012 by Rabbit 2600 Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 How do I go about making an enemy that follows the player around? Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 12, 2012 Share Posted October 12, 2012 (edited) what about the good 'ol If the player coordinate is horizontally greater than the enemy's increase the enemies horizontal coordinate otherwise decrease it. if player0x > player1x then player1x = player1x + 1 else player1x = player1x - 1 If the player coordinate is vertically greater than the enemy's increase the enemies vertical coordinate otherwise decrease it. if player0y > player1y then player1y = player1y + 1 else player1y = player1y - 1 Edited October 12, 2012 by theloon Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 Hm, I added the lines but nothing happens? Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 12, 2012 Share Posted October 12, 2012 (edited) Hm, I added the lines but nothing happens? Sorry, didn't mean to make it cut-and-paste into your code. Just trying to explain the logic behind a simple "heat-seeking" enemy AI. I'd check out the examples posted here: http://www.atariage....r-bb-beginners/ Here is an Enemy AI example: http://www.atariage....ai#entry2409272 This dude made a simple car racing demo with enemy AI http://www.atariage.com/forums/topic/148839-rad-racer-2600/#entry1815226 Edited October 12, 2012 by theloon Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 Haha, okay. Thank you I'll check the links out =) Quote Link to comment Share on other sites More sharing options...
Impaler_26 Posted October 12, 2012 Share Posted October 12, 2012 Also have a look at the sample.bas which is included with batariBasic, the enemy there follows the player... Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 Okay, I learned a lot from them and managed too fiddle up a rudimentary a.i. Now I have 2 more questions: If I want too make more then 1 enemy appear with the same sprite what do I put in? And, how do I make them fire at the player? Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 12, 2012 Share Posted October 12, 2012 For firing, check out the bB example thread that theloon directed you to. For multiple enemies you either need to flicker (change the player position and appearance every drawscreen) or use another display element, like a missile or ball, or if you're fine with them being side-by-side you can set the NUSIZ# register. (Or use an alternate kernel.) Most of these can be researched on RT's bB page. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 I have checked them but I don't know how to apply the coding that allows the player to fire to the enemy =/ Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 12, 2012 Share Posted October 12, 2012 (edited) basically, you are discovering the amazing limitations of the Atari 2600. You get 2 sprites, 2 missiles and one ball. Like RevEng says, your choices are: * Timeshare your second sprite so that every other frame the virtual enemy gets the shared sprite. * You may double or triple the sprite image to make it look like more than one of the same kind of enemy. * Use the multi-sprite kernel to get more sprites. This has some serious limitations/complications. I have checked them but I don't know how to apply the coding that allows the player to fire to the enemy =/ Did you look at Fire A Missile? http://www.atariage.com/forums/index.php?app=core&module=attach§ion=attach&attach_id=79925 Edited October 12, 2012 by theloon Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 Yeah, I looked at Fire A Missile. Guess I'll figure things out eventually. Thanks for all the help guys, you are getting me through some tough times =) Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 Ehem, an urgent question, I added a title screen to my game, but now I can't get the enemy sprite too appear anymore, how come? =/ rem ---- Sample Program 12 ---- rem This sample program adds a simple titlescreen to sample program 2. rem This program draws a yellow sprite on a black background, and rem adds a simple playfield to the background. set romsize 4k titlescreen rem set the playfield color to bright yellow (28) COLUPF=28 rem the playfield command draws the X's on the screen. Must use capital X, must be 32x11. end playfield: ................................ ....XXX...XXX...XXX..XX...XX.... ....X..X.X...X.X...X.X.X.X.X.... ....X..X.X...X.X...X.X..X..X.... ....XXX...XXX...XXX..X.....X.... ................................ ................................ ................................ ................................ ................................ ................................ end drawscreen rem if you press fire on the joystick, you'll leave the title screen and start the main program below if joy0fire then goto start rem if the joystick button is not pressed, just loop back to the titlescreen again goto titlescreen start playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............................X X............XXXXXX............X X............XXXXXX............X X............XXXXXX............X X..............................X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end end rem COLUP0=<xx> sets the color of the player 0 sprite. Valid range is 0-254 COLUP0=194 rem You need to set a color for the playfield COLUPF=88 rem Change the background color with COLUBK COLUBK=02 rem Here is where you define the shape of the player sprite. It's limited to rem 8 pixels wide, but you can make it as tall/long as you want. rem the 'player0' must be indented, the 'end' must NOT be indented. player0: %00011100 %00011000 %00011000 %00100000 %01011010 %01111100 %00100100 %00010000 %00011000 %00111100 %00011000 end rem This makes the player Move x=50 y=50 main player0x=x player0y=y drawscreen if joy0right then x=x+1 if joy0left then x=x-1 if joy0up then y=y-1 if joy0down then y=y+1 goto main rem makes the player position x 50 player0x=50 rem Put the player on the screen at Y position 50. Valid Range is 1 to ~90 player0y=50 enemy player1: %00100100 %00100100 %00011000 %00011000 %00111100 %01000010 %00011000 %00011000 end rem Put the enemy on the screen at x and y position 80. Valid Range is 1 to 159 player1x=30 player1y=30 rem this command instructs the program to write data to the TV screen. drawscreen rem you have to have a game loop, so tell the program to jump back to the beginning. goto main Quote Link to comment Share on other sites More sharing options...
RevEng Posted October 12, 2012 Share Posted October 12, 2012 It doesn't show up because your program never actually across the player1: definition, due to the "goto main" right under the if...then joystick checks. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 12, 2012 Author Share Posted October 12, 2012 Ah, okay, that cleared that up! But now I get a ghost image of the player instead, haha. It sure isn't easy making games on the atari. Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 13, 2012 Author Share Posted October 13, 2012 Everything is finaly coming together, the enemy is showing, the player dosn't get a ghost image anymore and I'm starting to get somewhere with the shooting, finaly =) Now, collision detection is something I found really hard. I've checked the "move sprite with playfield boundaries, and I can't seem to adapt the code to my game. It's a shaky process, the first few times I tried it I got reseted too the title screen, but now I changed things around yet again and this time nothing happens at all when the player collides with the playfield, what am I doing wrong this time? rem ---- Sample Program 12 ---- rem This sample program adds a simple titlescreen to sample program 2. rem This program draws a yellow sprite on a black background, and rem adds a simple playfield to the background. set smartbranching on set romsize 4k titlescreen rem set the playfield color to bright yellow (28) COLUPF=64 rem the playfield command draws the X's on the screen. Must use capital X, must be 32x11. end playfield: ................................ ....XXX...XXX...XXX..XX...XX.... ....X..X.X...X.X...X.X.X.X.X.... ....X..X.X...X.X...X.X..X..X.... ....XXX...XXX...XXX..X.....X.... ................................ ................................ ................................ ................................ ................................ ................................ end drawscreen rem if you press fire on the joystick, you'll leave the title screen and start the main program below if joy0fire then goto start rem if the joystick button is not pressed, just loop back to the titlescreen again goto titlescreen start playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............................X X............XXXXXX............X X............XXXXXX............X X............XX..XX............X X..............................X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end rem COLUP0=<xx> sets the color of the player 0 sprite. Valid range is 0-254 COLUP0=194 rem You need to set a color for the playfield COLUPF=64 rem Change the background color with COLUBK COLUBK=6 rem Here is where you define the shape of the player sprite. It's limited to rem 8 pixels wide, but you can make it as tall/long as you want. rem the 'player0' must be indented, the 'end' must NOT be indented. dim p0_x = b dim p0_y = c player0: %00011100 %00011000 %00011000 %00100000 %01011010 %01111100 %00100100 %00010000 %00011000 %00111100 %00011000 end rem This makes the player Move x=50 y=50 main player0x=x player0y=y drawscreen p0_x = 0 if joy0right then x=x+1 if joy0left then x=x-1 player0x = player0x + p0_x if joy0up then y=y-1 if joy0down then y=y+1 player0y = player0y + p0_y rem makes the player position x 50 player0x=50 rem Put the player on the screen at Y position 50. Valid Range is 1 to ~90 player0y=50 enemy player1: %00100100 %00100100 %00011000 %00011000 %00111100 %01000010 %00011000 %00011000 end rem Put the enemy on the screen at x and y position 80. Valid Range is 1 to 159 player1x=30 player1y=30 goto main rem this command instructs the program to write data to the TV screen. drawscreen if collision(player0,playfield) then gosub knock_player_back knock_player_back player0x = player0x - p0_x player0y = player0y - p0_y goto main Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 13, 2012 Share Posted October 13, 2012 (edited) Remember that drawscreen is actually a command. drawscreen tells the bB kernel to draw all the stuff on the screen. You had the right idea though: make a sub-routine that handles what must be handled during drawing the screen. See, certain things reset when you draw the screen. For instance, REFP0 (whether to flip horizontally the first sprite) resets to 0 after each screen refresh. So, if you want to keep the first sprite flipped you must always set it before doing a drawscreen command. Here is my draw event for one of my games in progress: draw_event COLUP0 = objectcolor drawscreen return In this case I have a variable called objectcolor that stores the color for player0 (the first sprite). I make sure COLUP0 is set to objectcolor before calling the drawscreen command. In order to not confuse myself I name the code label draw_event. Edited October 13, 2012 by theloon Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 13, 2012 Author Share Posted October 13, 2012 Neat, thanks for the tip, it was very helpful! Quote Link to comment Share on other sites More sharing options...
Rabbit 2600 Posted October 13, 2012 Author Share Posted October 13, 2012 I'm still unsure where too place certain code bits, like this one: if collision(player0,playfield) then gosub knock_player_back goto main knock_player_back player0x = player0x - p0_x player0y = player0y - p0_y I've tried placing it everywhere I deem logical, but I can't get it too work =/ 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.