Skip to content

Instantly share code, notes, and snippets.

@Koloss0
Koloss0 / PhongPointLight.txt
Last active January 31, 2019 00:16
This is Lua code that can be copied and pasted into a new project on the Codea IOS app. It includes a 3D scene lit by a Phong lighting shader. There are also some useful functions that I've written that can be used to easily add vertices, normals & texture coordinates to meshes; such as: addCube, addEllipse & addCylinder.
--# Main
function setup()
-- Set this to true or false to activate/deactivate the lighting shader
useShader = true
rotX,rotY = 0.2,1.3 -- camera rotation
camDist = 100 -- distance from the camera to origin
camOrigin = vec3(0,0,0) -- point of which the camera orbits
lightColour = color(255, 255, 255, 255)
@Koloss0
Koloss0 / Corwin
Created March 26, 2017 22:05
A 3D game for the Codea app
--# Main
-- Dimensions of screen: 1024,768
Worlds = {}
function Worlds.addTri(pos1,pos2,pos3,addTex,col,world)
local col,world = color(255),Worlds.town
local m = world.mesh
do
verts = m.vertices
verts[#verts+1],verts[#verts+2],verts[#verts+3] = pos1,pos2,pos3
@Koloss0
Koloss0 / gist:19a23d2236456bb53d9f881a773becdf
Last active September 27, 2016 22:27
Voxel Based FPS 1
--# Main
-- FPS
displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)
-- Use this function to perform your initial setup
function setup()
Player.chunkX = math.ceil(Player.x/1600)
Player.chunkZ = math.ceil(Player.z/1600)
do