“Ghost in the Shell” Signal Static on the Pico-8


Screen static demoThe glitch or static effect that appeared in “Ghost in the Shell” trailers, that have been circulating the last couple of months inspired me to apply a similar effect to a game project in development. What better way is there to demo the effect than in a 8bit “Ghost in the Shell” title screen?

The static effect is reasonably configurable, random and light weight, using very few available tokens. In the game version, additional parameters are available to set width, height and offset’s, to allow targeted areas with the static effect.

Here’s the important stuff!

glit = {}
glit.height=128 -- Set the width of area the screen glitch will appear
glit.width=128 -- Set the width 

function glitch()
   if g_on == true then -- on boolean is mangaged by the timer
     local t={7,2,5} -- Create array of three colors
     local c=rnd(3) -- Generate a random number between 1 and 3, we'll use this in a bit
     c=flr(c) -- Make sure our random number is an integer and not a float
     for i=0, 5, 4 do -- The outer loop generates the vertical glitch dots
       local gl_height = rnd(glit.height)
       for h=0, 100, 2 do -- The inner loop creates longer horizontal lines
         pset(rnd(glit.width), gl_height, t[c]) -- Write the random pixels to the screen and randomize the colors from the previously generated random number against out color array
       end
    end
 end
 
 -- Animation timeline that turns the static on and off
 if glit.t>30 and glit.t < 50 then
   g_on=true
 elseif glit.t>70 and glit.t < 80 then
   g_on=true
 elseif glit.t>120 then
   glit.t = 0
 else 
   g_on=false
 end
 glit.t+=1
end

and of course we call our glitch() function from _draw():

function _draw()
 cls() -- Clear the screen
 
 glitch() -- Start the static/glitch overlay
end

The code for the demo is available as a Pico8 cart at: http://www.lexaloffle.com/bbs/?tid=29102 or you can fork/download the code from GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *