Jump to content
IGNORED

Can someone clarify the use of a Debounce bit and joy0fire for me?


disjaukifa

Recommended Posts



rem ************************
  rem My various bit variables
  rem ************************
  dim Bit0_Debounce_Reset = var47
  dim Bit1_Debounce_Fire = var47
  dim Bit2_Game_Mode = var47


  dim Master_Counter = var46
  dim Frame_Counter = var45


  goto titleScreen

  rem ************************
  rem Hard Reset. Takes user back
  rem to the title screen and clears out
  rem all the variables as well.
  rem ************************
Hard_Reset
  pfclear
  drawscreen
  for temp5 = 0 to 25 : a[temp5] = 0 : next
  for temp5 = 0 to 46 : var0[temp5] = 0 : next
  Bit0_Debounce_Reset{0} = 1


titleScreen
  gosub titledrawscreen bank7
  if !switchreset && !joy0fire then Bit0_Debounce_Reset{0} = 0 : goto titleScreen
  if Bit0_Debounce_Reset{0} then goto titleScreen

  goto GameSetup

 

I'm trying to wrap my head around using bits for booleans to control various aspects of game I'm working on, and I'm missing something. Can someone explain to me exactly how the above code works so I can use it in other places!

 

Essential what I want to do in my code is make sure that the fire button won't tigger an action until it has been release, but for whatever reason, I can't seem to wrap my head around this bit codes to act as booleans and check it.

 

Thanks

Edited by disjaukifa
Link to comment
Share on other sites

Update. I've figured out the bit operater situation in the game I'm currently working on, but I would love some clarification otnh e coding example above which I know works, specifically how do you get out of the TitleScreen loop.

 

Thanks

Edited by disjaukifa
Link to comment
Share on other sites

Have you looked at the code here:

 

http://www.randomter...itching_example

 

I have not looked at that specific example but I have been on that page most of last night and parts of this morning.

Take a look at it. Just about every line of code is explained using REM statements.

Link to comment
Share on other sites

Basic flow control for debounce works like in the example, but that can look slightly confusing to those just getting introduced to bB.

Conceptualize it like this with:

rem if I press the fire button it should set the debounce bit and perform some bit of code
rem also I want to see if the debounce is still set to 1, if it is then dont proceed until debounce gets reset to 0
rem if the player is no longer holding down the fire button, then clear the debounce bit

 if joy0fire then bit_debounce = 1
wait_until_debounce_clear
 if !joy0fire then bit_debounce = 0
 if bit_debounce then goto wait_until_debounce_clear

When you say "if bit_blah then dosomething", your asking if the bit is 1, when you say "if !bit_blah then dosomething", your asking if the bit is 0

Hope this helped, RT's examples are good references to keep referring back to when you forget how things are supposed to work.

Edited by ScumSoft
Link to comment
Share on other sites

Basic flow control for debounce works like in the example, but that can look slightly confusing to those just getting introduced to bB.

Conceptualize it like this with:

rem if I press the fire button it should set the debounce bit and perform some bit of code
rem also I want to see if the debounce is still set to 1, if it is then dont proceed until debounce gets reset to 0
rem if the player is no longer holding down the fire button, then clear the debounce bit

 if joy0fire then bit_debounce = 1
wait_until_debounce_clear
 if !joy0fire then bit_debounce = 0
 if bit_debounce then goto wait_until_debounce_clear

When you say "if bit_blah then dosomething", your asking if the bit is 1, when you say "if !bit_blah then dosomething", your asking if the bit is 0

Hope this helped, RT's examples are good references to keep referring back to when you forget how things are supposed to work.

 

Yep it did, the problem I was having was actually a typo in my code that I just completely missed, I was checking Bit3_Jump_Peak{3} however when I went to modify it to see if it hit its peak I was doing the following

 

if player0y == 35 && !Bit3_Jump_Peak{3} then Bit3_Jump_Peak{0} = 1

 

And I was using that boolean bit to help check for the toggle of my Debounce boolean bit as well, so it was messing up all my code.

Edited by disjaukifa
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...