Jump to content
IGNORED

My questions about my first program


Recommended Posts

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?

Link to comment
Share on other sites

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 by Rabbit 2600
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by Rabbit 2600
Link to comment
Share on other sites

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 by theloon
Link to comment
Share on other sites

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 by theloon
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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&section=attach&attach_id=79925

Edited by theloon
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by theloon
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...