8bitrocket.com
12May/133

Happy Mother’s Day

I entered (and won) a local writing contest for Mother's Day with the following story about my mom.    When she saw it today, she had no idea I even remembered what happened in 1975, much less would write about it.  I think I blew her mind.

-8bitsteve


beachreporter2013_small

9May/130

Coding By Google – AS3 to PHP with Simple MYSQL DB Query and Data Return Tutorial (Free Code)

By Jeff Fulton (@8bitrocket on twitter)

Coding By Google - AS3 to PHP with Simple MYSQL DB Query and Data Return Tutorial (Free Code)

Here at Producto Studios, I use Google to look up code all day long.  Yes, I have written books on Javascript, Flash, Actionscript, and HTML5, but I still find myself looking stuff up all the time. There just is too much to know when trying to fulfill the requirements of a project.

So, a few days ago a needed to Call a PHP script from AS3, hit MySql,  and return back some data.  Nothing fancy, but not something I have not done in a while (since my Zynga days). I used a couple different resources to cobble together the code, but not any one that had everything I needed.  so I thought in the sense a fairness in sharing,  I would present this basic version (that could probably be much more secure, etc) in case anyone needed a starter in how to accomplish this task.

The PHP

I am by no means a PHP superstar.  I grew up on Perl, moved to vbscript, then to .net, then hid from server side coding until I had to learn a little PHP a couple years back. I think it is an excellent language though and use it as often as I can.

Our example is going to accept in an email address, check to make sure it is a valid email (hopefully this will solve most SQL injection problems, but if there is a better way, please let me know).  It will then look up a user in the MySQL Database with the email address. If the user exists, it will pass back the first and last name of the user.  Since this is pure PHP, any script, even JQUERY could call it and use it.  For this example though, Flash AS3 is going to be the m method used.

The Server Side PHP Script

You will have to provide your own database IP address or DNS name, along with the user, pass and db name.

  1. <?php
  2. $email = $_REQUEST['email'];
  3. $returnString="retval=";
  4. if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
  5.    $mysqli= new mysqli("xxx.xxx.xxx.xxx", "user", "pass", "db");
  6.    $sql="SELECT *FROM `user` WHERE email = '".$email."'";
  7.    $res=mysqli_query($mysqli, $sql);
  8.    if ($res) {
  9.       while ($newArray=mysqli_fetch_array($res, MYSQLI_ASSOC)) {
  10.       $first = $newArray['first'];
  11.       $last = $newArray['last'];
  12.       $returnString=$returnString."&first=".$first."&last=".$last;
  13.    }
  14.    echo $returnString;
  15. }
  16.    mysqli_free_result($res);
  17.    mysqli_close($mysqli);
  18. }else{
  19.    echo $returnString;
  20. }
  21. ?>

The Client Side Actionscript

This is the AS3 version of the script used to call the PHP.

 

  1. package {
  2.   import flash.events.*;
  3.   import flash.net.URLLoader;
  4.   import flash.net.URLRequest;
  5.   import flash.net.URLVariables;
  6.   import flash.net.URLLoaderDataFormat;
  7.   import flash.net.URLRequestMethod;
  8.   import flash.display.MovieClip;
  9.   public class Main extends MovieClip{
  10.     private var EMAIL_REGEX: RegExp = /^[A-Z0-9._%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,4}$/i;
  11.     private var formattedEmailAddress:String;
  12.     public function Main() {
  13.       trace("test as3 to php to mysql and back");
  14.       var email="Teff@Test.com";
  15.       formattedEmailAddress=email.toLowerCase();
  16.       if (formattedEmailAddress.match(EMAIL_REGEX)) {
  17.         trace("good email address format");
  18.         trace("checking database for email address...");
  19.         checkDbForEmail();
  20.       }else{
  21.         trace("bad email address format");
  22.       }
  23.     }
  24.     private function checkDbForEmail():void {
  25.       var url="http://addresstoyourserver/doesemailexist_tutorial.php";
  26.       var loader : URLLoader = new URLLoader;
  27.       var urlreq:URLRequest = new URLRequest(url);
  28.       var urlvars: URLVariables = new URLVariables;
  29.       loader.dataFormat = URLLoaderDataFormat.VARIABLES;
  30.       urlreq.method = URLRequestMethod.POST;
  31.       urlvars.email = formattedEmailAddress;
  32.       urlreq.data = urlvars;
  33.        loader.addEventListener(Event.COMPLETE, completed);
  34.       trace("calling loader");
  35.       loader.load(urlreq);
  36.     }
  37.     private function completed(event:Event): void{
  38.       trace("php event") ;
  39.       var loader2: URLLoader = URLLoader(event.target);
  40.       trace("first=", loader2.data.first);
  41.       var firstname:String=loader2.data.first;
  42.       var lastname:String=loader2.data.last;
  43.       if (firstname == null || firstname =="") {
  44.         trace("Sorry, that email does not exist in our database");
  45.       }else{
  46.        trace("user exists");
  47.       }
  48.     }
  49.   }
  50. }

That's all there is to it. I'm not christening this as the only or the best way to accoimplish this task, just one way that works and is moderately secure.  If you have a better way, please sent it over and I'll credit you and post your additions and comments.

Jeff Fulton is the Chief Technology Officer at Producto Studios, and co-author of The Essential Guide To Flash Games,as well as The HTML5 Canvas 1st and 2nd editions.
He can be reached at info[at]8bitrocket.com and at the @8bitrocket twitter address.

7May/130

HTML5 Canvas Book Example Files

HTML5 Canvas Book Example Files

Just in case these are not just available yet on the O'Reilly Site

http://www.8bitrocket.com/html5canvas/2nd_edition_examples_2_4_8_9_10.zip

http://www.8bitrocket.com/html5canvas/2nd_edition_examples_1_3_5_6_7_11.zip

6May/131

Random Game Idea : A Twitter Feed To Spark Your Imagination

Over the weekend we were playing with Twitter Bots (why? Because.) and we created a Twitter account named @randomgameidea with a Twitter bot that tweets a randomized game idea every hour.  These ideas are completely random.  The bot uses an updated set of data that was once housed in our GameStorm idea generator.    Also, if you tweet anything to @randomgameidea, it will respond with an idea just for you.  There are literally, trillions of possible combinations.  Most are useless, but...

 

Screen Shot 2013-05-06 at 11.24.27 AM

4May/130

ATASCII Tile Sheets

ATASCII Tile Sheets

So, I have been knocking around the idea of making some games that mimic the old Atari computer aesthetic in both graphics and sounds.  These games will just be for fun and they will probably be just game starters - single level game to demonstrate or duplicate a game type.  It might be a retro game or even a new style game, but being a complete and total Atari 800 nerd, I thought it would be fun to make the games look like they were built to run on the old Atari 8-bit computers.

I have not yet started the scrolling shooter that was going to be my first game (will it be in Flash, HTML5, Corona, or something else), but to get my creative ideas flowing, I decided to try and find some Atascii tables on the internet (I did, at http://joyfulcoder.net/atascii/) and turn them into 3 png tile sheets:  an 8x8, a 16x16, and a 32 x 32 set of the full 256 characters (including inverse video).  I thought it would be fun to make games using these.   I figured that I would share them with anyone who wanted to use them.

atascii_tilesheet8x8

atascii_tilesheet8x8

 

atascii_tilesheet16x16

atascii_tilesheet16x16

 

atascii_tilesheet32x32

atascii_tilesheet32x32

To make it interesting, the first person who uses these tiles (go ahead and be creative and color them any way you like) to make a decent version of Star Castle (in any language you prefer, as long as I can play it on my PC (browser or not) will get a complimentary signed copy of the new version of our book. I only have a single copy to give away though. This is NOT a contest or any type.  I just want to encourage creativity in any way I can.

HTML5 Canvas 2nd Edition

HTML5 Canvas 2nd Edition

 

3May/130

In Celebration of Day Against DRM (Fri, May 3, 2013) 5000+ titles 1/2 off including HTML5 Canvas 2nd Edition

HTML5 Canvas 2nd Edition

HTML5 Canvas 2nd Edition

              In Celebration of *Day *Against DRM

Save 50% on 5000+ Ebooks & Videos

(Save 60% on orders over $100)

Having the ability to download files at your convenience,

store them on all your devices, or share them with a friend

or colleague as you would a print book is liberating, and is

how it should be. This is a critical moment in the fight against

DRM. A proposal currently being considered by the W3C would

weave DRM into HTML5 — in other words, into the very fabric of

the Web.

 

This includes the latest edition of our book, the just released HTML5 Canvas 2nd Edition.

 

Ebooks from oreilly.com are DRM-free. You get free lifetime access, multiple file formats, free updates.

Use discount code: DRM2013 - Deal expires May 3, 2012 at

11:59pm PT and cannot be combined with other offers.

24Apr/130

The HTML5 Canvas Second Edition Has Been Released (Deal of the Day, 50% off)

HTML5 Canvas 2nd Edition

HTML5 Canvas 2nd Edition

 

The Second Edition (so the 3rd book) I have written with my brother Steve, The HTML5 Canvas was released today by O'Reilly. If you are interested in this wildly popular subject (for tech heads), you can get the E-Book edition for 1/2 off by using the code DEAL on the Publisher Web Site (It's the DEAL of the day).

http://shop.oreilly.com/product/0636920026266.do?code=DEAL&imm_mid=0a68f1&cmp=em-code-books-videos-deal-day-html5-canvas

This edition has added and changed over 50% of the original First edition. We have added A LOT of game related topics (as we do in everything we create). These include pixel perfect collision detection, Box2D Physics, A* Path Finding, targeting mobile browsers with full screen scalable content, and much much more. Every chapter has been re-written with additional content added and less popular or redundant content removed.

There are print editions available also at all major book retailers.

17Apr/130

The Run Cycle – Boston Thoughts

The Run Cycle

The Run Cycle

I was thinking about this while driving in this morning (I just saw that Colbert said something similar last night, but not exactly, so I'll say it now).
I am a runner, and I am constantly injuring myself just because I love the joy and freedom of sport. But, no matter how much training I have done, or how many injuries I have suffered, I always get back up, buy a new pair of shoes and keep going. But, this post isn't about me, this is just the preamble. You see, someone tried to murder runners, their fans, and families this last Monday at the premier running event in the world. That was a HUGE mistake. Of course it has made me sick all week to hear the stories of loss, but also rejuvenated to hear the stores of heroes.

Now to the real points, directed at the person or persons responsible for this crime. Here are 3 things you probably don't understand and will never understand.

1. Marathoner Runners do it for the love of the sport. These are people who run 19-21 miles as their last long run 2 weeks BEFORE a marathon. There are no crowds, no cheering sections, no tables filled with drinks and post race food. There is just them (and if they are lucky a partner) and the road. There is no medal for training for a race, or training in general, they do it because they love it. They are unshakable in that love of the freedom and personal accomplishment. If they are really good and really lucky they might qualify for the Boston Marathon. That's an important point. leading to the next one.
2. Every runner in the Boston Marathon was an elite runner in his or her age group and had to win a lottery just to get in. These are not people who will be shaken by adversity. Most of them have 10 black toes, no toe nails, with legs, ankles, knees, quads, taped up and sometimes just held together with the minimum of original tissue - just so they can run 26 miles repeatedly.
3. Bostonians, probably the toughest group of citizens on the planet (save Philadelphia and New York) came out in droves to watch others run this grueling race, and they will continue to do so.

So my point is, while you tragically maimed and killed over 100 people you will never ever shake these groups of people. They are all heroes and all winners because what they do is out of pure love. What you did was out of pure hate. We all know how that story ends. So I'll end mine right here...

6Apr/131

Comprehensive List of Lucas Arts Titles Released for Classic Atari Machines

By Jeff Fulton (@8bitrocket on twitter)

To the majority of the public, Atari died in 1983 and is relegated to hipster t-shirts and trucker hats with ironic joysticks on them.  While 90% of the USA and 70% of the UK gamers were playing with their C-64's, Nintendo's, Spectrums, Amigas, and the like, there were a large number of game players who stuck by the various Atari incarnations and their machines of varying quality.  The first Lucas Arts games were actually made as a partnership between Atari and Lucas to create the most advanced games possible for the Atari 8-bit machines (800XL computer  and 5200 console). If you read thorough (the otherwise fantastic) Retro Gamer magazine you would be hard-pressed to even know  that Atari existed after 1984. The Magazine has the Amiga, Speccy and c=64 so far up its butt (in a nice way) that incredible titles released for the Atari 7800, ST, Lynx, 2600, Atari-8bit and even the Jaguar are relegated to the "Spinal Tap Where are they now  radio ads". To help rectify this injustice slightly, I have compiled a list of the Lucas Arts titles released for the Classic Atari Machines (actually there are no non-classic machines other than the Flashback consoles).

Their Finest Hour - ST Action Magazine

Their Finest Hour - ST Action Magazine

 

Atari 8-bit Computers (Most released by Epyx, produced by Lucasfilm Games
BallBlazer

The Eidolon

Koronis Rift

Rescue on Fractalus!

Atari 5200 (Releases by Atari, developed by Lucasfilm games)

Ballblazer

Rescue on Fractalus!

Atari 7800 (Released by Atari)

Ballblazer

Atari ST Computers (Developed  or Published by Lucasfilm/Lucas Arts Games)

Battlehawks 1942

Indiana Jones and the Fate of Atlantis

Indiana Jones and the Last Crusade - The Action Game

Indiana Jones and the Last Crusade - The Graphic Adventure (SCUMM engine)

Loom

Manic Mansion

Night Shift

Pipe Dream

The Secret of Monkey Island

Their Finest Hour - The Battle of Britain

Zak McKracken and the Alien Mindbenders

Yes, there were many more titles released for the Amiga and C=64, but it seems like the Atari computer titles are always relegated to "Oh yeah, there might have been other versions also". If they name the ST version at all, it is usually with a disparaging remark like "The Amiga 500 version was nothing more then an ST port", never actually talking about the quality of the ST games. In fact, in most instances I will see a game comparison in a magazine (looking at you Retro Gamer) where it will show a 3 color ugly screen of blobs (Speccy version)  along with a colorful ST version and seemingly the Speccy version is always called out for being the better port.  There is so much Atari ST and Atari 8-bit computer hate and indifference out there in the magazine and on-line world that it sometimes makes me ill just to read retro reviews or publications.  Yes, the Amiga was an awesome machine, but the ST certainly was no slouch in the game department.  We happily played our original 1040 ST from 1987 all the way through 1993, when we finally had to get a PC for work reasons.  Even then, there was no game as good as an ST game on the 386DX40 until Wolf3d came out.

 

 

 

Filed under: Uncategorized 1 Comment
19Mar/130

Corona: Updating Mobile Game Content in Runtime

The Corona Labs Blog

The Corona Labs Blog

The Corona Labs Site has put up a tutorial I wrote on the basics of updating mobile content at run-time:

Updating Mobile Game Content in Runtime

Here is a brief summary:

green_tanks

We take the green tank tile sheet. And use it to place and animation on the screen:

figure1

Next we use ad XML file and the network.download() function in Corona to update the tile sheet to a new version when content has been updated:

<data>
<lastupdate>20130401</lastupdate>
<tilesheet>blue_tanks.png</tilesheet>
</data>

blue_tanks

This updates the tile sheet in the app:

figure2

All of the detail, code, and example files are on the Corona Labs Blog

 

This site is protected by Comment SPAM Wiper.