PLAYBASIC SOURCE CODES


Meta Balls - Light Blobs

Meta Balls - Light Blobs

This example recreates a popular demo effect known as meta balls/blobs. The scene is calculated by working out the amount of energy that each pixel receives from the surround 'blobs' or lights. The more lights the more work each pixel has to be do.

So if you did all the work (calc the distance etc) in the inner most loops, youd get a pretty heavy per pixel calculation. Such a loop would run slowly even in assembly/machine code. So what we need to do is come up with some ways we can simplify the inner loop to get the cost per pixel down as much as possible.

Video:



Related Links:

- Get Source Code
- A Crash Course In BASIC program Optimization

Particles Using Sprites

Particles Demo Using Sprites

     This is an older code snippet that was originally written by Crystal Noir, it creates a type of 3D particle explosion using animated 2d sprites. I've tweaking the code and fixed some logic errors and this was the end result.

Particle Demo Video



Get Source Code

Mapping Light / Shadows using Ray Intersection

     This demo shows the core logic behind drawing radial lights in top down 2D game. The light source is made up of a group triangle fragments drawn in a circular pattern. So we just step around the edge of the circle and draw triangles from the center to the edges. This gives us an N sided polygon that represents our light in the scene, the more sides the accurate the circle will be mapped.

     To make it act more light natural light, we need something to handle the occlusion/shadows. In PlayBASIC we can use the ray intersection support found in the world commands. That means we define the "hard" parts of the world and by hard I mean zones where light is not allowed to go/pas through, by outlining them with lines. So when we draw our light, we run ray intersections along the triangle edges against the hard / occlusion world, if there's a collision we grab the intersection point which will clip our light map triangles for us.

     This demo generates the occlusion world randomly, it's basically a cut'n'paste from the Projects/Worlds/RayIntersectWorld demo.

Get Mapping Light / Shadows using Ray Intersection from forums
Light-Map-Ray-Intersection-Example-V001.png

Limb Chains

    Here's a little example of a spinning egg / octopus looking structure.


Limb Chain Examples On Forums


Limb-Chain-Spinning-Egg-Octopus.png

Sprite Tweening Animation

     This example create a list of random positions then interpolates a sprite between each key frame in the set. This first version interpolates just the sprites coordinates/angle and scale, while the second version includes tint colour interpolation also.

Get Sprite Tweening Animation Tutorial / Library from Forums