Jump to content
IGNORED

First Time Programming an Atari 2600 Game! (And I need your help)


Recommended Posts

Hi Everyone!

 

I've been watching a few YouTube Series featuring batari Basic game dev and decided to give it a go.

 

To keep things simple, I'm using the standard kernel.

 

So far, I've been able to create my sprites, missile, playfield, ball movement, joystick control, and scoring. Not bad for hacking my way through, but I could really use some community assistance.

 

I'm struggling with:

  1. Animating my sprite when moving left and right (I'm trying to cycle through four frames of animation and then return to the idle sprite when not in motion)
  2. Collision detection between my p0 sprite and the ball seems inconsistent (Sometimes it looks as though it passes right through without registering the collision)

 

The Game

Objective: Capture as many delicious flies as you can

Hazard: Watch out for wasps! They can break your web. (I haven't coded the enemy yet)

Controls:

- Hold button to lower spider on her web

- Release button to climb back up the web

- You can only move left or right when at the top of the screen

 

Any and all feedback, advice, assistance is greatly appreciated.

Attached is my game code, so far. 

spidergame.bas

Persistence pays off!

 

I realized I forgot to include a goto command after each of the sprite frames, so it was always using the last sprite data table.

 

Still not sure how to ensure 100% p0 and ball collision detection, yet.

1 hour ago, 8bitPoet said:

I've been watching a few YouTube Series featuring batari Basic game dev and decided to give it a go.

 

Can you post links to those? I might want to link to them if they're good.

 

 

 

1 hour ago, 8bitPoet said:

I'm struggling with:

  1. Animating my sprite when moving left and right (I'm trying to cycle through four frames of animation and then return to the idle sprite when not in motion)
  2. Collision detection between my p0 sprite and the ball seems inconsistent (Sometimes it looks as though it passes right through without registering the collision)

 

I'll take a look and see if I can do anything. I see that you were working on your program some more. Please post the latest version.

Hey RT! Thanks for responding.

 

11 minutes ago, Random Terrain said:

Can you post links to those? I might want to link to them if they're good.

 

Here are the two YouTube series that I was referring to in my original post. I believe they're still coming out with episodes.

 

Here's the latest version of my game WIP with the working animations.

spidergame.bas

  • Like 3

I see that you are using b = (rand&40) + 30 in your program. According to the chart, that number 40 should be 1, 3, 7, 15, 31, 63, or 127.

23 minutes ago, Random Terrain said:

I see that you are using b = (rand&40) + 30 in your program. According to the chart, that number 40 should be 1, 3, 7, 15, 31, 63, or 127.

Ah ok. Fixed it. I thought I could choose any number for the range, but I was able to switch it to (rand&63) + 20 to keep the fly within the desired Y range.

 

I also think I've resolved the collision issue by doubling the width of the ball using CTRLPF = $11.

 

In other progress, I've added the enemy sprite (a wasp) but it doesn't do anything at the moment ... except flap its wings.

 

Updated game code attached.

 

Is it normal to produce code vomit and then go back and tidy everything up?

spidergame.bas

  • Like 1
15 minutes ago, 8bitPoet said:

Ah ok. Fixed it. I thought I could choose any number for the range, but I was able to switch it to (rand&63) + 20 to keep the fly within the desired Y range.

 

I also think I've resolved the collision issue by doubling the width of the ball using CTRLPF = $11.

 

In other progress, I've added the enemy sprite (a wasp) but it doesn't do anything at the moment ... except flap its wings.

 

Updated game code attached.

 

Is it normal to produce code vomit and then go back and tidy everything up?

 

Do you like the ball tiny? I was working on a test program to find the box area of the spider and if the fly is in that area, there will be a collision. No need for "if collision(player0,ball) then" if I do that.

 

I was also adding some little bit "variables" for you so you don't have to waste entire variables to know if things are off and on.

 

Your last question reminds me of a quote on this page:

 

https://www.randomterrain.com/rt-motivation-and-creativity-page-for-programmers.html

Quote

 

I have a a design philosophy that can be summed up in one sentence: "Make it work reliably and fast." This sentence can be broken down into the basic steps of a project:

  1. Make it.
  2. Make it work.
  3. Make it work reliably.
  4. Make it work reliably and fast.

~Donald R. Lebeau

 

 

In this case it would be make it, make it work, make it readable, make it even more readable by adding comments so you and others will know how the program works in the future since you will probably forget what you did and why you did it.

 

Also, if you keep making changes to your program while I'm working on it, my version will be 20 steps behind.

5 minutes ago, Random Terrain said:

Do you like the ball tiny? I was working on a test program to find the box area of the spider and if the fly is in that area, there will be a collision. No need for "if collision(player0,ball) then" if I do that.

I don't mind the larger 2 pixel wide ball in this case, but a hit box area for the spider would make for more reliable collision if I went with the smaller fly.

 

6 minutes ago, Random Terrain said:

I was also adding some little bit "variables" for you so you don't have to waste entire variables to know if things are off and on.

Bit "variables" is a brand new concept for me. I saw Karl G use them in some example code, but didn't fully grasp the execution.

 

That's a great quote! I guess I'm in the 'Make it work' phase. 😃

 

11 minutes ago, Random Terrain said:

Also, if you keep making changes to your program while I'm working on it, my version will be 20 steps behind.

My bad. I'll step away from the keyboard. I had some good momentum going and didn't want to stop.

 

I completed Gustavo's online 6502 assembly course over the summer, and while I learned a ton about how the Atari 2600 operates, my game concepts were outside my range of knowledge.

 

With batari Basic, you can 'Make it work' in a very short amount of time. So thank you for that!

  • Like 1

I have the new collision figured out and am trying to merge the two version of your program. Among the changes so far, I put "pfhline 0 0 31 on" before your main loop since you don't have to keep drawing it over and over again. That will save you some cycles.

Here's the program with a few changes to the code:

 

spidergame_2023y_11m_29d_0503t.bas

 

 

Here is the .bin file to use with your favorite emulator:

 

spidergame_2023y_11m_29d_0503t.bin

 

  • Like 2

Alright! I think I'm getting the bit variables now. I added another that's used to reflect the player 0 sprite when moving left. Super handy!

 

I see what you did for the modified collision detection. You're forming a "hitbox" by using a combination of the player 0 x and y and the sprite dimensions. Clever.

 

I'm gonna try to tackle the enemy attack next and then attempt to add some sounds.

 

Thank you for all of your assistance!

 

  • Like 1
5 hours ago, LatchKeyKid said:

As a future new coder myself, I'm looking forward to seeing how this progresses!

Hey @LatchKeyKid! I appreciate the encouragement. I'm sure I'll be posting regularly, as I'm relying heavily on the assistance from the community when I get stuck on something.

 

  • Like 1

PROGRESS UPDATE (and request for help)

 

I've rethought the enemy and have decided that the enemy is now ... an inchworm!

I know. Not the first thing you think of when you think of a potential threat, but this inchworm is a bully and will knock you down. (He shows up every 30 seconds in the game)

I may still use the wasp, but that's for a future decision.

 

I've tried to write a routine that animates the demise of the spider when the inchworm and spider collide. It's supposed to bounce up a few lines, then fall to the bottom.

However, I'm getting some unexpected results.

1. The spider's web is rendered during the animation, which it shouldn't be because I've added a line of code to skip the joystick routine when the collision flag is 1 and that's where the missile0 is used.

2. There's no animation OR it's happening in the blink of an eye. I've attempted to use the frame counter to control the animation speed, but I can't tell if it's working or not.

 

Attaching my latest .bas and .bin if anyone wants to look under the hood.

DISCLAIMER: Noob programmer made this.

 

spidergame_2023y_11m_30d_0245t.bas

spidergame_2023y_11m_30d_0245t.bas.bin

  • Like 3

I was out all day with my sister going to doctors and stores, so I probably won't be able to look until some time tomorrow.

I'm just starting to look at the code. A good habit to get into is using dim to make descriptive aliases for all variables that you're using since it helps you in the future when you look back at your old code and it helps others who might have to help you.

 

When dim is used to make aliases, people who use Visual batari Basic can select Audit Variables and that will list all variables used in the program.

 

Looks like you need to add a counter to slow down the death animation similar to what you did for making the inchworm appear. I don't know what variables are free since you're not using aliases for all your variables, so you'll have to do that yourself.

5 hours ago, Random Terrain said:

A good habit to get into is using dim to make descriptive aliases for all variables that you're using since it helps you in the future when you look back at your old code and it helps others who might have to help you.

That's a great suggestion. I'm reviewing my variable usage and think there might be an opportunity to use more temp variables, instead. Especially for situational counters. But I'll add variable aliases for the others.

 

5 hours ago, Random Terrain said:

Looks like you need to add a counter to slow down the death animation similar to what you did for making the inchworm appear.

I'm using _Frame_Counter effectively for the inchworm, but my implementation of it for the player death animation isn't working as expected. This also looks like one of those cases where variables i and h could be replaced with temp6 and temp5.

 

   ;***************************************************************
   ;
   ; Player death
   ;
   if !_Bit5_Inchworm_Collision{5} then goto __Skip_Player_Death
   player0:
   %00000000
   %00000000
   %11000110
   %00111000
   %11010110
   %10111010
end
   if _Frame_Counter <> 1 then goto __Skip_Player_Death ; Use Frame Counter for animation speed
   if i < 5 then i = i + 1 : y = y - i    ; bounce up a few pixels
   if i > 5 then h = h + 2 : y = y + h    ; then fall
   if y > 80 then _Bit5_Inchworm_Collision{5} = 0 : i = 0 : h = 0 : score = 0   ; Reset the collision flag
   player0y = y
__Skip_Player_Death

 

8 minutes ago, Random Terrain said:

If I remember correctly, temp variables can't be used as counters since they are short lived.

Ah ok. So I should define some permanent counter variables and repurpose them in my routines.

 

  • Like 1

I'm so close to figuring this out! 

 

I think it has something to do with my Inchworm Collision bit variable, _Bit5_Inchworm_Collision.

When the collision happens, _Bit5_Inchworm_Collision is set to 1. Then is tests for that flag to skip the joystick routine and to run the player death routine. Even with that check, I'm able to use the fire button so I'm doing something wrong here.

 

Here's the joystick routine in question:

   ;***************************************************************
   ;
   ; Joystick Routine
   ;
   if _Bit5_Inchworm_Collision{5} then goto __Skip_Joystick_Routine ; Disable controls during player death

   if joy0fire && y < 88 then y = y + 2 : missile0height = missile0height + 2 : _Bit1_UD_Joy_Movement{1} = 1 ; Spider moves down
   if !joy0fire && y > 8 then y = y - 2 : missile0height = missile0height - 2 : _Bit1_UD_Joy_Movement{1} = 0 ; Spider moves up

   if _Bit1_UD_Joy_Movement && y < 16 then missile0height = missile0height - 2 ; Limits missile 0 height until player drops past playfield

   if joy0left && y = 8 then x = x - 2 : _Bit2_LR_Joy_Movement{2} = 1 : _Bit3_Flip_P0{3} = 1
   if joy0right && y = 8 then x = x + 2 : _Bit2_LR_Joy_Movement{2} = 1 : _Bit3_Flip_P0{3} = 0
   if !joy0left then _Bit3_Flip_P0{3} = 0
   
   if x < 18 then x = 18 ; Left movement limiter
   if x > 137 then x = 137 ; Right movement limiter

   ; Position player 0 sprite
   player0x = x
   player0y = y
   ; Align missile to the top center of player 0 sprite
   missile0x = x + 4
   missile0y = y - 7
   

   if y < 16 then missile0x = 0 : missile0y = 0 : missile0height = 0 ; Hides web when player reaches top
   if y >= 88 then _Bit1_UD_Joy_Movement{1} = 0

__Skip_Joystick_Routine

 

And I've simplified the player death routine:

   ;***************************************************************
   ;
   ; Player death
   ;
   if !_Bit5_Inchworm_Collision{5} then goto __Skip_Player_Death ; If no collision, skip this routine
   ; Swap to falling player 0 sprite
   player0:
   %00000000
   %00000000
   %11000110
   %00111000
   %11010110
   %10111010
end
   if _Counter_I < 5 then _Counter_I = _Counter_I + 1 : player0y = player0y - _Counter_I    ; bounce up a few pixels
   if _Counter_I >= 5 then player0y = player0y + 2                                          ; fall down after bounce
   if player0y > 88 then _Bit5_Inchworm_Collision{5} = 0 : _Counter_I = 0 : score = 0   ; Reset the collision flag
__Skip_Player_Death

 

P.S. - I created variable aliases to make things easier, but I'm not sure my alias names are very good.

 

spidergame_2023y_12m_01d_0545t.bas

  • Like 1

I think I figured it out. When you bounce the player up after touching the inchworm, you're wrapping beyond zero into the 200s, so "if player0y > 88 then _Bit5_Inchworm_Collision{5} = 0" is getting activated during the bounce up. Stop from going backwards beyond zero and it should work.

  • Thanks 1
33 minutes ago, Random Terrain said:

Stop from going backwards beyond zero and it should work.

That was it! I lowered the number of pixels for the bounce and it works!

 

Thank you for helping me solve that!

 

Question regarding the Background kernel option.

If I used set kernel_options pfcolors pfheights background would I be able to make that top stripe span the full width of the screen without losing any missiles?

 

  • Like 1

KERNEL OPTION

I tried using the pfcolors, pfheights, and background to have the "branch" span the full screen, but couldn't get it to render without a vertical pixel shift part way across the screen. I also lost the fly's body because the ball was the same color as the pf/background.

Probably for the best, since the current playfield shows the player how far to the left and right the spider can move.

 

AUDIO

Since then, I've added some sound effects! We've got the tiny pattering of spider steps and a slide whistle effect when the spider is using her web.

I'm trying to add a sound that plays when a fly is captured, but whenever I try to use an audio channel that I've used for another sound, I just get a crackling noise.

I've commented it out for now, but there's a routing called Point Awarded Sound Effect at line 138.

I guess my question is whether or not you can trigger sounds using the same audio channel, but at different times?

 

SCORING

I've been thinking about the points. While play testing, I get the most satisfaction out of streaks. If one fly gets past me, in my head I'm starting over. The points don't reflect this, but I'm thinking that's what I'll do. I'll zero out the score if a fly reaches the left of the screen, but the highest streak will get stored in a separate variable from the score. The only way the game would end is if the play collides with the inchworm.

If I go that route, would I be able to show the highest streak on the Game Over screen?

 

Here's the latest .bin and .bas

spidergame_2023y_12m_02d_0305t.basspidergame_2023y_12m_02d_0305t.bas.bin

  • Like 2

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