How to resolve the algorithm Peripheral drift illusion step by step in the Action! programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Peripheral drift illusion step by step in the Action! programming language

Table of Contents

Problem Statement

Generate and display a Peripheral Drift Illusion The image appears to be moving even though it is perfectly static. Provide a link to show the output, either by running the code online or a screenshot uploaded to a suitable image host.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Peripheral drift illusion step by step in the Action! programming language

Source code in the action! programming language

PROC DrawTile(INT x BYTE y,flip,c1,c2)
  BYTE i

  Color=1
  FOR i=y+2 TO y+11
  DO
    Plot(x+1,i) DrawTo(x+5,i)
  OD
  Color=c1
  IF flip THEN
    Plot(x,y+12) DrawTo(x,y) DrawTo(x+6,y)
  ELSE
    Plot(x,y) DrawTo(x+6,y) DrawTo(x+6,y+12)
  FI
  Plot(x+1,y+1) DrawTo(x+5,y+1)
  Color=c2
  IF flip THEN
    Plot(x,y+13) DrawTo(x+6,y+13) DrawTo(x+6,y+1)
  ELSE
    Plot(x,y+1) DrawTo(x,y+13) DrawTo(x+6,y+13)
  FI
  Plot(x+1,y+12) DrawTo(x+5,y+12)
RETURN

PROC Draw()
  INT x,y,n
  BYTE flip,c1,c2

  FOR y=0 TO 8
  DO
    FOR x=0 TO 15
    DO
      n=(x-y)&15
      IF (n RSH 2)&1 THEN
        flip=1
      ELSE
        flip=0
      FI
      IF (n RSH 3)&1 THEN
        c1=3 c2=2
      ELSE
        c1=2 c2=3
      FI
      DrawTile(x*10,y*20+6,flip,c1,c2)
    OD
  OD
RETURN

PROC Main()
  BYTE CH=$02FC ;Internal hardware value for last key pressed
  BYTE PALNTSC=$D014 ;To check if PAL or NTSC system is used

  Graphics(15+16)
  IF PALNTSC=15 THEN
    SetColor(4,14,10) ;yellow for NTSC
    SetColor(0,8,4)   ;blue for NTSC
  ELSE
    SetColor(4,13,10) ;yellow for PAL
    SetColor(0,7,4)   ;blue for PAL
  FI
  SetColor(1,0,0)
  SetColor(2,0,14)
  Draw()

  DO UNTIL CH#$FF OD
  CH=$FF
RETURN

  

You may also check:How to resolve the algorithm Multiplication tables step by step in the Neko programming language
You may also check:How to resolve the algorithm Convert decimal number to rational step by step in the Rust programming language
You may also check:How to resolve the algorithm Comments step by step in the Pascal programming language
You may also check:How to resolve the algorithm Here document step by step in the Scala programming language
You may also check:How to resolve the algorithm Inheritance/Multiple step by step in the D programming language