Game Clock DLL

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Game Clock DLL

Post by netmaestro »

This is an oldschool analog chess clock, usable in any game that times the players.

Code: Select all

Import "chessclock.lib"
  CreateGameClock(a,b,c)
  CloseGameClock()
  PressClock(player)
EndImport

OpenWindow(0,0,0,320,240,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
ButtonGadget(1, 30,210,80,20,"Pause")
ButtonGadget(2, 120,210,80,20,"Press White")
ButtonGadget(3, 210,210,80,20,"Press Black ")

CreateGameClock(WindowID(0),10,10)

pressclock(0)

Repeat
  EventID = WaitWindowEvent()
  Select EventID
    Case #PB_Event_CloseWindow
      If EventWindow()=0
        CloseWindow(0)
      EndIf
      
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          PressClock(0) ; Idle
        Case 2
          PressClock(1) ; White
        Case 3
          PressClock(2) ; Black
      EndSelect
    
  EndSelect
  
Until EventID=16

End
There's no time controls programmed into it at this point. Game in five minutes is what it sets itself to. There will be an infinite number of possibilities in setting it, with primary, secondary and tertiary time controls all selectable with your choice of moves for each time period.
For example, a common time control would be 40 moves in 2 hours followed by 20 moves in one hour followed by all remaining moves in one hour. Or, all moves in a given number of minutes, say 10 for each side or maybe 10 for one side and 5 for the stronger player. All I'm doing right now is getting feedback and identifying bugs. If you can try it out and help with that, it's much appreciated.

Here's the library:
http://www.lloydsplace.com/chessclock.dll
http://www.lloydsplace.com/chessclock.lib

Please let me know of any bugs or issues if you find them.
BERESHEIT
ebs
Enthusiast
Enthusiast
Posts: 561
Joined: Fri Apr 25, 2003 11:08 pm

Re: Game Clock DLL

Post by ebs »

netmaestro,

Very nice! I found one thing: Running PB 5.11 on Windows XP, I get this error when closing the window:

---------------------------
Purebasic13.exe - Application Error
---------------------------
The instruction at "0x100030f5" referenced memory at "0x0103ef18". The memory could not be "read".


Click on OK to terminate the program
---------------------------
OK
---------------------------

Regards,
Eric
buddymatkona
Enthusiast
Enthusiast
Posts: 252
Joined: Mon Aug 16, 2010 4:29 am

Re: Game Clock DLL

Post by buddymatkona »

It works great with Win7/64 5.11 (PB x86 only). :)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Game Clock DLL

Post by davido »

netmaestro: Is this only for x86.

It gives errors on my W7-64 PB511-64 system:

POLINK: error: Unresolved external symbol 'CreateGameClock'.
POLINK: error: Unresolved external symbol 'PressClock'.
POLINK: falal error: 2 unresolved externals().


1st edit:
buddymatkona: Thank you for your reply. Now I know!
DE AA EB
citystate
Enthusiast
Enthusiast
Posts: 638
Joined: Sun Feb 12, 2006 10:06 pm

Re: Game Clock DLL

Post by citystate »

if it was compiled under x86, it will only work with x86

any chance of a recompile for 64, nm?
there is no sig, only zuul (and the following disclaimer)

WARNING: may be talking out of his hat
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Game Clock DLL

Post by netmaestro »

Another upload will come tomorrow. I'll implement a CloseGameClock function to see if that helps with the ima on closing the window and I will also include a version targeting 64bit.
BERESHEIT
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Game Clock DLL

Post by Kwai chang caine »

No world to say ..... nearly i can touch it :shock:
Thanks a lot NetMaster 8)
ImageThe happiness is a road...
Not a destination
Nituvious
Addict
Addict
Posts: 1029
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Game Clock DLL

Post by Nituvious »

I don't think this is correct...
It says it took me over 24 hours to solve my rubiks cube but when I looked out my window the sun was still shining!

Nice work, net! :P
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply