Archive for the ‘Flash’ Category

3D engine in 10 lines*

Tuesday, March 9th, 2010

UPDATE – HTML 5 Canvas version now online

During my session at the Flash Gaming Summit, I showed a very simple 3D particle renderer to attempt to demystify the process of converting 3D into 2D.


Flash simple 3D particle renderer

Click and drag.

The actual code that converts from 3D to 2D is easy! First you have to figure out how much you have to resize things depending on how far away they are. (ie what their z position is).

newscale = f/(f+z);

Where f is a notional field of view. Changing this will change how wide the (virtual) camera is. A good starting point would be 250. Then you multiply the 3D x and y positions by the newscale to get their 2D x and y positions.

x2d = x3d * newscale; 
y2d = y3d * newscale;

So that’s where we put our particle, in this case represented by a MovieClip that we also need to resize by our new scale :

clip.scaleX = clip.scaleY = newscale;

And then the final thing we need to do is sort by the z position so that particles in front appear above particles in the background.

particles.sortOn("z", Array.DESCENDING | Array.NUMERIC); 
for(var i:int = 0; i< particles.length;i++)
{
	particle = particles[i];
	particleClip.setChildIndex(particle.clip, i); 
}

There’s some other stuff in there too, to create the depth of field blur and also the bitmap trails, but have a look and see what you can do with it.

Download the source code for simple 3D engine.

* I haven’t actually counted the number of lines. I’m guessing it’s about 10. :-)

Learning to love learning

Saturday, March 6th, 2010

I’ve just published a blog post on the FITC blog where I explain what inspires me and how to learn to love the constant demand of changing technology.

http://blog.fitc.ca/post.cfm/stagnating-in-your-cubicle-learn-to-love-to-learn

Actionscript Hero interview

Friday, March 5th, 2010

It was great to catch up with Pablo and the ActionScriptHero crew in Amsterdam, and we had a good chat about the future of Flash, the exciting changes in digital and what inspires me.

FITC Amsterdam 2010 – Seb Lee-Delisle Interview Part 1/2 from ActionScriptHero.org on Vimeo.

FITC Amsterdam 2010 – Seb Lee-Delisle Interview Part 2/2 from ActionScriptHero.org on Vimeo.

FlashPlayer 10.1 coolness

Wednesday, February 24th, 2010

I just got back from a crazy fleeting visit to Amsterdam for FITC, and now the dust is settling, I wanted to talk about some cool new features in FlashPlayer 10.1, especially now that FlashPlayer 10.1 Beta 3 has just been released on Adobe Labs!

RTMFP – Peer-to-peer networking

Yes it’s quite catchy name I know, and this stuff was introduced into the FlashPlayer at version 10, but I haven’t actually seen much use of it as yet. One of its limitations of it was that if you wanted to broadcast to multiple users your FlashPlayer would have to deliver that content to every single connected user. Which needs a lot of bandwidth!

But the new 10.1 introduces some really clever new technology that spreads the load across different users. So you can broadcast your video to one person and their FlashPlayer will then pass that stream on to other connected users nearby. It’s kinda like BitTorrent except it’s all in the browser.

This is a really exciting area for video broadcasting although I hear that on initial video tests it’s a little fragile – probably due to the fact that it’s based on the lossy UDP protocol. But its real strength should be in multiplayer gaming – I hear from my friends at Influxis that latency times are reduced by 50-75%. So this is an area I’ll be doing some research into that’s for sure!

Microphone access – finally!

This is something that caught me out a couple of years ago when we were creating a sound to vision system at FlashBrighton. We got some cool effects working with MP3 files, but then we realised we couldn’t actually use these at gigs as we couldn’t process the audio coming into the microphone/line input.

I was delighted to get the email notification yesterday that this feature request on Adobe’s Jira bug reporting system has now been completed! :-) Excellent news, it means that we can now create some fun audio triggered games. This is important for the type of kids’ projects that we work on at Plug-in Media.

Flash 10.1 for Devices

This is hot news and I have to admit to being sceptical at first, as my luke-warm reports from MAX demonstrate. But no matter what you think about Flash on mobiles, you have to admit that FlashPlayer on Nexus One is an impressive engineering feat. The combination of a 1Ghz processor combined with a complete rewrite from the player engineers has brought the a fully functioning FlashPlayer on to a device for the first time.

Now clearly it has its limitations, I’ve tested the Plug-in Media site on it, and it runs at about 4 frames a second, and it also skips frames – a new way that the mobile FlashPlayer saves processor time. I’ve also tested LunarLander3D on it, which also runs at 4 frames per second. To be fair though, these are both processor heavy projects pushing Flash in the browser to the limits.

Testing LunarLander3D revealed another interesting issue – you can’t control this game at all as it is keyboard controlled. And you only get the keyboard entry pop-up if you click on a text field. So pretty much all key controlled flash games are gonna have to be rewritten if you wanna be able to play them on devices!

But this is very early days, and an excellent first step; the fact that a full FlashPlayer is running on these very limited platforms is very impressive. I think it’s going to be very interesting to see what happens over the next few months.

(If you’re interested in Flash on Devices you should definitely read Thibault’s white paper on the subject).

So exciting times for the Flash Platform, and these are the areas that caught my attention, but which new features of FlashPlayer10.1 excite you! There’s a full list here.

Changing the default app to open a .swf on OSX

Saturday, February 20th, 2010

This has been a massive problem to me lately, particularly with distributing files on my training courses. For some reason, the swf files that I give my attendees don’t open with the stand alone FlashPlayer, instead they often default to Flash CS4 etc.

I know the usual way to do this is by right clicking and selecting “Info” (or cmd-i) and then setting the app to open this file and then “Change All”. But for some reason, with swfs this doesn’t seem to work and it just reverts back to CS4 or whatever it was before.

This was driving me mental.

But I’ve found a fix – RCDefaultApp

This is a preferences pain that allows you to choose the app for a given file extension.

This seemed to fix it for me but I’d love to know why this happens and how you’ve solved it on your machine, particularly for Windows. And you’ll save me a lot of trouble in my upcoming training courses!

More training courses in Cologne, Minneapolis, New York and San Francisco

Wednesday, February 10th, 2010

I’ve just finished my Brighton training courses which were seriously good fun, and everyone seemed to enjoy themselves, I’ve certainly got excellent feedback so far!

My next training course is short notice; it’ll be a Papervision course in San Francisco on the 9th March particularly aimed at 3D games. It’ll coincide with the Flash games summit so if you’re interested, let me know and I’ll make sure to get in touch with more information as I have it.

Then it’s on to Cologne for FFK in April, where I’m running both a Papervision3D course and a Flash games training course! More info on the FFK website.

And back to NYC for Flash and the City in May, and I’ll be running courses around the conference. Again, mail me if you’re interested and I’ll send you the details as they are announced.

And finally in FlashBelt in June, I’ll be teaching a one day Flash games workshop. Teaching you maths by stealth – who knew that you could learn trigonometry from Asteroids and vector maths from platform games? :-) It’s a fantastic conference and I’m really looking forward to coming back for my fourth year in a row!

Can’t make any of these events? Then help me organise one near you! Mail me.

Giving ElectroServer more memory

Friday, January 29th, 2010

So after last time, I thought I’d given ElectroServer more memory, but it turns out I hadn’t. I’m not exactly sure why, but I suspect it’s something about how Media Temple is set up.

So rather than call the main ElectroServer app (which is just a shell script), I’m opening the ElectroServer jar file, and that way I can tell java how much memory to use (and other options) as parameters.

I’m pretty sure Java is installed somewhere on Media Temple (you need to install the dev tools) but I couldn’t find it anywhere! And if I just typed java it couldn’t find it. I even ran a find command, but it was nowhere! But then I realised that the Java runtime is packaged with ElectroServer in the jre folder!

So with a bit of fiddling I worked out that I could start ElectroServer with more memory by running the jar file, but I had to do it while in the server subfolder within the ES install.

../jre/bin/java -Xmx128M -jar lib/ElectroServer4-bootstrap.jar -mode StandAlone -config config/ES4Configuration.xml

where 128M is the amount of RAM made available.

[UPDATE]

There is a better way! Thanks to Paul Hayes (a colleague at Plug-in Media, see comments below) I have now realised that ElectroServer’s main app is nothing more than a shell script that you can edit. Furthermore there is a line you can uncomment right at the top to change the Java parameters :

# Uncomment the following line to add additional VM parameters
# INSTALL4J_ADD_VM_PARAMS=

Change this to :

# Uncomment the following line to add additional VM parameters
INSTALL4J_ADD_VM_PARAMS="-Xmx512m"

Where 512 is the amount of RAM in Mb you want ElectroServer to use.

Lego-ize yourself

Monday, January 18th, 2010

Lego-ise yourself

Pete Hellicar and Joel Gethin Lewis put me on to this iPhone app that creates a Lego portrait of you which is awesome. But I thought it’d be fun to do it in Flash in realtime.

(more…)

Multi-user gaming in Flash – Lunar Lander tests

Sunday, January 17th, 2010

Lunar Lander multi-user tests

Anyone playing my Lunar Lander game won’t know it, but we’re spying on them! The game gets around 20,000 hits a month, which is very roughly one a minute or so, so I thought it’d be the perfect vehicle to test out some real-time gaming techniques.

I’ve replaced the original game with one that transmits your position to ElectroServer, although you won’t notice any difference at all. The only way to see the all the current players is via the swf below :
(more…)

Predictive collision detection techniques

Saturday, January 9th, 2010

IMG_8165

In preparation for my upcoming Flash game programming training courses, I’m getting my head back into game physics, and I so I thought I’d share some useful collision detection methods I’ve discovered over the last few years.

Reactive collision detection

Collision detection in Flash games often occurs after things have moved. So you have a circle (usually a 2D representation of a ball) and you’re moving it towards a vertical line on the side of the screen (representing a wall). Every frame, you update its position and check whether it’s overlapping the wall.

Which is great, but of course if the ball is moving fast it may go from one side of the wall all the way to the other side between frames and no collision is detected. One way to get around this is to split up the movement of the ball into small segments and run this check several times between frames. This seems pretty inelegant to me so I have always strived to use predictive collision detection methods where my maths knowledge has allowed me! (This is also known as sweep testing, frame independent or continuous collision detection (CCD)).

Predicting when things will collide before you move them

So rather than just check whether the ball is intersecting with the wall between renders, we actually check the velocity of the ball to see at what point in time it would hit the wall if it continued in the direction it’s going.
(more…)

Bad Behavior has blocked 2855 access attempts in the last 7 days.