Playchilla logo

Archive for the ‘Algorithms’ Category

B-Spline Noise

I’ve published some java code for b-spline noise generation on bitbucket. This is how it looks:

Continue Reading...

Advancing Front progress

I’ve spent some more time on the triangulation, the mesh generation is not perfect yet, sometimes it leaves holes but I think it’s starting the get good enough: I made a video that shows the general idea of Advancing Front (Marching Triangles) as it triangulates the generated terrain: The goal with this project is to […]

Continue Reading...

Advancing Front Triangulation

I was supposed to finish the tower defence game for mobiles but then I saw this: I was so impressed what people could do with so few polygons and I thought it would be fun to code something low poly. Low poly art seems to be kind of trendy now as well. Retro from the 90’s […]

Continue Reading...

Dynamic hard shadows in 2d

Before I forget, here is how I’ve done the shadows for the new version of Shadowess. I realize that this blog post is not very detailed but rather should give you an idea of how shadow geometries can be generated. I may do a follow up with code in the future. My goal was to […]

Continue Reading...

Shooting at a moving target as3

As I was implementing the towers I needed them to aim and shoot on the anticipated position of an enemy, assuming they are moving linearly (no acceleration). This is because the bullets in my game are physics entities that won’t hit the enemy instantly but after some time as it travels towards the predicted interception […]

Continue Reading...

Real Time Fluids

This Jul (Swedish for Christmas) I’m not only eating Julbord, Julfika, Julgröt and drinking Julöl (basically put ‘Jul’ before any word and there you go), I’m also doing some Julcoding. Some time ago I ported a c implementation of a Naiver-Stokes fluid simulation to AS3 and I thought I should share it. It’s all based […]

Continue Reading...

Random direction in 2d

Randomness adds an extra flavor to games by injecting some unpredictability, something that can surprise the player. It also makes the game less mechanical and more organic. In the game prototype I posted earlier, bots always initialized their look directions to (1, 0). So every time a level starts all bots looks in this direction […]

Continue Reading...

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

Ray casting in a Spatial Hash with DDA

For quite some time I have been thinking of adding some ray casting into the Spatial Hash. The Spatial Hash is used for broad phase culling, eliminating objects that can’t intersect with what we want to test. My former implementation only allowed tests against rectangles – when shooting a ray this might be very inefficient. […]

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

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

Playchilla Physics Engine

During my summer holidays I spent some time to build a simple AS3 physics engine just to get a hang of how it works. Features Simultaneous motion – The Playchilla Physics Engine is simultaneous, meaning searches for the next collision and advances all entities to this point in time after which the collision is resolved. […]

Continue Reading...