Path: news.cs.au.dk!not-for-mail From: Erik Corry Newsgroups: comp.lang.beta Subject: Re: tron - X11 multi-player game (Long) Date: 4 Apr 2000 09:24:56 GMT Organization: =?ISO-8859-1?Q?Mj=F8lner?= Informatics ApS Lines: 119 Message-ID: <8cccd8$dr4l4$1@xinwen.cs.au.dk> References: NNTP-Posting-Host: amigo.cs.au.dk Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: xinwen.cs.au.dk 954840296 14520996 255.255.255.255 (4 Apr 2000 09:24:56 GMT) X-Complaints-To: news@cs.au.dk NNTP-Posting-Date: 4 Apr 2000 09:24:56 GMT User-Agent: tin/pre-1.4-980818 ("Laura") (UNIX) (IRIX64/6.5 (IP27)) Xref: news.cs.au.dk comp.lang.beta:12283 Alf-Ivar Holm wrote: > tron was written in C for X10. When winter crept up in '95 I grew bored > and decided to rewrite it, in Beta. Cool! > Having started to learn Beta, I was also anxious to try to do > something else than the usual stuff. Well, it was shockingly easy to > make something that worked, and it was more than fast enough too! The > only thing that took some time, was for me to add a GPL statement and > post it here ... Great. All development on BETA has now come to a stop while we 'test' your game :-). There was a problem in that if you held the turn keys down, the autorepeat would make you go around in circles and crash into yourself. Here's a patch that fixes it: diff -u -r1.1 tron.bet --- tron.bet 2000/04/03 14:53:02 1.1 +++ tron.bet 2000/04/04 08:45:45 @@ -240,14 +240,17 @@ dn: ^text; (* Display Name *) xd: @this(xtEnv).display; (* The X display (Not core.display!)*) db: ^bike; (* Bike *) + leftdown, rightdown, jumpdown: @boolean; eventHandler:: (# kp: @keyPress (# (* Handle key press *) do event.translate - (# left:: (# do db.turnLeft #); - right:: (# do db.turnRight #); + (# left:: + (# do (if not leftdown then db.turnLeft; true -> leftdown if) #); + right:: + (# do (if not rightdown then db.turnRight; true -> rightdown if) #); do (if kpch - //jumpKey then db.jump + //jumpKey then (if not jumpdown then db.jump; true -> jumpdown if) //speedKey then db.speedUp if); #); @@ -255,7 +258,12 @@ (* Handle key release *) kr: @keyRelease (# do event.translate - (# do (if kpch//speedKey then db.speedDown if) #); + (# left:: (# do 'keyrelease' -> putline; false -> leftdown #); + right:: (# do 'keyrelease' -> putline; false -> rightdown #); + do (if kpch + //jumpKey then false -> jumpdown; + //speedKey then db.speedDown + if) #); #); (* Init keyboard if human player *) init:: (# do (if db.type=types.human then kp.enable; kr.enable if) #);@@ -471,9 +479,10 @@ do current.move #); (* Move each running player *) ddTime->start; (* Restart Timer *) else (* One player left - the winner *) - bikeQ.find - (# predicate:: (# do (current.state=status.running)->value #) #) - ->winner[]; (if winner[]<>none then winner.win if); + none -> winner[]; + bikeQ.scan + (# do (if (current.state=status.running) then current[]->winner[] if) #); + (if winner[]<>none then winner.win if); true->main.commandBox.startButton.sensitive; false->main.commandBox.fastButton.sensitive; if); (That last part of the patch is a workaround for a thinko we have in the find method in BETA 5.0 and later. Without this fix you can't compile on the latest releases. The thinko will be fixed in the next release (if anyone is interested they can mail us now for a quick fix) but this works around it until then). This unfortunately needs a patch to xtenvbody.bet in order to switch on detectable autorepeats. X11 added this feature in X11R6, though they still default to the old broken behaviour of synthesising KeyRelease events when autorepeating. Should be harmless on old servers that don't support it. Here's the patch to $BETALIB/Xt/private/xtenvbody.bet: diff -u -r1.13 xtenvbody.bet --- xtenvbody.bet 1998/11/30 11:14:43 1.13 +++ xtenvbody.bet 2000/04/04 08:48:58 @@ -569,6 +569,11 @@ -- DisplayOpen: descriptor -- (# cl: @integer; + XkbSetDetectableAutoRepeat: external + (# display, detectable, supported, result: @integer; + enter (display, detectable, supported) + exit result + #); do (if displayString[]=NONE then DisplayError else @@ -584,6 +589,7 @@ (if private.theDisplay=0 then DisplayError else + (private.theDisplay, 1, 0) -> XkbSetDetectableAutoRepeat; applicationShellWidgetClass->cl; (THIS(xtenv).private.appname, @@THIS(xtenv).private.appclass.T[1], compile with 'beta xtenvbody.bet' logged in as a user that is allowed to write the files in your BETA installation. If you don't mind, since the game is GPL'ed and fun, we will include it on future BETA CD's and downloads in the 'demo' subdirectory. -- Erik Corry Mjølner Informatics ApS