Jump to content
Atarius Maximus

Code Snippets & Samples for bB Beginners

Recommended Posts

I've had a few requests via private mail to help people out who are trying to learn bB, along with requests for code examples. I thought I'd post some very simple, short programs that demonstrate how to do some specific things in bB. I always learn best by looking at sample code... hopefully these will help someone out. I'd be happy to create additional examples if someone wants one.

 

Here are some links to some good tutorials from other members:

 

From CurtisP: Programming Tutorial

From SeaGtGruff: Tutorial Session 1 | Tutorial Session 2 | Tutorial Session 3

 

Other downloads & links you'll want:

 

Get the latest version of bB here.

Get the latest version of Visual bB here.

Get the latest verison of Stella here.

Read the latest documentation here.

 

Steve

1_DrawSprite.bas

1_DrawSprite.bin

2_AddPlayfield.bas

2_AddPlayfield.bin

3_MoveASprite.bas

3_MoveAsprite.bin

4_FireAMissile.bas

4_FireAmissile.bin

5_AnimateASprite.bas

5_AnimateASprite.bin

6_AnimateAplayfield.bas

6_AnimateAplayfield.bin

7_3DMovingSprite.bas

7_3DMovingSprite.bin

9_DetectCollisions.bas

9_Detectcollisions.bin

8_FlashColors.bas

8_FlashColors.bin

10_MoveAnAnimatedSprite.bas

10_MoveAnAnimatedSprite.bas.bin

11_AdventureLight.bas

11_AdventureLight.bin

12_SimpleTitlescreenDemo.bas

12_SimpleTitlescreenDemo.bin

13_BankswitchingDemo.bas

13_BankswitchingDemo.bin

14_MoveAnimateAndFire.bas

14_MoveAnimateAndFire.bin

15_MoveSpritewithPlayfieldBoundaries.bas

15_MoveSpritewithPlayfieldBoundaries.bin

16_MoveSpritewithEnemySpriteFollowing.bas

16_MoveSpritewithEnemySpriteFollowing.bin

Edited by Atarius Maximus
  • Like 9

Share this post


Link to post
Share on other sites

Great idea! I will pin this topic. If anyone knows of other good examples scattered around the forum, maybe they can be mirrored here. Or if anyone has requests, post 'em up.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for this lot of binaries and source codes!

 

Finally I made my title screen working :D

Hope that I can get something done in a few weeks :)

  • Like 1

Share this post


Link to post
Share on other sites
Hi there,..

 

i have a problem with connecting the moving sprite sample with the animated sprite sample,....

 

can anyone post the code, it would help so much!

 

thnx

Do you mean how to move an animated sprite?

 

Michael

  • Like 2

Share this post


Link to post
Share on other sites

HI,.. sorry for my bad english.

 

yes, i mean how to move a animated Sprite.

 

 

and i also want to know how to programm diferent "layers", like a intro,... main part..., outro... credits....

 

oh, so many other questions, i will post them little by little if i cant find any conclution.

 

 

thanx!!

  • Like 1

Share this post


Link to post
Share on other sites
HI,.. sorry for my bad english.

 

yes, i mean how to move a animated Sprite.

Your English is fine. I was 98% certain that was what you meant, but my real reason for asking was because I wasn't at home when I was reading the posts, and that meant your question wouldn't show up under "View New Posts" when I did get home later. I wanted to post *something* in the thread so it would show up under "My Posts" when I got home, to remind myself that I intended to reply to you. I could have just posted something like "I'll check on it later," but instead I decided to ask for verification of what you wanted, just to be certain. So don't worry about your English! :)

 

Michael

  • Like 1

Share this post


Link to post
Share on other sites

Okay, here's a sample that combines "3_MoveASprite.bas" with "5_AnimateASprite.bas." I think perhaps the reason you were having trouble combining them is because they both use variable y, but they use y for two different things. :)

 

There are two ways this new sample can be improved-- (1) animate the sprite only when it's being moved around with the joystick; and (2) have the sprite face in the opposite direction if it's being moved right-to-left. But those can be for later.

 

Michael

10_MoveAnAnimatedSprite.bas

10_MoveAnAnimatedSprite.bas.bin

  • Like 1

Share this post


Link to post
Share on other sites

Thanx, that helps a lot!

 

what i still did not understand is your reply of the other question with going to other Levels (goto different Playfields if something happenes).

 

