Jump to content
IGNORED

Beginner help with IntyBasic


dalves
 Share

Recommended Posts

I've been trying my hand at programming for the Intellivision using IntyBasic. I've put together a basic program to gain some experience with sprites, collision detection, score keeping, and so on. I've uploaded the .bas file for anyone who wants to take a look. I'm hoping to gain some insight into some problems I'm having trouble figuring out and also would appreciate any tips on improving my code. Below are some questions I have and areas I hope to understand better. Any help would be greatly appreciated.

 

1. The code I've written is functional, but not sure if there are more efficient ways to do the same functions.

 

2. Still not 100% clear on the "WAIT" command. I assumed it is used to refresh the graphics. I'm not sure if I'm using it in places where it isn't needed or not using it enough.

 

3. When drawing the bars on the sides of the screen, I was hoping to have the blocks colored as (White, Light Blue, Blue, Light Blue, White). Unfortunately, it seems I can only access the first 8 colors and can't use the light blue. Not sure what I can do to make that work.

 

4. Originally was using a For/Next loop to fire the missile, but it would stop all other movement until the For/Next was complete. I found a work around for that, but still have the missile following the horizontal movement of the player's ship. Would appreciate any insight in how to have the missile stay at the "X" location it was fired from, but allowing the user to still move the ship.

 

5. I had read somewhere that you can't use the same sprite multiple times on screen. I was wondering if this is true and if so, I'm assuming there must be a work around.

 

I know I will come across more questions as I do more programming, but these are the ones I was hoping for some help with at this time. Again, any help would be appreciated.

st3.bas

  • Like 2
Link to comment
Share on other sites

I've been trying my hand at programming for the Intellivision using IntyBasic. I've put together a basic program to gain some experience with sprites, collision detection, score keeping, and so on. I've uploaded the .bas file for anyone who wants to take a look. I'm hoping to gain some insight into some problems I'm having trouble figuring out and also would appreciate any tips on improving my code. Below are some questions I have and areas I hope to understand better. Any help would be greatly appreciated.

 

1. The code I've written is functional, but not sure if there are more efficient ways to do the same functions.

 

2. Still not 100% clear on the "WAIT" command. I assumed it is used to refresh the graphics. I'm not sure if I'm using it in places where it isn't needed or not using it enough.

 

It will sync the game to 60 hz if you are in the game loop. Wait also see if there's collusion detection occurred in the previous frame. Some function need to be in VSYNC portion of the screen to function properly like DEFINE function.

 

3. When drawing the bars on the sides of the screen, I was hoping to have the blocks colored as (White, Light Blue, Blue, Light Blue, White). Unfortunately, it seems I can only access the first 8 colors and can't use the light blue. Not sure what I can do to make that work.

 

CONST CS_LIGHTBLUE = $1005. In order to access the upper color for the Intellivision, bit 12 has to be turned on. So there is a constant command for light blue.

 

4. Originally was using a For/Next loop to fire the missile, but it would stop all other movement until the For/Next was complete. I found a work around for that, but still have the missile following the horizontal movement of the player's ship. Would appreciate any insight in how to have the missile stay at the "X" location it was fired from, but allowing the user to still move the ship.

 

Have the missile have it own a, x, and y value. A stands for active, x stands for x-coordinate, and y stands for y-coordinate.

A=0 could mean that the missile can be fired.

 

if missilea=0 AND cont1.b0 then missilea=1:missiley=playery:missilex=playerx 'fires missile

if missilea=1 then missilex=missilex+1 'will move missile 1 pixel a frame

if missilex=160 then missilea=0:missilex=missiley=0 'if missile go off screen

 

5. I had read somewhere that you can't use the same sprite multiple times on screen. I was wondering if this is true and if so, I'm assuming there must be a work around.

 

There's max of 8 sprites that the Intellivision can have on screen. There's work around but have to be creative with this.

 

I know I will come across more questions as I do more programming, but these are the ones I was hoping for some help with at this time. Again, any help would be appreciated.

Link to comment
Share on other sites

Thanks Kiwi. The description for the WAIT command and missile code helped a bunch. I think the spirit of the code I'm using is correct, but I know it is long winded and clunky.

 

I still am having a problem with assigning the CS_LIGHTBLUE. I am including the most recent Constants.bas. I'm printing the bar as written below.

 

PRINT AT 20 COLOR CS_LIGHTBLUE, "\165"

 

When I use any of the first 8 colors, the character displays correctly, but when I assign any color after that, the it is all garbled.

 

The question I'm trying to find an answer to about sprites is about using the same sprite on the screen multiple times. An example would be Space Armada. I always assumed that the rows of aliens were the same sprite used several times to create a row. Or as in Astrosmash when you have multiple asteroids falling that are the same graphic but different colors. I didn't think you'd have to create a separate sprite for each one.

 

(One other thing I'd like to figure out is how to generate a random star field, like in Astrosmash.)

Link to comment
Share on other sites

As a side note. I'm doing okay with looking at existing programs and learning from that. Occasionally the syntax of certain commands seems to vary in different program. I'm trying to use RAND in an existing program to create a random "X" coordinate of an enemy. One example program shows it written as (Using X as the variable), "X=RAND/2+20", another one shows it as "X=RAND % 16". If anyone can help with this, it would be greatly appreciated.

Edited by dalves
Link to comment
Share on other sites

It depends on how you are using RAND.

 

RAND is an internal variable that gets updated in each screen frame and contains a pseudo-random number between 0 and 255.

 

RANDOM is the same variable but forced to be updated, useful if you're using several random numbers per frame BUT it's more slow.

 

Using the % operator you get a random value in the range 0..x-1, for example, RAND % 16 gives you a value between 0 and 15. Typically this value is adjusted to a minimum using the add operator.

 

For example, given the Intellivision screen width is 20 columns, if you have one column of wall at left and at right, then you get a position inside using X = RAND % 18 + 1 (gives a value from 1 to 18, never 0 or 19)

 

For pixel positioning it's enough to multiply by 8 or use direct pixel positioning X = RAND % 144 + 8

Link to comment
Share on other sites

Thanks again for your responses and information. I guess this is one of the difficulties with being a beginner. I've been able to use some of the sample codes that people have shared to start to do some very basic programming. There is still a lot of it that looks like a foreign language to me. I'm sure I can chip away at it slowly, but when you can put something together that kind of resembles a game, you want to have all the answers immediately so you can keep creating.

 

Astrosmash is one of my favorite games and I'm currently using that as a template to learn how to program. I've been able to program some basic functions like moving, firing, print the characters that form the mountain outline, have an asteroid falling from random locations and have affected score and lives. I still need to figure out how to make the starfield and add more falling asteroids and get the animated ship to fire. I'm sure I will over time. Who knows, I've always wanted to create a sequel to Astrosmash, and maybe someday soon I can. ;-)

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Making some progress, slow but sure...

 

I was wondering if anyone out there has seen an example .bas of a starfield? I can make one using Paint.NET, but then have trouble displaying text and sprites. I have absolutely no doubt I'm doing something wrong but still trying to figure out what. I'm assuming there are commands for drawing individual pixels and lines that I just don't know about yet.

 

Not sure if anyone would mind, but as I've been learning as a beginner, I've been putting together a "How to" PDF from the perspective of a beginner. I thought maybe it would be helpful for those like me who are just starting out like me.

Link to comment
Share on other sites

Intellivision is a tile-based system. There's 20x12 worth of 8x8 sized tiles, aka card. You can use the print at command to print period on the screen.

 

print at 83 color 7,"."

print at 10 color 7,"."

print at 150 color 7,"."

print at 210 color 7,"."

 

will print 4 period at a specific part of the screen. The number has to be 0-239, number 240 and above will crash the system.

Link to comment
Share on other sites

Thanks Kiwi, I had done that before but the stars looked huge. Wasn't sure if there was a way to draw individual pixels in the tiles while still being able to maintain text in other tiles.

 

Groovybee, I was looking for a basic static one like in Astrosmash.

Edited by dalves
Link to comment
Share on other sites

I guess that is part of what I don't understand at this point in my learning to program. Can I define a configuration of pixels into a single card and then copy that card to multiple locations on the screen? In the way you can do with sprites?

Yep! Thats how you make interesting backgrounds for the levels in your game. Just define bricks, flowers, stars, mountains etc. (whatever your game needs) and print them on screen at the locations you want them. There are more advanced techniques like using a map editor such as TileStudio to do the heavy lifting, but that comes with its own issues.

Link to comment
Share on other sites

Thanks Groovybee, that helps a ton. Most of my basic programming experience comes from having a Color Computer 3 as a kid. Programming graphics was very different in that system and I'm still feeling my way through the Intellivision way.

 

Perhaps I am getting greedy here, but do you know of any real basic examples of how this is done? It would be great to look at the code and figure out the right way to do it?

Link to comment
Share on other sites

Thanks Groovybee, that helps a ton. Most of my basic programming experience comes from having a Color Computer 3 as a kid. Programming graphics was very different in that system and I'm still feeling my way through the Intellivision way.

 

Perhaps I am getting greedy here, but do you know of any real basic examples of how this is done? It would be great to look at the code and figure out the right way to do it?

Did you look at any of the samples included with IntyBASIC in the samples or contrib folder? And are you using 1.2.6, currently the newest?

Link to comment
Share on other sites

I just checked and I'm using the SDK 1.0.1. I downloaded IntyBasic 1.2.6 and saw there were a lot more .bas files in the Contributions folder. I will check those out and see if I can figure it out.

 

I was checking out the AppleCatcher.bas, as that seemed to be one with a very detailed background. If I understand correctly, it looks like you create the background images using Bitmaps and then use Print to draw them in the tile?

  • Like 1
Link to comment
Share on other sites

I just checked and I'm using the SDK 1.0.1. I downloaded IntyBasic 1.2.6 and saw there were a lot more .bas files in the Contributions folder. I will check those out and see if I can figure it out.

 

I was checking out the AppleCatcher.bas, as that seemed to be one with a very detailed background. If I understand correctly, it looks like you create the background images using Bitmaps and then use Print to draw them in the tile?

 

That's right :) also give a look to the IntyBASIC manual to check usage of statements and make comparisons with Apple Catcher.

Link to comment
Share on other sites

My first game is coming along pretty well, considering my limited knowledge of the code. The background needs more work and the stars need to look more random, but the general layout is there. Still need to figure out how to do an animated explosion without slowing down the rest of the sprites. I'm using GOSUB with WAIT to draw each sprite of the explosion and it bogs down the game.

 

Invasion

  • Like 8
Link to comment
Share on other sites

My first game is coming along pretty well, considering my limited knowledge of the code. The background needs more work and the stars need to look more random, but the general layout is there. Still need to figure out how to do an animated explosion without slowing down the rest of the sprites. I'm using GOSUB with WAIT to draw each sprite of the explosion and it bogs down the game.

 

 

It looks pretty cool! :cool:

 

Although I will say it is perhaps too similar to Astrosmash. I think you can change the look a bit and still retain the same feel. For instance, instead of a solid horizontal line as the "ground," maybe draw it bumpy and uneven, maybe even conforming to the ground pattern you made below it to give it some texture. The cannon can still move horizontally on top of it.

 

For extra coolness, you could make the cannon sprite have less priority than the background (clearing the MOB "priority" bit), and have it move "behind" some of the terrain features. If you keep the bumps at just a few pixels high, it would give a nice effect without obscuring the cannon itself.

 

Also, you could colour the background mountains in various layers (take a look at the Goat Nom title screen for an idea), or change it to a cityscape.

 

As for the stars, that's so easy it's almost criminal: Make a few cards with various cluster patterns of stars in them (e.g., a single pixel in different positions, two pixels close to each other, etc.), just three or four should be sufficient, and of course the "clear" card (which is in GROM). As you draw your background in a loop, get a random number within the range of your "star pattern" cards and draw that card onto the screen. For a more sparse look, have your random numbers bias towards zero (the clear card).

 

Let us know if you need help writing code for that.

 

-dZ.

Link to comment
Share on other sites

My first game is coming along pretty well, considering my limited knowledge of the code. The background needs more work and the stars need to look more random, but the general layout is there. Still need to figure out how to do an animated explosion without slowing down the rest of the sprites. I'm using GOSUB with WAIT to draw each sprite of the explosion and it bogs down the game.

 

 

Looks awesome. I think there is a lot of merit to mimicking something familiar as you learn and then add things as you learn more. (and DZ-Jay has a knack for making really good suggestions of what makes game even more playable)..

 

From the pic I am guessing we are protecting the 3 buildings buried in the ground level.

Link to comment
Share on other sites

Thanks for the input. DZ, I LOVE some of your ideas to give the game depth. I recently read something about the "Behind" statement and I'll have to find an example of it. I was thinking about drawing the bottom of a large mothership at the top of the screen and have the other ships emerge from that.

 

The general idea is kind of a hybrid between Space Invades and Missile Command. You have large and small ships descending on the planet. The large ships use guided missiles to keep you occupied and away from the smaller ships that are looking to destroy the 3 underground cities you're defending.

 

I'm going to tweak a couple things and then I'll post the ROM and BAS files for anyone who's interested.

Link to comment
Share on other sites

Hey everyone, I decided to upload the ROM and BAS files of what I have of the game so far. Just a reminder that this game is still in the "Sketch" stages. I have the general idea of what I want it to be but need to fine tune what aliens play what part. Right now it is set up with 5 levels that are all the same other than the backgrounds changing color. I think I'm going to eventually have it so each stage is almost it's own game, with ships and tasks unique to that level. I've got most of the bugs ironed out, but still have a couple more to correct. If you look at my code, you will see how limited I am in my understanding of programming for Intellivision at this point. I draw the backgrounds and use sprites, and then the rest of it is all "IF" statements. Hopefully as I learn more my games and programming will improve as well. ;-)

inv10.bas

inv10.rom

  • Like 2
Link to comment
Share on other sites

For IntyBASIC in general, I'd recommend learning how the Gosub keyword works. It lets you isolate code into logical Procedures that help simplify your game start and loops

For instance:

REM Print title screen text


PRINT AT 62 COLOR CS_WHITE,"Alves Electronics"
PRINT AT 86 COLOR CS_WHITE,"presents"
PRINT AT 146 COLOR CS_WHITE,"Invasion"
PRINT AT 201 COLOR CS_WHITE,"Copr @ 2016  Alves"


could be isolated into a procedure:


ShowTitleScreen: Procedure
PRINT AT 62 COLOR CS_WHITE,"Alves Electronics"
PRINT AT 86 COLOR CS_WHITE,"presents"
PRINT AT 146 COLOR CS_WHITE,"Invasion"
PRINT AT 201 COLOR CS_WHITE,"Copr @ 2016  Alves"
END

Then at the top you would have:

REM Print title screen text
Gosub ShowTitleScreen

Makes things easier to read and debug.

 

You can also compound logical things together with the ":"

IF #LEVEL=1 THEN MTNC=CS_YELLOW
IF #LEVEL=1 THEN DRTC=CS_TAN
IF #LEVEL=2 THEN MTNC=CS_DARKGREEN
IF #LEVEL=2 THEN DRTC=CS_GREEN
IF #LEVEL=3 THEN MTNC=CS_BLUE
IF #LEVEL=3 THEN DRTC=CS_WHITE
IF #LEVEL=4 THEN MTNC=CS_RED
IF #LEVEL=4 THEN DRTC=CS_YELLOW
IF #LEVEL=5 THEN MTNC=CS_GREEN
IF #LEVEL=5 THEN DRTC=CS_BLUE

becomes

IF #LEVEL=1 THEN MTNC=CS_YELLOW: DRTC=CS_TAN
IF #LEVEL=2 THEN MTNC=CS_DARKGREEN:DRTC=CS_GREEN

etc.

There is no need to perform the same IF twice. You can also use the IF..THEN..ELSE..ENDIF mechanism
IF #LEVEL=1 THEN
MTNC=CS_YELLOW
DRTC=CS_TAN
rem and do other stuff
END IF
In the collection of IFs example above, there are lots of more efficient ways including the ON #LEVEL GOSUB or storing the colors in an array. You certainly wouldn't iterate thru 100 "IF LEVEL=" commands just to change colors.
Definitely a good start, and by starting with a recent version of IntyBASIC you have the benefit of not having to use stinky hex codes everywhere ;)
  • Like 2
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...
 Share

  • Recently Browsing   0 members

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