Advertisement
Guest User

Codea 3D Beta API Test

a guest
Mar 6th, 2012
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. function setup()
  2.     displayMode(STANDARD)
  3.  
  4.     parameter("Size",50,500,200)
  5.     parameter("CamHeight", 0, 1000, 300)
  6.     parameter("Angle",-180, 180, 0)
  7. end
  8.  
  9. function draw()
  10.    -- First arg is FOV, second is aspect
  11.    perspective(45, WIDTH/HEIGHT)
  12.  
  13.    -- Position the camera up and back, look at origin
  14.    camera(0,CamHeight,-300, 0,0,0, 0,1,0)
  15.  
  16.    -- This sets a dark background color 
  17.    background(40, 40, 50)
  18.  
  19.    -- This sets the line thickness
  20.    strokeWidth(5)
  21.  
  22.    smooth()
  23.    rectMode(CENTER)
  24.  
  25.    -- Make a floor
  26.    translate(0,-Size/2,0)
  27.    rotate(Angle,0,1,0)
  28.    rotate(90,1,0,0)
  29.    sprite("SpaceCute:Background", 0, 0, 300, 300)
  30.  
  31.    -- Rotate and translate the square
  32.    resetMatrix()
  33.    rotate(Angle,0,1,0)
  34.    translate(0, 0, -100)
  35.  
  36.    fill(44, 97, 161, 255)
  37.    rect(0, 0, Size, Size)
  38.  
  39.    resetMatrix()
  40.    rotate(Angle,0,1,0)
  41.    fill(191, 26, 26, 255)
  42.    ellipse(0, 0, Size*0.8)
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement