Showing posts with label Actionscript. Show all posts
Showing posts with label Actionscript. Show all posts

Remoting with BlazeDS from plain vanilla Actionscript 3 class

Thursday, 21 August 2008 | Labels: , | 77 comments |

I wanted to use BlazeDS from within my plain AS3 project (no mxml or Flex, well of course I need to use the Flex remoting and rpc classes on the client). I found a number solutions on the web, unfortunatly none of them worked. After much effort I got a example almost working but I kept getting this error on the client:

TypeError: Error #1034: Type Coercion failed: cannot convert Object@13e9921 to mx.messaging.messages.ErrorMessage.

and this error on the server:

No destination with id 'null' is registered with any service.

Fortunally Peter Farland over at the Adobe product forums gave me a (rather obscure) solution:
http://www.adobeforums.com/webx/?13@618.wIQPiTpvUo4@.59b6384e/0

I thought I'd document the full solution here in case anybody else ran into the same problem.

Environment

  1. BlazeDS, the recommended turnkey installation (my file was blazeds_turnkey_3-0-0-544.zip)
  2. Flex 3 SDK
  3. Flash Develop 3
Setup

  1. Unzip the BlazeDS zip file and start the sample DB and then Tomcat as the standard instructions say.
  2. Check the sample 3 in the "Take the test run", you should get a grid up with a load of camera data.
  3. Go to the [BlazeDS install directory]\tomcat\webapps\ROOT\ and copy the crossdomain.xml file there
  4. Now open you AS3 dev enviroment, I used Flash Develope, but Flex builder, Flash IDE or FDT will do.
  5. Create a project and copy the Main.as source file at the end of this post as the main class.
  6. Check the url in the code is correct for you
  7. Run it, you should see a load of trace. In that trace there you should see the same information as when you ran example.
My next post will be about configuring your own services and classes on the server, and maybe a more general solution...

Files
Main.as
crossdomain.xml


glaze Physics engine code released

Wednesday, 6 February 2008 | Labels: , , | 19 comments |

What had a working title of pEngine is now part of the glaze engine. It now only comprises of the rigid body dynamics engine, I'm going to now slowly port over the other features such as tile support, AI, line of sight etc. I was going to wait with this release until the code was complete and I was happy - which was probably going to be never so I though I'd get it out there a see what people might make with it.

The source is available at http://code.google.com/p/glaze/

The latest demos can now be found at http://home.planet.nl/~borst595/glaze.html

Good luck with it, post any questions, comments of links to anything you make on the group: http://groups.google.com/group/glaze-engine

Broadphase now added...

Wednesday, 23 January 2008 | Labels: , | 2 comments |

I was a little skeptical about broadphase with tightly packed bodies. After some playing around with Sweep&Sort I came up with a very efficient version that Actionscript likes. I also implemented my own inline Insertion Sort on the shape list to take advantage of spacial coherence (anybody know that the built in AS3 Array sort algorithm is?).

Result? A bump to 425 bodies - not all that stable sometimes. The stack just disintegrates at various points sometimes - I'll have to take a look, maybe bump up the iterations of the solver...

Find it here: http://home.planet.nl/~borst595/pEngineStressDemo.swf

or through the link at the bottom of the main page:

http://home.planet.nl/~borst595/pEngine.html

Now I really need to start fixing stuff for a release rather than seeing how fast I can make it....

Showing off...

Wednesday, 16 January 2008 | Labels: , | 5 comments |

Same demos as the other version of pEngine, only this time demo 1 (press 4) is a tower of 246 individual blocks.

Don't forget, you can aim and fire a block by clicking the left mouse button...



Play here:http://home.planet.nl/~borst595/pEngine246.swf

A reasonably decent computer required as well as the latest flash player - get it now!

New Actionsctipt 3 Physics / Game Dynamics Engine - Port of Chipmunk

Tuesday, 15 January 2008 | Labels: , | 1 comments |

After trying to a number of ideas for my tile engine, I decided I really wanted rigid body dynamics - my existing glaze engine is really only a particle dynamics engine. The trick with rigid body dynamics is to get it stable (aka no jitter). Fortunately there is a solution for this (SI) as shown in the Box2D physics engine (also ported to Actionscript 3) and the Motor2 engine. There is also a rather elegant implementation in C called Chipmunk.

After a few marathon coding sessions I ported the bulk of the code to Actionscript 3, and once working rewrote large chunks so that it was more optimized for the AVM.

The initial result can be seen here: Chipmunk Port - pEngine Alpha

I've still got a long way to go - I'm working a very simple API at the moment that allows you to describe a scene using tiles. I'll be updating this blog more frequently as I progress.

