## 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:

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 […]

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 […]

### 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 […]

### 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 […]

### 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 […]

### 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 […]

### 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 […]

### 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. […]

### 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 […]