Shop OBEX P1 Docs P2 Docs Learn Events
code advice — Parallax Forums

code advice

shmowshmow Posts: 109
edited 2008-06-09 18:22 in Propeller 1
I've written a little "beat the clock" game.
The player has to press and hold a button for 5 seconds before the clock runs out.
I have a hub dedicated to each timer:
- one hub for the game clock which counts down to zero - timer1.
- another hub for the player's 5 sec pushbutton - timer2.

The premise is if the player holds the pushbutton down for all 5 seconds before the game's clock counts to zero then the player wins and the "computer" has lost, and...
...if the game's clock reaches zero before the player can reach 5 seconds with the pushbutton then the "computer" wins and the player has lost.

The conflict arises if the player's time with the pushbutton·reaches the 5 second at the same time as the game's clock reaches zero.

I've tried assigning variables to force one or the other.· I may even try the XOR to work in favor of the game - not truely fair.

Does anyone have any suggestions?

Much appreciated,
Shmow

Comments

  • vampyrevampyre Posts: 146
    edited 2008-06-09 15:18
    I think that you must mean you have two cogs running the game? that being said I think it would be most helpful if you posted your code for us to look at, or at least the parts of your code that check for the winning condition
  • hippyhippy Posts: 1,981
    edited 2008-06-09 15:28
    I'm not sure I understand the game itself but if you want a fair system then you'll have to accept the notion that the outcome will be win, lose or draw. If you are only willing to declare win or lose you have to accept that what would have been a draw will have to be unfair on one player or the other.
  • BurritoeBurritoe Posts: 5
    edited 2008-06-09 18:22
    In which cog does the comparison of the the two timers reside?· Where is the checking of the two timers and when does it happen?

    It would be of help to post your code.

    if you are using the full resolution of the cnt, the 'ties' should be highly unlikely.
Sign In or Register to comment.