ICK

Friday, 30 November 2007 | Labels: , , | 2 comments |

After some playing around with various physics engines I decided to write a Verlet/Particle Physics Construction kit. Let people play around with building things out of not-so-steady materials. Anyway after some experimentation I ended up with something that played not unlike Tower of Goo (http://www.experimentalgameplay.com/game.php?g=17).

For some reason or other I decided to recreate the look and feel of Tower - mainly for the challenge of creating a native game into Flash/Actionscript.

The result is here:

http://www.100percentcode.com/ICK.html

See how high you can get!

If you like it the guys a 2D Boy are making a full games out their original - It also been entered into the IGF 2008 - good luck guys...

Exile Remake Update

Wednesday, 26 September 2007 | Labels: , , | 0 comments |

The latest demo of the engine & game can now always be found here:

http://home.planet.nl/%7Eborst595/Exile.html

Controls and Instructions can be found on the page. Its worth noting that this engine runs much faster with the latest Flash 9 Beta found here:

http://labs.adobe.com/technologies/flashplayer9/

This demo is running at 30fps.

More of a game...

Friday, 14 September 2007 | Labels: , , , | 0 comments |

Everything is the engine can now be destroyed (not the landscape thought) - some things are just tougher than others. At the moment the turrets and some of the doors only take a few hits - for test purposes.

Other improvements:

  • New Weapon system + light rocket launcher implemented.
  • Multi sampling between game objects (not landscape at the moment). This ensures high speed collisions always impact (the rocket should never tunnel through a door).
  • Massive internal restructure. The code is now halfway into its release form.
  • Improved Aiming

Additional keys:
1: Default blaster
4: Light rockets

Demo

Latest Demo - Large Level with doors & swich system

Sunday, 9 September 2007 | Labels: , , | 0 comments |

Latest demo is available here. Controls are WASD, mouse to aim, click to fire. The door and switch system are in place and working. This level is 100x100 but its been tested with 2000x2000, with a 48x48 pixel tile that's a level of 96,000 x 96,000 pixels....

This demo, with a 100x100 level (the bitmap data is generated in code) is only 23Kb

Line of sight demo

Tuesday, 4 September 2007 | Labels: , , , , | 0 comments |

I've switched track for a bit. This time working on the AI. This demo shows some line of sight testing. The code calculates 3 rays from an eye that intersect with the two limits and centre of an AABB. If the object is visible the the turret calculates a firing solution and fire. At the moment this is all done every frame (30fps). I'll spread this calculation out over a series of frames. The current enemy AI plan is:

  1. Create a list of target candidates within range (1.5x the firing range of the turret)
  2. Prioritize list
  3. Lock target
  4. Check visibility
  5. Calculate firing solution and fire.
  6. Reload
  7. Goto 4

The controls are the same. WASD to move the player, click to fire in the direction of the mouse.

Demo

Almost there...

Sunday, 2 September 2007 | Labels: , , , , | 0 comments |

I wanted to get a version with source ready this weekend - unfortunately I didn't make that target. I did however fully incorporate the grid object cache (tested with 1000x1000 tiles), a new map definition method and a physics constraints system into the code base.

Demo

2D Circular Linked List Data Grid

Thursday, 30 August 2007 | Labels: , , , | 0 comments |

In order to manage the visible bitmap data in the tile engine, I wrote this 2D Circular Linked List Data Grid. Once initialized the grid can hold n x n data items. The grid can be shifted left, right, up and down. As the grid is shifted, the items that fall off once side are added to the other, and automatically updated with new information. This demo illustrates the code. The red rectangle simulates the scroll window of the Tile Engine. The black/grey 4x4 grid represents the Bitmap Data Grid (Each smaller square would be a super tile of, say 5x5 normal tiles). As you move the red rectangle around with the cursor keys, the grid updates correspondingly. The important thing here is that there is only ever 4x4 Bitmap and BitmapData objects that get rotated around, updated and recycled.

Source.

Tile Engine Update v0.1

Tuesday, 28 August 2007 | Labels: , , , , | 0 comments |

Big update:

  • Completely new collision resolution code, much more stable.
  • The physics system in much more flexible, it also includes mass in the calculations now.
  • Projectile system improved. Projectiles die out after a certain time (with various effects). The system allows a great variety of weapons to be implemented using one class.
  • Projectile explosions impart force on surrounding object (you can have fun with this and the boxes)
  • First attempt at an Enemy AI gun turret. The turret uses a ballistics solver to calculate the two angles it can hit the player with, and then fires. I'll write an entry on this, I'm going to extend this to take into account relative velocities.
  • The projector (.exe) version now uses the latest beta flash player.

Controls (focus window first):
  • A,W,S,D : Thrust Player
  • Left Click : Fire weapon in direction on mouse cursor
  • CTRL Left CLick : Shoot ray
  • SPACE : Add non-player 'boxes' to interact with
  • ENTER : Add random force to boxes
Available here as:

.SWF
.EXE

Flash Player Beta update 9.0.60.120

Monday, 27 August 2007 | Labels: , | 0 comments |

Get the latest and greatest at http://labs.adobe.com/technologies/flashplayer9/

If your looking for the debug player, grab the latest Flex 3 SDK nightly build from the bottom of this page (you have to check the box agreeing to the T&C)

AS3 Performance Test Framework

Sunday, 26 August 2007 | Labels: , | 0 comments |

This is an extension of something I found (I wish I could remember where) to quickly run performance tests in controlled, repeatable environment. To run your own tests just write a class that implements the ITests interface, see the VectorTests.as as an example. All the functions in the array returned by getRegisteredTests() will get exectued. You can change the number of iterations, test cycles etc by modifying the TestRunner.as

Also if you do build a new test class, dont forget to change this line in TestRunner.as:

public var tests:ITests = new BasicLoopTests();

Replacing the BasicLoopTests() with your class name.

The code can be found here: http://home.planet.nl/%7Eborst595/BenchmarkAS3.zip

Tile Engine Update

Saturday, 25 August 2007 | Labels: , , , , | 0 comments |

Update:

  • Particle system added
  • Projectile system added
The controls have changes a little:
  • A,W,S,D : Thrust Player
  • Left Click : Fire weapon in directon on mouse cursor
  • CTRL Left CLick : Shoot ray
  • SPACE : Add non-player 'boxes' to interact with
  • ENTER : Add random force to boxes
You can download a play the demo with the previous links. I've still not updated the source code, again its still in a bit of the mess.

If you try it out please let me know how it performs (cpu).

Thx

AS3/N Tile Engine Update

Thursday, 23 August 2007 | Labels: , , , , | 2 comments |

Major update:

  • All AABB/Tile collision code done
  • All ray/Tile/AABB code done (see keyboard instructions below)
  • Scrolling! Level can be as big as you like (bound by the length of array). Because each tile in the map is only a reference to a single instance of that type the engine is very memory efficient.
The .SWF can be downloaded here.

The .EXE player version (incorporated the latest beta player) can be downloaded here.

The source can be found in a previous post.

Controls:
  • Cursor: Move Player
  • Space: Add/Reset boxes
  • Enter: Apply random energy to boxes
  • Left click: Shoot ray, intersects with tiles, affects boxes
  • CTRL Left click: Place move player to mouse

To do:
  • Some serious physics engine improvements
  • Projectiles
  • AI (pathfinding, flocking etc)
  • Particle engine

Tile Engine Redesign - N

Tuesday, 14 August 2007 | Labels: , , , | 3 comments |

Having played around with a few of my own ideas, I'm going to pursue a geometry based tile +physics engine initially based on the fabulous N tutorials found here. I'm currently working on porting the tutorials to AS3, and then adding the scrolling engine on top. A zip of the current build will be available here.

http://home.planet.nl/%7Eborst595/SeperationAxis.zip

AS3 2D Tile Scroll Game Engine - Glaze Engine

Thursday, 9 August 2007 | Labels: , , | 30 comments |

This is the first demo of my new project - A 2D Tile Game Engine for AS3 - Glaze.

Features:
- Unlimited level size, the level builds as you transverse it
- Efficient pixel perfect collision detection between tiles and game objects
- Basic fast physics engine for a 2D sprite world
- Particle engine/effects
- Full level editor/sprite editor thanks to Tile Studio - an open source project that provides just that.

Planed features:
- Enhanced physics system (either Verlet or RK4 integrator)
- Line of sight functionality
- Common NPC AI (Pathfinding, flocking, communication)

If anybody tries the demo please let me know how it runs (outside a browser) - I'm interested in the spec of you machine a som idea of CPU usage.

V0.2.1 Released

Thursday, 5 July 2007 | Labels: , | 0 comments |

Tidied up a few things and started adding some better test examples. On test 3 you can now step through examples of how a real time monitored process could affect the diagram in a browser.

  • Embedded all the correct fonts for normal, italic, bold and bold italic
  • Embedded just the Latin range (reduced .swf file by a third). I'll write a entry on this.
  • Enabled html formatting on all the reliant items (messages, info box and columns).
  • Turned up font anti-aliasing to full on everything.

You can find it here.