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

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...

1Jan/130

Don’t be afraid of Windows 8 Desktop

This (Windows 8 has problems, but it doesn’t deserve the dreaded Vista comparison)says that Windows 8 is only good for touch screens.

Windows 8 Desktop

Windows 8 Desktop

 

He is wrong. Windows 8 is just Windows 7 with new "window" dressing and a few new good features. The backup and app search are 10X better than Windows 7 [Start] menu or (especially) OS X Finder.

Windows 8 Search

Windows 8 Search

If you need to old Win 7 desktop, just click on the giant DESKTOP button.

Windows 8 Desktop

Windows 8 Desktop

 

You will be right back to familiar territory. There is nothing to fear from Windows 8, except time wasted playing with the new free (or low cost) games and apps from the Windows 8 store.

Wordamint

Wordamint

They are easy to build also, as the HTML5 Canvas (we tested all of our book's apps with in) can easily be compiled into Windows Store Apps. This gives you the ability to port all of the older Flash, Android, or iOS games that you want to port to a new platform.

26Dec/120

The Run Cycle – Running Sick After Christmas

The Literal Run Cycle - Running Sick After Christmas

The Run Cycle

The Run Cycle

The Day After Christmas Run is never an easy one. This year it was especially difficult because I have been battling a nasty sinus infection over the last week or so and I have not run for 10 days (and only 2 times in 4 months before that).  I have not been completely idle over those 10 days, having done a few difficult classes at the gym, but I have not run during that time. NOTHING has the same effect on my body than a run does.

So, today I took my tired, infection and Christmas treat weakened body to the local track just to get the legs moving for a few miles and to hopefully burn off some of the avalanche of tasty, but  terrible for me,  food I have been ingesting over the last week. Overall it was a success.  I did 5 miles, running (jogging really) 90% of the distance and stopped in the middle to do a few burpees, v-ups,  and pull-ups.  I can't say it was absolutely the easiest workout I have ever done, but the 5 months ago version of me would have considered in barley a workout at all.

My foot is still recovering from surgery, but I didn't have any pain from the running or the burpees.  Afterward it swelled up a bit and the incision/infection point was a little sore, but all in all, it seems to feel 80-90% healed, even if it doesn't look it.

12-26-12 Run Foot

12-26-12 Run Foot

Again, I ran in my Saucony Kinvara 3's. They are my favorite shoe at the moment, and they are stuffed with an extra thick custom insole from Road Runner.  My feet feel fine, and I  don't have any pain in the bottom of either foot, so, I win! Bonus =).

My sickness - I have been battling a nasty upper-respiratory infection that took me out of commission for a couple days completely, but even though it has not subsided completely I figured I would test out my lung fitness a little.  I did not have any ill effects from the run, but I did take an inhaler along that I used one time during the run. The wind was out in force today, and so my allergies were kicked up in full swing.   Even with all of that against me, it seems like the actual run was a success and I didn't make myself any worse than I was, in fact, it might have actually helped me as now, 3 hours later,I feel better than I did before I started and might even be able to make it to the double circuit / spin 2 hour class that I sometimes go to on Thursday mornings.

That's not to say that I fetl 100%.  Here is a picture of the old tired version of me from right after I finished the run, just then realizing tat I left my mixed bottle of Recoverite at home and would have to wait another 10 minutes before I could get my paws on it.

12-26-12 Run Tired

12-26-12 Run Tired

So, what does this have to do with gaming or 8bitrocket, Producto, Atari, development, etc?I don't have any pithy juxtapositions on running through code bugs and running through sickness (although, now that I mention it, that would be an interesting one for next time).

I have not been working since Friday, but there is some news to report on that front.    First, Steve and I finished all of the first draft chapter revisions for the second edition of our HTML5 Canvas book.  Second, I received an iCade (Thanks, Jeanne!) for Christmas, so I can play all of the Atari, Vectrex, Activision, and Namco classic games I want (and can afford) with arcade-like controls using the iPad.  Third, I started Business is Fun, the Atari history book (like a "Peoples History of Atari") by Marty Goldberg and Curt Vendel.  A full review will show up here some time soon.

Happy coding and running to you all. (or what ever you do that makes you both angry and happy at the same time).

17Dec/120

The Literal Run Cycle #1

Jeff Fulton (8bitjeff)

This is a blog that usually deals with game design / programming, retro-gaming and other nostalgia.   It is not a fitness blog by any means, but since running and overall fitness is a big part of what keeps me going on a daily basis, I wanted to start what I hope will be more of an inspirational look at what the life of an avid, but amateur 42 year old runner is like.  Right now, I am actually starting over.  Literally, starting from ground zero with my running.  I had foot surgery on October 4th, 2012 and did not run at all the month before the surgery. I have only started jogging again, doing 5 easy miles 1 or 2 times a week. By easy I mean EASY. I actually walk part of each mile and jog the rest and then repeat.  To keep my overall fitness up, I also workout most days of the week, but take at least one rest day to recover.  When I could not run, I would walk fast, do the spin bike or the elliptical, and take weight and circuit training classes or see a personal trainer.   Because of this, I have been able to ease myself back into jogging without too much difficultly. My heart rate is really good during the jogging portions and it drops dramatically during the walk intervals. I owe all of that to the trainers and equipment at the Beach Cities Health District Center for Health and Fitness as well as the well trained staff at the Beach Cities Orthopedics Physical Therapy (not related to one another).

So, as  I would like to figure out a way to relate this series of blog entries to  the rest of my life and work, I am calling it the "The Run Cycle".  Anyone who has had to do animation of any type knows what a walk or run cycle is. It is a series of drawn frames that when played in succession simulate to the eye a natural walk or run style movement for a character.   For a recent project I needed a place-holder for a "run cycle" before the animators created one, so I "borrowed" and cleaned up a set of images I found on the internet.  We would never use someone else's work for production, but while in development, I needed something to show the animators what I wanted to accomplish.  Here is the "run cycle" that I provided to them as a base.

Run Cycle

Run Cycle

I actually added the Saucony Kinvara 3's to each frame just for these frames just for this series of blog entries. Saucony is my favorite brand of running / racing shoe. I don't see that many people out there with them, so they are unique and always have the coolest designs. That's what's really important, right, that you look cool while injuring yourself running? Anyway, I chose the Kinvara 2 because it was light weight, but sturdy and flexible. I also combine my shoes with the thickest Road Runner Sports created custom insoles to ensure my feet are as protected as they can be. The new Kinvara's 3's feel like you are running on air and are so light that I hardly notice that they are even on. Enough ad-man slinging for them. They are not paying me for this, but I just wanted to make sure that the bases were covered.

Here is my current pair though, and nestled inside is that thick, comfy Road Runner custom insole:

Kinvara3

Kinvara3

The game should be in the iOS store some time soon, and obviously, the real one will not use this run cycle, but I like it enough to use it as the logo for this series of blog entries.

So, does the world really need another amateur running blog? No, not really. I am pretty sure there are far too many out there now, and obviously, most people want to read what the experts do, but who knows. Since I am starting at ground zero, maybe I can inspire someone else to get out there, especially someone (like me) who spends most of their time behind a desk all day long.

So, about my most recent run. Yesterday morning, I took off on a wood-chip trail run in Manhattan Beach, but needed to derail to the harder concrete strand when I hit a part of the trail that is being repaired. Here is a map and basic Garmin summary details from this moderate training session:

run-12-16-summary

run-12-16-summary

12-16-run Map

12-16-run Map

To compare this to my pre-surgery runs, on a "long run day", or even a moderate run day, my average mile pace would be around 8:00 - 9:00 minutes with some a little faster. Right now, with the walking and jogging, I am at about 12:28. I am not pushing it and really not too tired when I finish, so my fitness it still pretty good. Here is a picture of my current left foot. It has not completely healed, so I am being cautious with it.

Toe 12-16

Toe 12-16

My next run is this Wednesday on an all-weather track. I will be doing the same basic format: Walk the first 1/4 or every mile and then jog the next 3/4. Between then and now I have a personal training session that will help keep my body in good working order for when I hit the track.

We also have the launch of our new game into the Apple store, and I am trying to complete the final chapter of the second edition of a the HTML5 Canvas book I am working on with Steve (8bitsteve), my brother. Sometimes it is hard to fit it all in.

One last thing. Let's not forget the names of the 20 little ones and 6 care givers who bravely tried to keep them safe last Friday:
CHARLOTTE, DANIEL, RACHEL, OLIVIA, JOSEPHINE, ANA, DYLAN, DAWN, MADELEINE, CATHERINE, CHASE, JESSE, JAMES, GRACE, ANNE MARIE, EMILIE, JACK, NOAH, CAROLINE, JESSICA, AVIELLE, LAUREN, MARY, VICTORIA, BENJAMIN, ALLISON. May they rest in peace and their sacrifice help make some changes to the current state of affairs in the USA.

16Dec/120

Friday was a Tough Day for a Deadline, but HTML5 Canvas 2nd Edition Is Nearly Complete

By Jeff Fulton (8bitjeff)

Tough Day for a Deadline, but HTML5 Canvas 2nd Edition Is Nearly Complete

There will be no Atari video game retrospectives this weekend on 8bitrocket. Far too many little ones will not get to experience their own version of the same thing, never have a chance to write about it some day, and never have the joy of spending another holiday season with their families. Our hearts are broken here at 8bitrocket towers. For a site dedicated to things we loved as children and exploring how to re-visit and re-create those memories in many different ways, we just can't celebrate anything like that right now. What we have is work though, and as anyone who is trying to make it without any corporate backing knows, work MUST go on, no matter what happens, or food doesn't make it on the table, health insurance premiums are not paid for, car loans and housing payments go un-paid and life just kind of stops and spins like a proverbial hamster on a habitrail.

First, here is a list of the first names of all the brave little ones and their hero protectors that didn't make it out safely.
I can't fathom the evil that would do such a thing:

CHARLOTTE, DANIEL, RACHEL, OLIVIA, JOSEPHINE, ANA, DYLAN, DAWN, MADELEINE, CATHERINE, CHASE, JESSE, JAMES, GRACE, ANNE MARIE, EMILIE, JACK, NOAH, CAROLINE, JESSICA, AVIELLE, LAUREN, MARY, VICTORIA, BENJAMIN, ALLISON

So, with a heavy heart and tears welling up, I crashed through some technical barriers I was experiencing and finally completed chapter 9 of the Second Edition of our HTML5 Canvas book for O'Reilly.

All of the chapters have been updated, revised, and re-written to add new content and replace out-dated or incomplete ideas that simply were not possible on the Canvas when we started on this project 2 and 1/2 years ago. My major focus has been adding in more game development content to the various chapters (especially the two game specific chapters) to have a more complete reference guide for the budding and experienced HTML5 Canvas game developers. Not that the first edition was limited in scope at all, but there was no time or space to cover some subjects that we really wanted to cover, and some that were impossible until this point. I have been working on chapters 8 and 9 (Game Essentials 1 and 2) for the last few months, shoring them up to provide a much better set of tools for myself and anyone who buys the new edition. Steve has been working on updating the physics, sounds, video, text chapters and adding anything new he finds that might be useful across the the entire book.

It has not been easy, especially since the deadline was Friday (a tragic day to even think about work), but I was finally able to get a revised 2nd edition of chapter 9 (Game Essentials Part 2)  complete and to the publisher for a first look. The two game chapters (8, and 9) and the image chapter (4) have been re-written to add in things that I wanted in the first edition but just didn't have time to fit in: Pixel-based collision detection, A* Pathfinding, Fine and Coarse tile-based world scrolling, and more. I know Steve has been busy adding in Box 2D content and other goodies to his chapters. There is just one chapter left to do for me, number 10. It deals with using Phone-Gap to create a HTML5 based iOS native application, and we are adding in the concept porting a browser game to a touch interface. The first part needs to be re-written 100% as everything about PhoneGap, xCode and the iOS portal has been completely re-vamped since the first edition. Also, more and more people are publishing games on the internet to target mobile browsers and we wanted to add in some "secret sauce" that we have uncovered to make this a little easier of a transition for the developer.

Here are some images from the various chapters that I have written to help give you an idea of what game subjects I have been covering and how they will be presented in the new edition (Tentative publish date March 2013).

Pixel Based Collisions

Pixel Based Collisions

AStar on the Canvas

AStar on the Canvas

Fine Scrolling

Fine Scrolling

 

I am starting on chapter 10 today, so hopefully the entire first draft will be complete by the middle of the week and then it is on to technical reviewer revisions and Chicago Book of Style red lines to fix.

This site is protected by Comment SPAM Wiper.