Design Tips and Demoscene effects with pseudo code

From SizeCoding
Revision as of 16:33, 8 June 2025 by Superogue (talk | contribs)

Jump to: navigation, search

Introduction

On this page we will provide a bunch of general design tips as well as examples for commonly used effects.

General Tips

  • Learn from the source code of others (a lot of productions include the sourcecode)
  • Make sure to write comments, your future self will thank you.
  • Make prototypes in another language you're familiar with
  • If your idea is complex: approach your problems one at a time in seperate files and merge them together at a later stage
  • Collect your own bag of tricks and document them for easy access
  • Write down a simplified list how much bytes each of the commonly used instruction costs
  • Don't be afraid to itterate on existing ideas and code
  • Get comfortable making mistakes.
  • Cherish the happy accidents

Design Tips

Design tip #1

Try to look around to see what is out there and where there is room for new stuff: Whenever i start experimenting with a new platform (like spectrum, atari, fantasyconsole, etc.) I literally watch EVERYTHING that is ever released in 256, 128 and below for that platform to get a feel for what is out there and where i can maybe add something.

Design tip #2

The actual execution is in (re-)combining tools from your bag of tricks... The more tricks in your bag, the amount of combining possible increases tenfold... So imho its always worth to try experimenting with (new) things/techniques without ever having a point of releasing it, or doing something concrete with it...

Design tip #3

Don't try to optimise early, but don't do things 'the expensive way' deliberately either. Try to sketch out the idea as complete as possible to what we had in mind. (trying to make zero to little compromises, regardless of size). So your intro will probably always go overboard by quite a bit in the beginning (300-350 bytes for 256, ~160-170 for 128 byte stuff) and once you're happy with the end result tone back from there and THEN start to make compromises (or not at all, so a 128 byte intro ends up as a 256b down the road , or a 256b intro is on hold , changes platform, or dismantled for parts) .

Design tip #4

If you can afford the luxury: Ideally you'd like to have at least 1 intro ready for release at any time , without a party in sight... This allows you to have a choice, maybe tweak on the end-result a bit more or to have something to submit last minute.

Effects and Techniques

There are basically two strains of effects being used.

  • The first would be Hardware Effects (rasterbars, sprites,etc.) that are often used on 8/16bit machines to compensate for the lack of CPU power.
  • The second group is pixel-based effects where the pixel color or index is calculated for each pixel (or chunky pixel on older platforms) on the screen.

Common Demoscene Effects

Pixel-summing / Automatons

Here you add a number of different pixels and shift back the result to create interesting effects, e.g. Fire effect, Random Walk, Color fight, etc.

color = (img[x,y] + img[x,y+1] + img[x-1,y+1] + img[x+1,y+1]) / 4;

Plasma

Calculate the color for each pixel by adding a number of sine values, e.g.

color = sin(x*val+t) + sin(y*val2+t) + sin((x+y)*val3 + t)

Image/UV Distorters

Distort each pixel by essentially transforming your X,Y screenspace to something different (for example a polar space by taking the atan to center for x-axis and distance to center for y-axis). Other know distortion spaces for example are the Rotozoomer and Floorcast, which transforms your X,Y space into a perspective floor.

Perspective Floor
dx=x-centerx;dy=y-centerx
z = abs(dy);
U = x * scalevalue / z
V = perspectivevalue / z
Polar Coordinates/Tunnel
dx=x-centerx;dy=y-centerx
U = atan2(dx,dy) * 128/MATH_PI;
V = sqrt(dx*dx + dy*dy);
For a perspective tunnel:
V=somevalue/sqrt(dx*dx+dy*dy)
Rotozoomer
dx=x-centerx;dy=y-centerx
U = cos(angle)*dx - sin(angle)*dy
V = sin(angle)*dx + cos(angle)*dy

These U,V coordinates can then be used for either a bitwise operation (like a XOR or AND pattern for example) or lookup coordinates for your texture.

Size vs Effect table

Description Raymarching Ray-Intersection Examples
Domain-Repetition Yes No TBA
Fast Multi-Sample No Yes TBA
Twisting & Blending Yes No TBA
Shape-Blending Yes  ? TBA