Monday, December 22, 2008

Flash Side Scroller / Platform Engine: Post 1.5

I've been working here and there on a side scroller engine in my spare time. I say post 1.5 in the title because I briefly mentioned the game at the end of a previous post.

In the previous post I just had a square for a character, general movement, and basic collision detection. Since then, Stan created a run animation and I changed my collision detection so that it can handle any shape (before it could only handle rectangles). So now I have ramps, stairs, and crazy spiral platforms. Its still very, very early and unfortunately fairly buggy.

The main thing I want to touch on is the collision detection. I have come up with a scheme to handle all the collisions using bitmapData objects. I choose this option for two reasons:
1. I wanted to stay away from grids because by the end of this I want the world and characters to be very fluid and animated. I didn't want to constrain the art and design to any rectangles or dimensions.
2. For speed purposes, I want to use blitting and only display 1 bitmap on the screen... this rules out any MovieClip/Vector hit test.

To accomplish this there will be three bitmapData objects: Floor, Walls, and Ceiling. As the character moves, I will store the character's x,y position and do a hitTest on the different bitmapData objects. That means that all the black walls/floors/etc that you currently see do not need to be displayed on the screen, I just need their bitmapData to use as reference. In the final product you will see some pretty scenery and all of these fugly black platforms will be referenced in the background.

If a hit occurs then I need to find the boundaries of the platform that is being hit. Obviously I can't just grab the boundaries of the entire bitmap because that would always be 0,0 for the top left and the width,height for the bottom right (since the bitmap takes up the entire level). I initially did a red floodfill on the contact point and then grabbed the bounds of the color red from the bitmap. This worked great when I was only using rectangular platforms. Once I made slopes and stairs, however, I was back to the same problem of getting the outer rectangle when the actual hit occurred somewhere within the bounds.

Therefore, I tweaked the process. After a hitTest returns true, I copy the pixels from that column into a 1 pixel wide bitmapData object. I then do the same floodFill operation on this object. By keeping it 1 pixel wide, I am guaranteed to not be impacted by the surrounding platform area.

This has worked much better than my initial collision detection... but I have run into one bug that I need to squash. It seems as though the hitTest and the floodFill are rounded a bit differently. Or possibly one is rounded and one is not. In any case, sometimes a hit is triggered but then the floodFill will fill the whitespace instead of a black platform. When this happens the character jumps to a higher platform or to the far side of the screen. It should be fairly easy to get around this by adding some constraints or possibly an extra check to make sure the floodFill is hitting a black area... but I hopefully with some extra time I will be able to figure out the rounding difference because the work-arounds I have in my head seem as though they would be slightly more processor intensive.

Anyways. I wanted to post my progress before the break. Not sure if I will be on here much until the 5th. You can check it out here.

Hope you found this interesting. There will be more to come.

Enjoy the Holidays.

Recent Project Recap

I got some good news and I got some bad news. The good news is that a project we were working on awhile back is officially done. The bad news is that client is no longer in business. Soooooo, yeah.

Its really unfortunate too, the client has been around for a long time and had a significant number of employees. Another casualty to the economic woes.

But I won't go into that... need to stay on topic here. We decided to upload the project on our server just so we would have it in our portfolio. If you would like a peak, check out the Odyssey Group's website. All the pages were designed by Hendrix Rader Wise, it was our job to take their static pages and bring them to life. Most of it is straight forward, but I did get to experiment with working with particles. You can find a smoke example by clicking PEOPLE and then MILESTONES. I blogged about the smoke particles back in September. The PLACES page also uses a neat little particle component. Basically you create a black and white image and Flash will cover the black space with particles (in this case a map of the US with holes for the "hotspots"). We created a variety of build ins for the map, my favorite was a very cool water-like effect, but they didn't exactly drive home the point of the company's expansion so we ended up with what is currently shown.

As always, leave your comments, suggestions, feedback.

Wednesday, December 17, 2008

How to Delete Flash Shared Objects

