Jump to content
IGNORED

Score related ‘If’ declarations (Resolved)


ProwoodStuff

Recommended Posts

I’ve been experimenting with getting more playfields on screen but hit a roadblock. That roadblock being how it gets to the next screen. Because I want it to be when a certain score is hit, it goes to the next level.

 

The code I jotted down is:

if score = 2 then goto playfield2

Is there a way to resolve the issue or is this not possible to do on the Atari 2600?

Link to comment
Share on other sites

1 hour ago, Random Terrain said:

When the score is obtained, nothing happens.

 

Do I need to move stuff around at all? I'd be willing to bet I do.

 

mainloop
 temp5 = _sc3 & $0F
 if collision(player0,missile0) then score = score + 1
 temp6 = _sc3 & $0F
 if collision(player0,missile0) then missile0y = 134
 if player0x=161 then player0x=1
 if joy0up then player0y = player0y - 1
 if joy0down then player0y = player0y + 1
 if joy0left then player0x = player0x - 1
 if joy0right then player0x = player0x + 1 
 if _sc1 = $00 && _sc2 = $00 && _sc3 > $02 then goto playfield2
 drawscreen
 goto mainloop
end

The Missile moving is temporary until it changes to the next playfield.

Edited by ProwoodStuff
Adding more context to a certain line of code
Link to comment
Share on other sites

Try this:

 

   dim _sc1 = score
   dim _sc2 = score+1
   dim _sc3 = score+2

   scorecolor = $FA

__Main_Loop

   ; if collision(player0,missile0) then missile0y = 134 : score = score + 1

   if player0x > 160 then player0x = 1

   if c then c = c - 1

   if !joy0up then c = 0 : goto __Skip_Joy0_Up

   player0y = player0y - 1

   if !c then score = score + 1 : c = 45

__Skip_Joy0_Up

   if joy0down then player0y = player0y + 1
   if joy0left then player0x = player0x - 1
   if joy0right then player0x = player0x + 1

   if _sc1 = $00 && _sc2 = $00 && _sc3 > $01 then c = 45 : COLUBK = $B4 : goto __Playfield_02

   drawscreen

   goto __Main_Loop


__Playfield_02

   if c then c = c - 1 : if !c then COLUBK = 0 : score = 0 : goto __Main_Loop

   drawscreen

   goto __Playfield_02

 

For this test, I deactivated the collision code and made pushing up on the joystick increase the score. When it hits 2, the screen changes color.

  • Like 1
Link to comment
Share on other sites

10 hours ago, Random Terrain said:

Try this:

 

   dim _sc1 = score
   dim _sc2 = score+1
   dim _sc3 = score+2

   scorecolor = $FA

__Main_Loop

   ; if collision(player0,missile0) then missile0y = 134 : score = score + 1

   if player0x > 160 then player0x = 1

   if c then c = c - 1

   if !joy0up then c = 0 : goto __Skip_Joy0_Up

   player0y = player0y - 1

   if !c then score = score + 1 : c = 45

__Skip_Joy0_Up

   if joy0down then player0y = player0y + 1
   if joy0left then player0x = player0x - 1
   if joy0right then player0x = player0x + 1

   if _sc1 = $00 && _sc2 = $00 && _sc3 > $01 then c = 45 : COLUBK = $B4 : goto __Playfield_02

   drawscreen

   goto __Main_Loop


__Playfield_02

   if c then c = c - 1 : if !c then COLUBK = 0 : score = 0 : goto __Main_Loop

   drawscreen

   goto __Playfield_02

 

For this test, I deactivated the collision code and made pushing up on the joystick increase the score. When it hits 2, the screen changes color.

All it’s giving me is what I can only describe as a late 1800’s video but without the video and only the tape.

 

 

I’m probably going to start from scratch and see if I can optimise my spaghetti code more to have it so this stuff doesn’t cause the emulator to have a breakdown