anyway... in next time i´ll try to work with combinations of the samples in this tread. Its my problem that i do not exactly know how to use

lot of different actions in on programm.

 

i look forward to create new samples with your help, that would be very helpfull for the other new programmers here.

for me it´s the best way to learn, looking at other peoples programs and putting out special events i like to use.

 

thanx so far,..

 

Tom

  • Like 1

Share this post


Link to post
Share on other sites
Okay, here's a sample that combines "3_MoveASprite.bas" with "5_AnimateASprite.bas." I think perhaps the reason you were having trouble combining them is because they both use variable y, but they use y for two different things. :)

 

There are two ways this new sample can be improved-- (1) animate the sprite only when it's being moved around with the joystick; and (2) have the sprite face in the opposite direction if it's being moved right-to-left. But those can be for later.

 

Michael

 

I've updated the first post with your additions, Michael. I'll keep doing that when new samples are posted.

 

Cheers! :)

 

Steve

  • Like 1

Share this post


Link to post
Share on other sites
I've updated the first post with your additions, Michael. I'll keep doing that when new samples are posted.

 

Cheers! :)

 

Steve

 

 

fine,.. so i can continue with my patchwork programming,.. that helps a lot at the begin,..

 

 

thanx tom

Edited by freehabitat
  • Like 1

Share this post


Link to post
Share on other sites

I looked at your animated playfield code. You have this:

 

 x=10 : rem Counter number - when to switch to frame 2
y=20 : rem Counter number - when to switch to frame 3
z=30 : rem Counter number - when to switch to frame 4


main

COLUPF=28
COLUBK=0

b=b+1

if b>30 then b=0

if b=x then goto frame1
if b=y then goto frame2
if b=z then goto frame3

ETC, ETC

 

Wouldn't it be better to just to this?

 

main

COLUPF=28
COLUBK=0

b=b+1

if b>30 then b=0

if b=10 then goto frame1
if b=20 then goto frame2
if b=30 then goto frame3

ETC, ETC

 

I don't know if it saves you any ROM, but this way you're not wasting variables.

  • Like 1

Share this post


Link to post
Share on other sites
I looked at your animated playfield code. You have this:

The only reason I can think of for using variables is to make the code more reusable within the program-- for example, if you want to speed up or slow down the animation rate by changing the values in the variables. Otherwise, constants help save RAM (which-- on the Atari 2600-- is more important than saving ROM, since RAM is more precious than ROM).

 

Michael

  • Like 1

Share this post


Link to post
Share on other sites
I looked at your animated playfield code. You have this:

The only reason I can think of for using variables is to make the code more reusable within the program-- for example, if you want to speed up or slow down the animation rate by changing the values in the variables. Otherwise, constants help save RAM (which-- on the Atari 2600-- is more important than saving ROM, since RAM is more precious than ROM).

 

Michael

 

That is exactly why I did it - to allow for changing the animation rate. I suppose it wasn't necessary for the sample program, yuppicide's revision would work fine too.

 

Steve

  • Like 1

Share this post


Link to post
Share on other sites

Didn't think of that. Thanks. Good idea.

 

That is exactly why I did it - to allow for changing the animation rate. I suppose it wasn't necessary for the sample program, yuppicide's revision would work fine too.

 

Steve

  • Like 1

Share this post


Link to post
Share on other sites

One thing we should do with the first post is make everything the same. Am I nitpicking? Unfortunately yes.

 

Everything code snippet has two files with it. First one being .bas, and second being .bin. Except number 8. It's backwards. First is .bin. Not a big deal, but I couldn't find 8 to load in bB and I swore I downloaded it lol.

 

Second, number 10 is named .bas.bin when every other one is .bin.

 

Anyway, nice tutorials. I enjoyed them. I think there should be one for how to insert simple background music and one how to insert a sound effect. I'll be able to manage just fine I am sure, but still would be nice to read a tut. Thanks again for the tutorials!

  • Like 1

Share this post


Link to post
Share on other sites

I added another sample program to the first post. It's a sample program that shows how to make the 'light' sprite around your character to move around an invisible maze, just like the mazes in the original Adventure game.

 

Thanks,

 

Steve

  • Like 1

Share this post


Link to post
Share on other sites

One more sample was added to the first post, by request: 12-SimpleTitlescreenDemo.bas. It shows how to make a simple titlescreen. From the titlescreen, press fire to start the game.

 

Steve

  • Like 2

Share this post


Link to post
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.

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...