I just had my first run in with shared objects. The client wants the user to see a video the first time they open the homepage and then to see page2 for every other time the user opens the homepage. I had read about sharedObjects before and by referencing the help docs they were pretty easy to implement.

However, attempting to remove the little buggers is a different story. I figured I would just need to clear my cookies and reload the page. Nope. Hmmm, clear cache and reload? Not so much. Clear everything? Offline Content, Search History, Browsing History, etc? No, No, and more no. Those buggers are like cockroaches.

Turns out with a little research I found out that Flash Objects are their own beast. They live outside the browser and therefore are not controlled or contained by the browser. Fair enough.

For Windows users you can find these guys hiding in the following default location:

Windows Vista:
C:\Users\userName\AppData\Roaming\Macromedia\Flash Player\#SharedObjects

Windows XP:
Documents and Settings\userName\Application data\Macromedia\Flash Player\#SharedObjects

The first time I opened that folder was a bit scary. Its amazing how many sites have been collecting information about me without me knowing. I thought I was somewhat safe by deleting cookies, little did I know I had all these friends hiding in my application folder.

To remove them you just simply delete them from their corresponding folder. Next time you visit the site they will be recreated automatically.

You can learn more about Managing Shared Objects at Adobe's help Center.

You can also change your SharedObject settings by visiting Adobe Flash Player's Settings Manager.

Tuesday, December 16, 2008

Console Games and Flash Games... The Lines Blur

The line dividing the TV and the internet have been blurring for awhile now. This is not news... it has been very apparent with examples such as Pandora, Hulu, netflix, etc. However, a couple articles jumped out at me today that suggest that the line between console games and Flash games are also blurring.

First off, head over to 8BitRocket and read about a Flash Game making into Time Magazine's top ten games of 2008. To me, that is huge news. A flash game being put in the same list as GTA, Star Wars, Rock Band, Spore... are you serious? That is incredible. It brings some legitimacy to Flash gaming platform that is mostly known for its casual games and possibly even its advergaming (sorry, had to throw that word in there, just learned it this week while chatting over at 8Bit).

Second off, check out the Papervision's recent blog post about a flash microsite that ties into Little big Planet. Basically you can customize your character for the PS3 hit and display it on the web. Nothing too crazy there, but then I read that they plan to integrate the avatars you create into the ps3 game itself. That would be amazing. The ability to have Flash integrate into the console gaming world could be an incredible boost to the Flash gaming world. This could lead to possibly unlocking things in the game by completing achievements (Kongrgate) online and vice versus. This would open up a slew of marketing and social avenues.

Its an exciting time to be into Flash development... as all these different digital worlds collide.

Friday, December 12, 2008

Work Hard, Play Hard

Someone forgot to send me the memo, I guess the saying "Work hard, Play Hard" has been retired for quite some time.

In my defense, when asked, "What is the work environment like at the Basement?" Its much easier to say Work Hard, Play Hard than it is to explain how we get our shit done on time with quality results while having a good time doing so. But I guess the former answer causes some people to shudder and do an internal vomit.

No one likes an internal vomit, so with that in mind I guess the saying is officially too clique and should be tossed in the waste bucket along with giving 110% or bringing your A game... altho I still kind of like that one.

So all of you out there like myself who unknowingly still used the classic Work Hard Play Hard slogan... its time to give it up... its time to let it go... its time to move on.

Tuesday, December 9, 2008

25 Lines of Code Finalist

Keith recently posted the finalists for his 25 Lines of Code contest.

I just briefly clicked through the swfs... there are some amazing projects there. You have your classic fractal tree, and classic partical fireworks (both done extremely well). Then you have a few full fledged games... which I wouldn't think would be possible in that short amount of code. A few nice 3D objects... I definitely like the interaction with the dandelion, altho the cube with the Conway's Game of Life is no slouch either. There is a very cool flocking example and then a few organic math based objects... including one that reminds me of the root in Pan's Labyrinth (I just watched it last night so its on the mind). All in all, I am extremely impressed.

Now I am looking forward to being able crack open the FLA's and see what kind of Black Magic they used to accomplish these pieces. Should be able to find some new tricks and techniques crammed in there.

