Jump to content

Photo

Code Snippets & Samples for bB Beginners


48 replies to this topic

#1 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • 1,552 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Mon Jun 25, 2007 1:43 PM

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

Attached Files


Edited by Atarius Maximus, Sat Jun 14, 2014 8:38 AM.


#2 Impaler_26 OFFLINE  

Impaler_26

    Cookie Meister

  • 2,580 posts
  • Braindead
  • Location:Hueco Mundo

Posted Mon Jun 25, 2007 2:03 PM

Thanks for those nice examples!!!

They'll sure be useful for me when i get off my lazy butt and continue work on my game one day :)

#3 batari OFFLINE  

batari

    )66]U('=I;B$*

  • 6,501 posts
  • begin 644 contest

Posted Mon Jun 25, 2007 2:04 PM

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.

#4 Nognir OFFLINE  

Nognir

    Dragonstomper

  • 750 posts
  • Location:Regenstauf (near Regensburg) Bavaria, Germany

Posted Wed Aug 8, 2007 1:02 PM

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 :)

#5 freehabitat OFFLINE  

freehabitat

    Chopper Commander

  • 113 posts
  • Location:Vienna, AUSTRIA

Posted Fri Nov 2, 2007 3:25 PM

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

#6 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • 5,455 posts
  • Location:Georgia, USA

Posted Fri Nov 2, 2007 5:39 PM

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

#7 freehabitat OFFLINE  

freehabitat

    Chopper Commander

  • 113 posts
  • Location:Vienna, AUSTRIA

Posted Fri Nov 2, 2007 5:42 PM

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

#8 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • 5,455 posts
  • Location:Georgia, USA

Posted Fri Nov 2, 2007 10:31 PM

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

#9 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • 5,455 posts
  • Location:Georgia, USA

Posted Fri Nov 2, 2007 11:52 PM

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

Attached Files



#10 freehabitat OFFLINE  

freehabitat

    Chopper Commander

  • 113 posts
  • Location:Vienna, AUSTRIA

Posted Sat Nov 3, 2007 7:32 AM

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

#11 Dan Iacovelli ONLINE  

Dan Iacovelli

    Quadrunner

  • 5,471 posts
  • Location:westchester,IL

Posted Mon Nov 5, 2007 3:12 PM

I recongize the playfield sample,I asked the question for that for my game I'm working on.
Also the animate sprite sample helped me alot with my game.

#12 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,552 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Mon Nov 5, 2007 4:25 PM

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

#13 freehabitat OFFLINE  

freehabitat

    Chopper Commander

  • 113 posts
  • Location:Vienna, AUSTRIA

Posted Mon Nov 5, 2007 5:34 PM

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, Mon Nov 5, 2007 5:42 PM.


#14 Fort Apocalypse OFFLINE  

Fort Apocalypse

    Stargunner

  • 1,593 posts

Posted Thu Dec 27, 2007 6:15 AM

In addition to examples, there is a great reference here that batari wrote and Random Terrain maintains:
http://www.randomter...c-commands.html

#15 Fort Apocalypse OFFLINE  

Fort Apocalypse

    Stargunner

  • 1,593 posts

Posted Thu Dec 27, 2007 6:18 AM

Link to the easter egg Michael found about shakescreen since it has a code sample for how to shake the screen.

#16 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Wed Jul 23, 2008 11:53 AM

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.

#17 SeaGtGruff OFFLINE  

SeaGtGruff

    Quadrunner

  • 5,455 posts
  • Location:Georgia, USA

Posted Wed Jul 23, 2008 6:27 PM

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

#18 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,552 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Fri Jul 25, 2008 10:27 AM

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

#19 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Mon Jul 28, 2008 8:44 AM

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



#20 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Wed Jul 30, 2008 6:44 PM

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!

#21 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Thu Aug 7, 2008 11:59 AM

Here's my own code snippet. I was fooling around and thought maybe somebody could make some use of this.

In this I show you how to use two player sprites combined to make one big player sprite.

Attached Files



#22 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,552 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Mon Jan 26, 2009 8:07 AM

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

#23 Atarius Maximus OFFLINE  

Atarius Maximus

    Stargunner

  • Topic Starter
  • 1,552 posts
  • Load "Atari2600",8,1: SYS32777
  • Location:St. Louis, Missouri USA

Posted Tue Mar 17, 2009 12:48 PM

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

#24 RevEng ONLINE  

RevEng

    River Patroller

  • 3,411 posts
  • bit player
  • Location:Canada

Posted Sun May 31, 2009 9:24 AM

One more example for the pot - how to use shared sprite data for player0 and player1.


Attached File  13_SharedSpriteData.bas   5.16KB   383 downloads
Attached File  13_SharedSpriteData.bas.bin   4KB   366 downloads

(edit - fixed up the comments a bit)

Attached Files


Edited by RevEng, Sun May 31, 2009 11:25 AM.


#25 Animan OFFLINE  

Animan

    River Patroller

  • 2,391 posts
  • Just some guy who plays Atari and watches Anime.
  • Location:Texas

Posted Tue Jun 30, 2009 8:46 AM

Can anyone show me how to make a scrolling playfield?




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users