1. Where dose the code go?
- Posted by "A.R.S. Alvin Koffman" <ka9qlq at HOTMAIL.COM> Jul 18, 2000
- 401 views
------=_NextPart_000_0025_01BFF0ED.9E1ED780 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I spliced two of Dave Coney's winlib examples and got this working then = it dawned on me. WHERE DO YOU PUT THE $#@*! CODE TO DO STUFF WITH!!!!!! = Dang you jump from DOS out the Windows, and your in a different world, = even with Dave's winlib. That dice game I cobbled up in May and posted = for review in June was clunky but it worked, this I don't know. I did = the dice game with BASIC experience that's ten years old (code = something, try it, add more). Crude true but it worked. Sorry to blab, = but had to get it off my chest (wheeeezzzzz). I'm going to read Dave's = connect 4 code and hope a light comes on. -- A simple Windows dice game include win32lib.ew without warning =20 constant WinDice =3D create( Window, "Win Dice!", 0, Default, Default, 400, 200, 0 ) -- create a control in the window constant Throw_Button =3D create( PushButton, "&Throw Dice", WinDice, 100, 30, 80, 40, 0 ) -- action to take when the window opens global procedure onPaint_WinDice( integer x1, integer y1, integer x2, = integer y2 ) wPuts( WinDice, "WinDice Version 1.0 Click the Throw dice button to = play" ) end procedure =20 -- tell Windows when to do the action onPaint[WinDice] =3D routine_id( "onPaint_WinDice" ) =20 -- hand control over to Windows WinMain( WinDice, Normal ) http://ka9qlq.tripod.com/ ------=_NextPart_000_0025_01BFF0ED.9E1ED780 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2614.3401" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#a8c8f0> <DIV><FONT face=3DArial size=3D2>I spliced two of Dave Coney's winlib = examples and=20 got this working then it dawned on me. WHERE DO YOU PUT THE $#@*! CODE = TO DO=20 STUFF WITH!!!!!! Dang you jump from DOS out the Windows, and your in a = different=20 world, even with Dave's winlib. That dice game I cobbled up in May and = posted=20 for review in June was clunky but it worked, this I don't know. I did = the dice=20 game with BASIC experience that's ten years old (code something, try it, = add=20 more). Crude true but it worked. Sorry to blab, but had to get it off my = chest=20 (wheeeezzzzz). I'm going to read Dave's connect 4 code and hope a light = comes=20 on.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>-- A simple Windows dice = game</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>include win32lib.ew<BR>without=20 warning<BR> <BR>constant WinDice =3D<BR> = create(=20 Window, "Win Dice!", 0, Default, Default, 400, 200, 0 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- create a control in the = window<BR>constant=20 Throw_Button =3D<BR> create( PushButton, "&Throw = Dice",=20 WinDice, 100, 30, 80, 40, 0 )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2>-- action to take when the window = opens<BR>global=20 procedure onPaint_WinDice( integer x1, integer y1, integer x2, integer = y2=20 )<BR> wPuts( WinDice, "WinDice Version 1.0 Click the = Throw=20 dice button to play" )<BR>end procedure</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2> <BR>-- tell Windows when = to do the=20 action<BR> onPaint[WinDice] =3D routine_id( = "onPaint_WinDice"=20 )<BR> <BR>-- hand control over to = Windows<BR> =20 WinMain( WinDice, Normal )</FONT></DIV> <DIV> </DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2><A=20 ------=_NextPart_000_0025_01BFF0ED.9E1ED780--
2. Re: Where dose the code go?
- Posted by Brian Broker <bkb at CNW.COM> Jul 19, 2000
- 397 views
On Tue, 18 Jul 2000 19:23:13 -0500, A.R.S. Alvin Koffman wrote: >I spliced two of Dave Coney's winlib examples and got this working then it >dawned on me. WHERE DO YOU PUT THE $#@*! CODE TO DO STUFF WITH!!!!!! In windows programming, you write code to handle different events. For a dice game, you might have a button for rolling the dice. So that's where you might put most of your code. E.g. if you had a button 'RollBtn' then your code would go into a procedure 'onClick[RollBtn]'. Since you are a beginner to event-driven programming, you might want to take a look at the Win32Lib Tutor at http://www.king.igs.net/~wolfritz/tutor.htm -- Brian
3. Re: Where dose the code go?
- Posted by Dan B Moyer <DANMOYER at PRODIGY.NET> Jul 18, 2000
- 405 views
- Last edited Jul 19, 2000
Alvin, Here's an amended version of your program which might help. In general, code goes into procedures or functions, placed somewhere before the last main loop statement, and before the event handler which invokes them. Dan Moyer -- begin code -- A simple Windows dice game include win32lib.ew without warning ------------------------------------------ -- CONTROLS: constant WinDice = create( Window, "Win Dice!", 0, Default, Default, 400, 200, 0 ) -- create a control in the window constant Throw_Button = create( PushButton, "&Throw Dice", WinDice, 100, 30, 80, 40, 0 ) ---------------------------------------------- -- ACTIONS (things to do when initiating events occur): -- action to take when the window opens global procedure onPaint_WinDice( integer x1, integer y1, integer x2, integer y2 ) setPosition(WinDice,1,1) -- sets initial position for text wPuts( WinDice, "WinDice Version 1.0 Click the Throw dice button to play" ) end procedure -- action to take when roll dice button pressed: procedure RollDice() integer d1,d2 d1 = rand( 6 ) -- get dice values d2 = rand( 6 ) repaintWindow(WinDice) -- clears screen so new numbers don't overwrite old setPosition(WinDice,1,20) --sets position of first number wPrint(WinDice,d1) setPosition(WinDice,20,20)-- sets position of second number wPrint(WinDice,d2) end procedure ----------------------------------------------- -- EVENTS (tell Windows when to do an action & what action to do): onPaint[WinDice] = routine_id( "onPaint_WinDice" ) onClick[Throw_Button]=routine_id("RollDice") ----------------------------------------------- -- MAIN LOOP: -- hand control over to Windows WinMain( WinDice, Normal ) -- end code -----Original Message----- From: A.R.S. Alvin Koffman <ka9qlq at HOTMAIL.COM> To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU> Date: Tuesday, July 18, 2000 5:23 PM Subject: Where dose the code go? I spliced two of Dave Coney's winlib examples and got this working then it dawned on me. WHERE DO YOU PUT THE $#@*! CODE TO DO STUFF WITH!!!!!! Dang you jump from DOS out the Windows, and your in a different world, even with Dave's winlib. That dice game I cobbled up in May and posted for review in June was clunky but it worked, this I don't know. I did the dice game with BASIC experience that's ten years old (code something, try it, add more). Crude true but it worked. Sorry to blab, but had to get it off my chest (wheeeezzzzz). I'm going to read Dave's connect 4 code and hope a light comes on. -- A simple Windows dice game include win32lib.ew without warning constant WinDice = create( Window, "Win Dice!", 0, Default, Default, 400, 200, 0 ) -- create a control in the window constant Throw_Button = create( PushButton, "&Throw Dice", WinDice, 100, 30, 80, 40, 0 ) -- action to take when the window opens global procedure onPaint_WinDice( integer x1, integer y1, integer x2, integer y2 ) wPuts( WinDice, "WinDice Version 1.0 Click the Throw dice button to play" ) end procedure -- tell Windows when to do the action onPaint[WinDice] = routine_id( "onPaint_WinDice" ) -- hand control over to Windows WinMain( WinDice, Normal ) http://ka9qlq.tripod.com/
4. Re: Where dose the code go?
- Posted by "A.R.S. Alvin Koffman" <ka9qlq at HOTMAIL.COM> Jul 20, 2000
- 394 views
Thanks guys I'll keep trying.