Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

TIC-80

Fantasy computer for making, playing and sharing tiny games. · By Nesbox

'Tunnel' mini-demo )

A topic by alrado created Feb 09, 2017 Views: 698 Replies: 9
Viewing posts 1 to 5
(+2)

Inspired by Philippo demo I wrote this ) You can control with the cursor.

-- 'tunnel' mini-demo by Al Rado
-- constants, change them for different effects
SCR_WIDTH = 240
SCR_HEIGHT = 136
MAX_COLOR = 15
COLOR_SWITCH_PERIOD = 100
COLOR_MOVE_SPEED = 2
SPEED = 1/800
DEVIATION = 150
RECT_STEP = 4
RECT_START_W = 30
RECT_START_H = 15
SIN_COEFF = 0.67 
SHIFT_DELTA = 0.03
-- variables
shiftX = 0
shiftY = 0
function TIC()
  if btn(0) then shiftY=shiftY-SHIFT_DELTA end
  if btn(1) then shiftY=shiftY+SHIFT_DELTA end
  if btn(2) then shiftX=shiftX-SHIFT_DELTA end
  if btn(3) then shiftX=shiftX+SHIFT_DELTA end
  -- calc base variables 
  slowedTime = time()*SPEED
  rectCount = (SCR_WIDTH - RECT_START_W)/ RECT_STEP
  -- draw rectangles
  cls()
  for i=0, rectCount do  
    stepX = (SCR_WIDTH - RECT_START_W)/ rectCount
    stepY = (SCR_HEIGHT - RECT_START_H)/ rectCount
    width = RECT_START_W + i*stepX
    height = RECT_START_H + i*stepY
    x = (math.cos(slowedTime) + shiftX) * DEVIATION/i
    y = (math.sin(slowedTime*SIN_COEFF) + shiftY) * DEVIATION/i
    color = (i/COLOR_SWITCH_PERIOD - slowedTime*COLOR_MOVE_SPEED)%MAX_COLOR + 1
    rectb(SCR_WIDTH/2 + x - width/2, SCR_HEIGHT/2 + y - height/2, 
      width, height, color)
  end 
  -- additionall draw 
  rectb(0, 0, SCR_WIDTH, SCR_HEIGHT, color)
  poke(0x3FF8, color)
end

Developer (1 edit)

Great example of how to use BORDER COLOR.

Thanks

Thank you!

(1 edit)

does Android version have a copy/paste function? I tried to paste this demo into a new cart, but no luck. What is the best way to test this demo on a phone?

Update: it does now! Thanks Dev! Works like a charm

Developer

You can use CTRL+C/V keys in theory, but I've not even tested it.

Please make an issue here https://github.com/nesbox/tic.computer/issues

(+1)

I confirm the problem on Android devices.

Maybe add a buttons to copy/paste in the code editor?

Well done.

Thanks!

This demo is awesome! Please add a shooter ship/or crosshair and some 3D laser blasting. Enemies to avoid and blast would be great too.

Thanks! Sounds great, I can try )