Jump to content
IGNORED

How would I flash the playfield off and on?


Words Fail

Recommended Posts

I've got my game working.. I figured out how make it so when you run over all the blocks on the level it loads the next level... there's 4 levels right now, no enemies yet. I'd like the level to flash in between rounds. EDIT: I got the code working, but I'm trying to shorten it / make it better.

 

Earlier in my code it sets a=1, 2, etc to say which level you're on.

 

When the game determines you cleared a level it goes to a subroutine:

 

levelend
 player0x=250: player0y=150
 g=g+1
 if g=30 then g=0: goto levelend2
 drawscreen
 goto levelend

levelend2
 i=i+1
 if i=40 then goto levelend3
 if i=80 then gosub rack0: drawscreen
 if i=120 then goto levelend3
 if i=160 then gosub rack0: drawscreen
 if i=200 then goto levelend3
 if i=240 then gosub rack0: drawscreen
 if i=241 then a=a+1: g=0: h=0: b=0: return otherbank
 goto levelend2

levelend3
 if a=1 then gosub rack1: drawscreen: goto levelend
 if a=2 then gosub rack2: drawscreen: goto levelend
 if a=3 then gosub rack3: drawscreen: goto levelend
 if a=4 then gosub rack4: drawscreen: goto levelend

 

So rack0 is basically just a blank playfield statement.. and rack1 through rack4 are the levels.. so it's drawing the level, then drawing nothing, then drawing the level, etc. I am not sure how to get the speed nice. I used two freakin variables.. to slow it down. The flashes are kind of quick.

 

 

Edited by Words Fail
Link to comment
Share on other sites

I usually have a variable for a world timer. Then when I have other things that I may want slower or faster I only do them on certain frames. 
 

So I may do something like 

if w{1} then goto SKIP

or 

if w{0} then g=g+1

or 

if w{0} and joy0up then player0y=player0y+1


I play around with it sometimes to get timing or speed right but it helps save me some variables sometimes like if I want something to move slower but don’t want to waste a variable for it to have subpixel movement or if a variable alone counts down to fast. 

Link to comment
Share on other sites

I forgot about clearing the playfield. RT has this on his page for pfclear
 

I have used some depending on which saved me more space. Like if I wanted to keep the playfield but clear a certain spot I would just clear certain playfield variables. Or if I want the top cleared I will sometimes do a playfield statement but only have the top few lines I wish to clear (I’ve done this with colors as well). 

  • Like 1
Link to comment
Share on other sites


   Here the idea is the timer counts 1/10 second intervals whitch is 6 drawscreens
   a time slice is a count of 16 ie 1.6 second it sets the playfield color once per time slice
   the slices are counting 0..3 in bits 4 and 5 of timer
   if its slice 0 it sets the playfield color to the background color to blank the playfield
   if its not slice 0 it restores the playfield color
   so blank for 1.6 seconds playfield for 4.8 seconds

   after 4 cycles the timer rolls over and returns
   
   you could fiddle with the timing by changing the number of drawscreens per delay
   and/or number of counts per time slice

 

  untested

 

levelend
   player0x=250: player0y=150

   timer = 0

levelend2

   timer = timer + 1

   if !timer then a = a + 1: g = 0: h = 0: b = 0: return otherbank

   if timer & $0F then tenth_second_delay  ; if timer mod 16 <> 0

   ;  if timer mod 16 is 0 change the playfield

   if !timer & $30 then COLUPF = background_color: goto tenth_second_delay  ;  if timer is the zeroeth multiple of 16 blank the playfield

   ;  otherwise unblank

   COLUPF = playfield_color

tenth_second_delay
  drawscreen 
  drawscreen 
  drawscreen 
  drawscreen 
  drawscreen 
  drawscreen 
  goto levelend2

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I can't seem to figure out how to make a freakin timer that doesn't make me want to have a seizure. I saw your thing above about putting in 6 drawscreens.. no idea where they would go, but that really slows down the program.

 

I'm using DPC+ to chjange bkcolors as follows

 

 bkcolors:
 $00
 $80
 $80
 $82
 $82
 $84
 $84
 $86
 $86
 $88
 $88
 $88
 $86
 $86
 $84
 $84
 $82
 $82
 $80
 $80
 $00
 $00
end
 return otherbank

 

The top and bottom are always $00, the middle I think is always $88.. but the other colors I want to move around.. I'm kind of trying to make it like a space background of sorts. 

 

So the numbers just shift around.. in a few bkcolors statements.. just an example below.

 

bktimer 
 j=j+1
 if j=10 then goto bk1
 if j=20 then goto bk2
 if j=30 then goto bk3
 if j=40 then goto bk4
 if j=50 then goto bk5
 if j=60 then j=0: goto bk1

 

After it runs one of the bkcolors: section  it returns otherbank which is the end of my game loop and draws the screen then starts my loop over.

 

I'm sure there's a shorter way to do the above, but anyway running that code the background cycles way too quick.. basically flicker, but you can see something is going on.

 

So I added a second timer:

 

bktimer 
 k=k+1
 if k=100 then k=0: goto bktimer2
goto bktimer

bktimer2
 j=j+1
 if j=10 then goto bk1
 if j=20 then goto bk2
 if j=30 then goto bk3
 if j=40 then goto bk4
 if j=50 then goto bk5
 if j=60 then j=0: goto bk1


I figured the first time would slow it down.. that didn't work either. I tried changing the goto bktimer to return otherbank which draws the screen then does my loop again before going back to this routine to make new background colors.

 

 

Link to comment
Share on other sites

Loops don't work as delays in bB quite they same way they do in other basics. You have to include a drawscreen in the loop, otherwise all you're doing is adding a bunch of cycles before the screen is drawn and risking going out of sync.

 

For your color changes, assuming the code continues to a drawscreen, you're changing the colors every 10 frames or 1/6 of a second. Something like this might work better:

 

k = k + 1

if k = 120 then j = j + 1 : k = 0

if j = 5 then j = 0

on j goto bk0 bk1 bk2 bk3 bk4

 

This will change the colors every 120 frames or 2 seconds. If you adjust the timing, keep in mind that on...goto requires sequential values that start at 0 to work.

  • Like 1
Link to comment
Share on other sites

  I don't understand

 

  the drawscreens are part of the levelend routine they go were ever the levelend routine is
  I thought you were just flashing the screen between levels
  so the draw screens shouldn't slow the game down they should only slow the flashing.

 

  here's another variant


  the timer counts drawscreens and cycles in ~4.25 seconds
  so ~.85 seconds per bkx

 

  untested

 

levelend
   player0x=250: player0y=150

   timer = 0

levelend2

   temp1 = timer/2 : temp1 = (temp1/4 + temp1)/32  ;  temp1 = timer/51

   on temp1 gosub bk1 bk2 bk3 bk4 bk5

   drawscreen

   timer = timer + 1

   if timer then  levelend2

   a = a + 1: g = 0: h = 0: b = 0: return otherbank

 

  • Like 1
Link to comment
Share on other sites

Actually, I solved my issue by adding a second drawscreen to slow it down. I don't remember who to thank for that tip, but someone here mentioned it. Oh it was Bogax.

 

So it counts to 80, drawscreen twice, counts to 160 drawscreen twice, then 240 and you guessed it drawscreen twice. I actually have a level of all .............. it draws. I guess I can remove the counting crap and wasted variable and just drawscreen more times to create. I'll try shortly.

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