ˆˆˆ ªªª ˆˆˆ ÌÌÌ ÌÏÌ ÌÏÌ ÌÏ̈ˆªªˆ¨̬ϬϬϬPUUUVUfgfCp6DEAUPefffvDfwDssÀìîÍ!ÍÌÌÍ ÎîÜÜÌÌÜ00DDADD@@D ÌÌÌ ªªª ª¬ª ªÊÌ ªªª€ˆˆˆÿ̬ÿªª¬ªªªªªˆˆÿEDPEUf3efwfv`wDs1c3vfgwgpwwwàÝÌÍîÝÍÍ!ÀàÝÎÐÜÌÝÜÝîÜ Ýì DDDDD0@@ >£=!"23CDD""33DDD!"23CDDDD""33DDDDD""33DDDDD""33DDDDD""33DDDDD""33DDDDD!"23CDDDD""33DDD!"23CDDˆˆxwgfVUU€ˆˆwwffUUUˆˆxwgfVUUUU€ˆˆwwffUUUUU€ˆˆwwffUUUUU€ˆˆwwffUUUUU€ˆˆwwffUUUUU€ˆˆwwffUUUUUˆˆxwgfVUUUU€ˆˆwwffUUUˆˆxwgfVUUˆˆ˜™©ªº»»€ˆˆ™™ªª»»» ˆˆ˜™©ªº»»»»€ˆˆ™™ªª»»»»» €ˆˆ™™ªª»»»»» €ˆˆ™™ªª»»»»» €ˆˆ™™ªª»»»»» €ˆˆ™™ªª»»»»» ˆˆ˜™©ªº»»»»€ˆˆ™™ªª»»» ˆˆ˜™©ªº»»ˆ€€ˆˆˆˆÿÿïîÞÝÍÌ̈ˆ€ˆðÿÿîîÝÝÌÌÌ €ˆˆˆˆÿÿïîÞÝÍÌÌÌ̈ˆ€ˆðÿÿîîÝÝÌÌÌÌÌ €xwˆwðÿÿîîÝÝÌÌÌÌÌ €wwpw‡ðÿÿîîÝÝÌÌÌÌÌ ˆxwwˆwwðÿÿîîÝÝÌÌÌÌÌ €ˆˆ€ww‡xw‡ðÿÿîîÝÝÌÌÌÌÌ €ˆˆxwwˆwwÿÿïîÞÝÍÌÌÌ̈ˆˆ€wffVUffUðÿÿîîÝÝÌÌÌ €ˆˆhffUUeVefÿÿïîÞÝÍÌ̈xwpwwVUfffv€ww‡ˆˆgfCDfwwwwˆˆx6DDsxwwgffEAs€wwgffEDDsxwffVE1c€gffUf33vfhffefwgwgpwwfv‡xwwwwgwˆˆwÌÌÀÌÀ ÌÌÌÌ ÌÌÀÌÀÌ ÀÌ Ì ÌÌ ÀÌÀÌ ÌÌÀÌ ÌÌÀÌÀÌÀÌ ÌÌÌÌÀÌÌÌ Ì Ì ÌÀ Ì Ì Ì À Ì Ì Ì À Ì À ÌÀ Ì Ì Ì ÌÌÀ ÌÌÌÌÌ Ì Ì ÌÌ À Ì Ì Ì À Ì ÌÌ Ì Ì Ì ÌÌÌÀÌÌÌÀÌÌÌÌÌÌ Ì ÀÌÀÌ Ì ÀÌ Ì À ÀÌÌÌÌÌÌÌÀÌÌ ÀÌÌp-- title: Afterimage Demo -- author: Marioio333 -- desc: A demo for an afterimage effect -- site: https://marioio333.neocities.org/ -- license: MIT License (change this to your license of choice) -- version: 0.1 -- script: lua REFRESH_RATE = 5 -- in frames t = 0 COLORS_UP = {5,6,7,12,13,14} COLORS_DOWN = {4,3,2,1,11,10,9} END_COLORS = {8,15} SPRITES = 4 CONTROLS = { BTN_UP = 0, BTN_DOWN = 1, BTN_LEFT = 2, BTN_RIGHT = 3, BTN_ACTION = 4 } balls = { { x = 40, y = 20, speed = 100, -- inverse color = 4, }, { x = 40, y = 40, speed = 100, -- inverse color = 5, }, { x = 40, y = 60, speed = 100, -- inverse color = 11, }, { x = 40, y = 80, speed = 100, -- inverse color = 12, }, } player = { x = 110, y = 60, speed = 1, sprite = 1 } function BOOT() cls(0) end function TIC() INPUTS() UPDATES() DRAW() end function INPUTS() -- Player if btn(CONTROLS.BTN_UP) then player.y = player.y-player.speed end if btn(CONTROLS.BTN_DOWN) then player.y = player.y+player.speed end if btn(CONTROLS.BTN_LEFT) then player.x = player.x-player.speed end if btn(CONTROLS.BTN_RIGHT) then player.x = player.x+player.speed end if btnp(CONTROLS.BTN_ACTION) then player.sprite = player.sprite+2 if player.sprite > SPRITES*2 then player.sprite = 1 end end end -- INPUTS function UPDATES() t = t+1 for i,ball in pairs(balls) do ball.x = (math.sin(t/ball.speed)*100)+119 end end -- UPDATES function DRAW() if t % REFRESH_RATE == 0 then degradeColors() end for i,ball in pairs(balls) do circ(ball.x,ball.y,5,ball.color) end spr(player.sprite,player.x,player.y,0,1,0,0,2,2) print("Press A to change sprite",10,126,12) end -- DRAW -- HELPERS function degradeColors() for y=0,136 do for x=0,240 do color = pix(x,y) if findArray(END_COLORS,color) then color = 0 elseif findArray(COLORS_UP,color) then color = color+1 elseif findArray(COLORS_DOWN,color) then color = color-1 end pix(x,y,color) end end end function findArray(list,element) for i=0,#list do if list[i] == element then return true end end return false end