Tuesday, December 2, 2008

Mac Flash Video Bug... autoPlay (AS3)

Ran into an obscure bug last night. We had an FLVPlayBack video placed on the homepage with autoPlay set to true. I needed to change the autoPlay to false and since I didn't have access to the FLA I just did it within the code and committed it to SVN for another developer to compile.

Upon playback I saw no errors and thought it worked like a charm. The developer on the other hand was having all sorts of problems with the video playing on top of the homepage animation. It was the same SWF but he was viewing it on a Mac and I was on a PC (both using Firefox). After digging around for awhile we eventually figured out that he needed to set the autoPlay to false in the FLA, instead of in the code. For some reason this fixed the issues during playback on the Mac.

I haven't done any extensive testings, but it seems from these results that you can't change FLVPlayBack component's autoPlay to false in code and then view it on a Mac. You need to make sure you change the component in the FLA instead.

Monday, December 1, 2008

Sidetracked... Flash Gaming

10 Days without a post... I think that is a new record. Not one I am proud of, but it happens.

Between deadlines, eating turkey, and celebrating my birthday, I've been busy researching Flash games. It started as a simple assignment, which was to come up with a few examples of game types that we (the basement) could make. Basically an example of a point and click, example of a shooter, example of a platformer/side scroller... etc etc.

Well shit, once you open that Pandora's box you find yourself stuck playing Flash games for days. I have gaming systems, I have a gaming pc, I recently bought Bioshock... but somehow, ever since that assignment a couple weeks ago, I find myself staying up late playing Flash games. There is just something about a good Flash game that is hard to pass up. You think you are going to play for just 10min before you head for bed and then you find yourself saying "just 1 more try" at 2am in the morning. DOH.

Anyways, I've compiled a small list of sites that have sucked me in recently.

First and foremost: Kongregate. This site is incredible. It is not just your everyday game portal, it has a built in rewards system that keeps you coming back for me. Reward are given out for playing games, making games, and reviewing games and they come in forms of points, kreds, and cards. For example, if I build a 600 foot tower in 99 Bricks then I get 30 points. The more points I get the more I level up. At this stage, leveling up is only for prestige, but in the future it could lead to unlocking certain features of the site. Kreds on the other hand are used for buying extra content in games. Cards are unlocked and used in the Kongai Card game. All three of which give you a great reason to keep playing a variety of games into the wee hours of the night. I still can't get my tower past 490, damn it.

From there you need to check out Jay Is Games. They have daily dose of reviews of a variety of games (not all Flash). I enjoy going to JayIsGames because they tend to spotlight games that aren't being featured on the big game portals. These games usually have something unique and don't follow the beaten path. Therefore, it is a great place to go for inspiration.

After Jay comes my friends at 8 Bit Rocket. Their weekly inter-web mash up contains a wealth of information about the Flash gaming world that will keep you busy for hours. Beyond that they also offer their own news, opinions, and plenty of in-depth tutorials. They also have a nice collection of games they've developed, including: Jack's Beach Blitz.

This wouldn't be a proper Flash game post without sending some love to Emanuele Feronato. If you ever have any desire to make Flash games on your own then you absolutely have to read his 9 part series on monetizing Flash games. He breaks down his experience and process step by step showing you what to do and what to avoid. Its a priceless read for any aspiring game developer.

I could go on and on. But those are the biggies... the ones I check daily.

From all of this reading and research I have been inspired to start my own side scrolling/platform engine in my free time. Eventually I see it being used by the basement, but currently it has no face and is just a core engine that will be able to be skinned and reused. Here is a very early prototype that just shows some basic movement, scrolling, and wall collision detection. (click on the screen then use your arrows to move/jump). I am implementing the Blitting and Collision Detection technique I researched back in May (wow, I hate to be clique but time is flying). I am combining that research with the bitmap techniques I learned in Mario Klingemann's presentation to help me find the bounds of the different walls the character is colliding with. So far it is running very smooth. We will see if that holds up once I add projectiles and enemies.

Thats my story lately. Now I need sleep.