Link to comment
Share on other sites

The test program works for me using Stella.

 

Here's the .bas file:

test_01_2023y_01m_13d_2058t.bas

 

Here's the .bin file to use with an emulator:

test_01_2023y_01m_13d_2058t.bin

 

You should see the score and pressing up should increase the score by one each time. When the score reaches 2, the background will change color, then the score will reset to 0.

 

 

Link to comment
Share on other sites

I did some really minor tweaking and got it to work but it takes just about 3.84 seconds to get to playfield 2, any adjustments I could make to make it faster and efficient?

 

mainloop
 
 if collision(player0,missile0) then missile0y = 134 : score = score + 1 
 if player0x > 160 then player0x = 1
 
 if c then c = c - 1
 
 if !joy0up then c = 0 : goto __Skip_Joy0_Up

 player0y = player0y - 1
 
 
 if switchreset then reboot
 
__Skip_Joy0_Up

   if joy0down then player0y = player0y + 1
   if joy0left then player0x = player0x - 1
   if joy0right then player0x = player0x + 1

   if _sc1 = $00 && _sc2 = $00 && _sc3 = $02 then c = 45 : COLUBK = $B4 : goto __Playfield_02
 
 drawscreen
 goto mainloop
end

__Playfield_02

   if c then c = c + 1 : if !c then COLUBK = 0 : score = 3 : goto mainloop 

   goto __Playfield_02
 
end

 

Link to comment
Share on other sites

The text example program slows stuff down using a counter to make it easier for you to see what is happening. You wouldn't use that counter or the color changes in your actual program.

 

It would look more like this after the extra test code is removed:

 

__Main_Loop

   if collision(player0,missile0) then missile0y = 134 : score = score + 1

   if joy0up then player0y = player0y - 1
   if joy0down then player0y = player0y + 1
   if joy0left then player0x = player0x - 1
   if joy0right then player0x = player0x + 1

   if player0x > 160 then player0x = 1

   if _sc1 = $00 && _sc2 = $00 && _sc3 > $01 then goto __Playfield_02

   drawscreen

   goto __Main_Loop


__Playfield_02

   ; More of your code goes here

 

  • Thanks 1
Link to comment
Share on other sites

1 minute ago, Random Terrain said:

The text example program slows stuff down using a counter to make it easier for you to see what is happening. You wouldn't use that counter or the color changes in your actual program.

 

It would look more like this after the extra test code is removed:

 

__Main_Loop

   if collision(player0,missile0) then missile0y = 134 : score = score + 1

   if joy0up then player0y = player0y - 1
   if joy0down then player0y = player0y + 1
   if joy0left then player0x = player0x - 1
   if joy0right then player0x = player0x + 1

   if player0x > 160 then player0x = 1

   if _sc1 = $00 && _sc2 = $00 && _sc3 > $01 then goto __Playfield_02

   drawscreen

   goto __Main_Loop


__Playfield_02

   ; More of your code goes here

 

ah, well that's why lol.

 

Thanks for all the help. I'll try and take it from here now that I have a basic understanding.

I'll post again if stuff goes sideways 

Link to comment
Share on other sites

As a side I find that using the score can be harder than just using a plain old variable.  Less gotchas and more flexible options for performing math.

 

As an example: if you get points for crashing into an enemy car you could also use a separate variable to tally up each crash.   After 10 crashes then go to the next screen.

  • Like 3
Link to comment
Share on other sites

56 minutes ago, Gemintronic said:

As a side I find that using the score can be harder than just using a plain old variable.  Less gotchas and more flexible options for performing math.

 

As an example: if you get points for crashing into an enemy car you could also use a separate variable to tally up each crash.   After 10 crashes then go to the next screen.

So true. I based some of my earlier games difficulty progression on score and found it to cause more issues or be not as precise. Now I have a variable or two that tally things for me that will flip bits or trigger things to happen. 

  • Like 3
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...