{"id":6056,"date":"2011-02-07T22:09:57","date_gmt":"2011-02-07T22:09:57","guid":{"rendered":"http:\/\/16.563"},"modified":"2011-02-07T22:09:57","modified_gmt":"2011-02-07T22:09:57","slug":"bar-fight","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/labs\/2011\/02\/bar-fight\/","title":{"rendered":"Game On Spotlight: Bar Fight"},"content":{"rendered":"<p><em>Bar Fight was a finalist in the Game On 2010 competition that showcased the use of Web GL. This is a guest post by <a href=\"http:\/\/www.oliverbaker.org\">Oliver Baker<\/a> &#8211;  Studying for a double-major at UT Dallas &#8211; and his father, <a href=\"http:\/\/www.sjbaker.org\">Steve Baker<\/a> who works at Total Immersion Software.   Together, they are team who created <a href=\"http:\/\/www.tubagames.net\">BarFight<\/a>,  a Wild West game written using WebGL\/HTML5\/CSS3.<\/em><\/p>\n<h2>Who are <a href=\"http:\/\/www.tubagames.net\/\">TuBaGames<\/a>?<\/h2>\n<p>Well, we&#8217;re Steve and Oliver Baker &#8211; a father and son team from the UK,  now living and working in Texas.  We&#8217;re long-time 3D graphics  enthusiasts and amateur games writers.  Linux folk may remember <a href=\"http:\/\/tuxaqfh.sf.net\">Tux the  Penguin &#8211; A Quest for Herring<\/a> which we created  back in 1997 when Oliver was just 7 years old &#8211; it was the first ever 3D  game for Linux.  Back then graphics cards could draw just a few hundred  triangles and the artistic demands were minimal at best.  <a href=\"http:\/\/tuxkart.sf.net\">TuxKart<\/a> was a much better game &#8211; that came along in 1999  and was to be found on most Linux distro&#8217;s for years afterwards.  Fast-forward to August 2010; we&#8217;d been watching the progress of WebGL  and decided to try to write some online games using it.  Because we  intend to fund the web site using advertising revenue alone, we can&#8217;t  afford a massive server farm to host the games.  So we needed to come up  with games with low server demands.  Turn-based games fit the bill  quite well because the server code can sleep while players are deciding  what to do.  Thus was born &#8220;<a href=\"http:\/\/www.tubagames.net\/\">TuBaGames.net<\/a>&#8221; (TUrn BAsed GAMES for the  NET).  Our vision &#8211; though constantly subject to redirection &#8211; is that we will  have a large library of games, in which players can compete in, and are  ranked. The <a href=\"http:\/\/www.tubagames.net\">BarFight<\/a> serves as a lobby in which people can hang out and  let off some steam. We have some interesting ways of publicizing matches  and making high-ranked games the &#8220;must see attraction&#8221;; so stick around  and see how far TuBaGames will go.<\/p>\n<h2>Inspiration for the Saloon<\/h2>\n<p>The first thing to build for TuBaGames was a &#8220;lobby&#8221; area where players  could come together to chat, hang out, maybe buy and swap in-game items  and arrange matches.  We came up with the idea of having a virtual  bar-room, with tables where people could meet up in the virtual world  and drink virtual beer. <a href=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_0.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-medium wp-image-566\" src=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_0-300x144.png\" alt=\"\" width=\"300\" height=\"144\" \/><\/a> It was a small step from there to a Wild West  Saloon.  At about that time, we caught the announcement of the <a href=\"https:\/\/gaming.mozillalabs.com\/\">Mozilla GameOn  2010<\/a> contest &#8211; and decided that this would be a great way to get  publicity for the site.  Since all we had planned out was the Saloon, it  was natural to try to make this into a game and that&#8217;s how &#8220;<a href=\"http:\/\/www.tubagames.net\">BarFight<\/a>&#8221;  was born&#8230;a cosey chatroom &#8211; with extreme violence mixed in for fun!  <a href=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_1-300x144.png\" alt=\"\" width=\"300\" height=\"144\" class=\"alignright size-medium wp-image-571\" \/><\/a> In the process of finding concept art for Oliver to work with  (WikiCommons &#8211; we love you!) we realized that what we wanted wasn&#8217;t a  realistic saloon &#8211; but rather the kind you see in just about every  1940&#8217;s western &#8211; the kind where someone spills a drink on someone else &#8211;  and within about 10 seconds there are three dozen cowboys swinging  punches at each other and generally smashing up the place!  <\/p>\n<p><a href=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_2.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_2-300x144.png\" alt=\"\" width=\"300\" height=\"144\" class=\"alignleft size-medium wp-image-574\" \/><\/a> The bar  fight in Roy Rodger&#8217;s movie: &#8220;Rough Riders Roundup&#8221; (which is now out of  copyright) was the perfect inspiration.  The idea that our players are  just a bunch of &#8220;extras&#8221; in a Hollywood movie explains why nobody is  ever seriously hurt &#8211; and let&#8217;s us get away with some awful cliches.<\/p>\n<h2>The Work process and the Father\/Son thing<\/h2>\n<p>Since we live 180 miles apart &#8211; we use copious text messaging, email and  daily half-hour long phone calls.  We probably wind up communicating  more than most families who live in the same house!  We also have our  own private Wiki where we keep reference art, documentation and the  all-important &#8220;To Do List&#8221;.  We&#8217;ve taken to using &#8220;unison&#8221; to keep our  PC&#8217;s in sync with each others files and for updating the server.  We use  online tools for things like compiling the server and converting models  from Blender to JavaScript.  That infrastructure soaked up quite a bit  of development effort &#8211; but it proved utterly invaluable &#8211; well worth  the effort. It also allows to quickly expand our library of games in the  future.  Staying good friends through the process worked out OK &#8211; although we had  a few &#8216;tense moments&#8217; during the worst of the sleep-deprived crunch.   What&#8217;s remarkable is that Francoise (wife\/mother) and Tracy (girlfriend)  are still with us afterwards!  All credit goes to them!<\/p>\n<h2>Development<\/h2>\n<p>* Oliver (who is the artistic one) modeled the saloon, its inhabitants  and about 40 other props using Blender and GIMP, putting together over  50 separate animations and around 100 texture maps.<\/p>\n<p>* Steve (who is a dyed-in-the-wool code-head) set about writing a  WebGL-based renderer in JavaScript to draw it all, shader code in GLSL,  Python to export Blender models and a server in PHP and C++.  In all,  about 20,000 lines of code.<\/p>\n<p>* Reagan Smith (a friend of Oliver) recorded all of the voices for us &#8211;  he&#8217;s an absolute star!  We still have a ton of silly cowboy phrases to  work into the game&#8230;er&#8230;dag&#8217;nabbit!<\/p>\n<p>* The web site itself was more or less a joint effort in PHP, CSS3 and  HTML5 &#8211; using MySQL to store user preferences.  We like to be &#8220;light on our feet&#8221; and change plans as often as it makes  sense.  The original vision was to stay &#8220;turn-based&#8221; and to use an  orthographic perspective to allow you to see the entire bar room at a  single glance.  But on a whim one day in mid-December, we switched to an  &#8220;over the shoulder&#8221; camera view and were blown away with how good it  all looks like that &#8211; so now you can switch cameras to a variety of  different views.  If you grab some colored glasses, you can even go into  the &#8220;Options&#8221; menu and turn on stereographic 3D rendering.  The &#8220;turns&#8221;  in the turn-based system were gradually reduced from 20 seconds to 5  seconds &#8211; and eventually to 1 second.  It&#8217;s still really &#8220;turn based&#8221;  under the hood &#8211; but it looks more or less interactive to the end user.   <a href=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_31.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px-Publicity_31.png\" alt=\"\" width=\"914\" height=\"440\" class=\"aligncenter size-full wp-image-583\" \/><\/a>The control system is intended to help &#8220;casual&#8221; gamers &#8211; you can just  click on something or someone in the saloon &#8211; tell your guy what to do &#8211;  and then be free to do something else as he does it.  It&#8217;s definitely  not intended to be a &#8220;twitch response&#8221; kind of a thing. <\/p>\n<p>The software for rendering the cowboys and cowgals is really complex &#8211;  and probably the most sophisticated piece of &#8220;tech&#8221; in the game.  We  only have three blender models &#8211; one for all of the cowboys, one for the  cowgirls and another for the dancers.  Because JavaScript is pretty  slow, the whole business of switching clothing, texture and color is  handled inside the GPU.  The &#8220;Wardrobe department&#8221; lets players  customize their characters.  Animation uses &#8220;skeletal meshes&#8221; &#8211; Oliver  uses blender to describe how the &#8220;bones&#8221; move and the position of each  bone is stored for every 24th of a second of animation.  Steve&#8217;s shader  uses the bone structure to position the vertices of the &#8220;skin&#8221;.  There  are 30 bones for each character &#8211; including some special ones such as  the &#8220;skirt bones&#8221; for the dancers and a &#8220;revolver bone&#8221; for the players.  <\/p>\n<p>As relative newbies at web development, we faced a bunch of struggles  and setbacks &#8211; not least because we were initially working with  decidedly flaky daily builds of Firefox 4 and Chrome &#8220;Canary&#8221;.  It&#8217;s  been a continual problem to know which problems were of our own making &#8211;  and which were &#8220;Browser-induced&#8221; &#8211; especially because we wanted the  game to work in both Linux and Windows and with both Chrome and Firefox.   Another incredibly tough issue was figuring out how Blender stores  skeletal mesh animations &#8211; that cost close to a month of coding time!   HTML5 audio has been another area of considerable difficulty.  On the plus side, we found ourselves relying more and more on HTML5 and  CSS3 &#8211; our original menu system was rendered in WebGL &#8211; but when we  discovered downloadable fonts in CSS3, that whole business became a lot  easier.  The WebGL team at Khronos, Apple, Mozilla and Google were of  tremendous help when we found bugs &#8211; they were often able to turn out  bug fixes in less than a day! WebGL exceeded our expectations in most  regards &#8211; we even managed to squeak in an optional dynamic shadow  renderer.  <\/p>\n<p>Work really kicked into high gear over the Xmas break &#8211; we both crunched  18 hour days with far too little sleep trying to get it all done by the  Jan 11th cut-off.  As with any game in production, ambitions begin sky-high, and you just  KNOW you&#8217;ve created the most revolutionary game since Pong, but  inevitably things get cut (though a surprising portion of ideas stayed  into the BarFight game) and with a tight deadline, things get pushed  over to the next deadline, and it&#8217;s near impossible for developers to be  satisfied with their final product. That said &#8211; we are very proud of  our game, and we will even get a chance to improve upon it, and polish  it even more!<br \/>\n<a href=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px_Publicity_4.png\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/mozillalabs.com\/gaming\/files\/2011\/02\/800px_Publicity_4.png\" alt=\"\" width=\"914\" height=\"440\" class=\"aligncenter size-full wp-image-585\" \/><\/a><br \/>\n(A great feature of web based games &#8211; no set delivery  date, and all people need to do to download a patch is to &#8220;Reload&#8221;) Our  main focus at this point though, is to move on to making tons more  games!  You can find out much more about the development process at our <a href=\"http:\/\/tubagames-barfight.net\/colophon.php\">Colophon page<\/a>.<\/p>\n<h2>Gags, Easter Eggs, In Jokes<\/h2>\n<p>To the left of the screen is the &#8220;RowdyMeter&#8221; &#8211; if players can make  enough mayhem, a bunch of dancing girls appear and dance the Can-Can for  you!  There are numerous references to our buddy, Tux the Penguin &#8211; and  if you zoom into the beer bottles, you&#8217;ll see what the beer is made of!   For those more engrossed into the graphics world might enjoy some of  the paintings as well! (Not just the one above the bar either!)  Several  of the non-player characters have names that show up when you  mouse-over them &#8211; check them out on Wikipedia &#8211; you may be surprised at  what you find!<\/p>\n<h2>What&#8217;s Next?<\/h2>\n<p>Well, catching up on sleep is high on the priority list still!  We still  have work to get BarFight utterly done &#8211; get the kinks out &#8211; learn  lessons from the people who played it.  Because it&#8217;s still going to  become the &#8220;lobby&#8221; for our game site, we have to do some restructuring  yet.  Beyond that, there is always &#8220;The Next Game&#8221; &#8211; we&#8217;re thinking about  sailing ships &#8211; pirates maybe.  We&#8217;re also in discussion with a local  rock band about doing a large scale sci-fi land-combat game based around  their themes&#8230;in exchange for some really cool sound tracks and mutual  publicity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bar Fight was a finalist in the Game On 2010 competition that showcased the use of Web GL. This is a guest post by Oliver Baker &#8211; Studying for a double-major at UT Dallas &#8211; and his father, Steve Baker &hellip; <a class=\"go\" href=\"https:\/\/blog.mozilla.org\/labs\/2011\/02\/bar-fight\/\">Continue reading<\/a><\/p>\n","protected":false},"author":1438,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20250,254,19292,19433],"tags":[19518,19520,19599],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/6056"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/users\/1438"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/comments?post=6056"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/posts\/6056\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/media?parent=6056"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/categories?post=6056"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/labs\/wp-json\/wp\/v2\/tags?post=6056"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}