Playchilla logo

Archive for the ‘AS3 Coding’ Category

Simple Shadow Casting in 2D

Unaccordingly to my plan I spent yesterday rewriting my shadow casting routines. What I need is a frustum, or flashlight type of light source. Before, I had solved this by first drawing a full circle onto which I drew masking triangles, carving out the frustum pie. This mask was very expensive to draw (imagine a […]

Continue Reading...

How to check if a point is inside a hexagon

Hexagons have always fascinated me, they appear everywhere, in architecture, computer games and more curiously; this rather symmetrical structure emerge in a lot of places naturally. Snow crystal: Bee hive: Civilization V: Google on hexagon and you shall be surprised of all its appearances. Anyway, I’ve never familiarized myself closer to those mystical shapes other […]

Continue Reading...

Vector 2d for AS3

Here is the source code for an AS3 vector 2d class I wrote (Vec2.as and Vec2Const.as), feel free to use it and link back if you like it. Here are some features: Implemented for most operations, add, sub, div, mul, scale, dot, normalize, cross, length, distance, rotation, spinor, lerp, slerp, reflection etc Separation of read […]

Continue Reading...

As3 Spatial Hash

When I wrote the Playchilla Physics Engine last summer I needed a broad phase algorithm to reduce the number of collisions to check. There are several ways to do this using spatial partitioning for example Grids, Spatial Hashing, Trees and Sweep and Prune. After reviewing them I decided to go with something called Spatial Hashing […]

Continue Reading...

AS3 and constants

As3 is lacking a powerful const keyword, this post will show a few tricks to simulate const. Anyone who has worked with C++ has encountered the keyword ‘const’. This can be very confusing at first, but once you get a hang of it you will understand how powerful it’s, and have trouble living without it. […]

Continue Reading...