3D help[CLOSED]

I need help making the players head move wen ever I touch the screen, I’m not sure if I havet to make a player function or a touch function please help

TAP 1

– Use this function to perform your initial setup
function setup()
displayMode(STANDARD)

availableTests = { Test2(), Test1() }
currentTest = availableTests[1]

parameter.integer("SceneSelect",1,#availableTests,1)

parameter.number("Size",50,500,150)
parameter.number("CamHeight", 0, 1000, 300)
parameter.number("Angle",-360, 360, 0)
parameter.number("FieldOfView", 10, 140, 45)


the3DViewMatrix = viewMatrix()
parameter.watch("the3DViewMatrix")

-- These watches are evaluated after draw() is finished
-- Thus the contents are not as interesting
parameter.watch("viewMatrix()")
parameter.watch("modelMatrix()")
parameter.watch("projectionMatrix()")

end

– This function gets called once every frame
function draw()
– Set the currentTest to the selected scene
currentTest = availableTests[SceneSelect]

-- First arg is FOV, second is aspect
perspective(FieldOfView, WIDTH/HEIGHT)

-- Position the camera up and back, look at origin
camera(0,CamHeight,-300, 0,0,0, 0,1,0)

-- Write this into a variable so we can watch() it
-- at this point in time
the3DViewMatrix = viewMatrix()

-- This sets a dark background color 
background(83, 181, 228, 255)

-- Do your drawing here
currentTest:draw()    

-- Restore orthographic projection
ortho()

-- Restore the view matrix to the identity
viewMatrix(matrix())

-- Draw a label at the top of the screen
fill(255)
font("ArialRoundedMTBold")
fontSize(20)

text(currentTest:name(), WIDTH/2, HEIGHT - 30)

end

Test1 = class()

function Test1:name()
return “Codea Primitives in 3D”
end

function Test1:draw()

background(144, 209, 144, 255)
sprite("Documents:Logo", 1, 1, 300)

end

TAB 2

Test2 = class()

function Test2:name()
return “SuperCraft V1.0 Beta X”

end

function Test2:init()
– all the unique vertices that make up a cube
local vertices = {
vec3(-0.5, -0.5, 0.5), – Left bottom front
vec3( 0.5, -0.5, 0.5), – Right bottom front
vec3( 0.5, 0.5, 0.5), – Right top front
vec3(-0.5, 0.5, 0.5), – Left top front
vec3(-0.5, -0.5, -0.5), – Left bottom back
vec3( 0.5, -0.5, -0.5), – Right bottom back
vec3( 0.5, 0.5, -0.5), – Right top back
vec3(-0.5, 0.5, -0.5), – Left top back
}

-- now construct a cube out of the vertices above
local cubeverts = {
  -- Front
  vertices[1], vertices[2], vertices[3],
  vertices[1], vertices[3], vertices[4],
  -- Right
  vertices[2], vertices[6], vertices[7],
  vertices[2], vertices[7], vertices[3],
  -- Back
  vertices[6], vertices[5], vertices[8],
  vertices[6], vertices[8], vertices[7],
  -- Left
  vertices[5], vertices[1], vertices[4],
  vertices[5], vertices[4], vertices[8],
  -- Top
  vertices[4], vertices[3], vertices[7],
  vertices[4], vertices[7], vertices[8],
  -- Bottom
  vertices[5], vertices[6], vertices[2],
  vertices[5], vertices[2], vertices[1],
}

-- all the unique texture positions needed
local texvertices = { vec2(0.03,0.24),
                      vec2(0.97,0.24),
                      vec2(0.03,0.69),
                      vec2(0.97,0.69) }
            
-- apply the texture coordinates to each triangle
local cubetexCoords = {
 
        -- Front
  texvertices[1], texvertices[2], texvertices[4],
  texvertices[1], texvertices[4], texvertices[3],
  -- Right
  texvertices[1], texvertices[2], texvertices[4],
  texvertices[1], texvertices[4], texvertices[3],
  -- Back
  texvertices[1], texvertices[2], texvertices[4],
  texvertices[1], texvertices[4], texvertices[3],
  -- Left
  texvertices[1], texvertices[2], texvertices[4],
  texvertices[1], texvertices[4], texvertices[3],
  -- Top
  texvertices[1], texvertices[2], texvertices[4],
  texvertices[1], texvertices[4], texvertices[3],
  -- Bottom
  texvertices[1], texvertices[2], texvertices[4],
  texvertices[1], texvertices[4], texvertices[3],
}


-- all the unique vertices that make up a cube
local vertices = {
  vec3(-0.5, -0.2,  0.5), -- Left  bottom front
  vec3( 0.5, -0.2,  0.5), -- Right bottom front
  vec3( 0.5,  0.2,  0.5), -- Right top    front
  vec3(-0.5,  0.2,  0.5), -- Left  top    front
  vec3(-0.5, -0.2, -0.5), -- Left  bottom back
  vec3( 0.5, -0.2, -0.5), -- Right bottom back
  vec3( 0.5,  0.2, -0.5), -- Right top    back
  vec3(-0.5,  0.2, -0.5), -- Left  top    back
}


-- now construct a cube out of the vertices above
local slab = {
  -- Front
  vertices[1], vertices[2], vertices[3],
  vertices[1], vertices[3], vertices[4],
  -- Right
  vertices[2], vertices[6], vertices[7],
  vertices[2], vertices[7], vertices[3],
  -- Back
  vertices[6], vertices[5], vertices[8],
  vertices[6], vertices[8], vertices[7],
  -- Left
  vertices[5], vertices[1], vertices[4],
  vertices[5], vertices[4], vertices[8],
  -- Top
  vertices[4], vertices[3], vertices[7],
  vertices[4], vertices[7], vertices[8],
  -- Bottom
  vertices[5], vertices[6], vertices[2],
  vertices[5], vertices[2], vertices[1],
}



-- now we have our blocks

-- Stone Block
self.stone = mesh()
self.stone.vertices = cubeverts
self.stone.texture = "Planet Cute:Stone Block"
self.stone.texCoords = cubetexCoords
self.stone:setColors(255,255,255,255)

-- Dirt Block
self.dirt = mesh()
self.dirt.vertices = cubeverts
self.dirt.texture = "Planet Cute:Dirt Block"
self.dirt.texCoords = cubetexCoords
self.dirt:setColors(255,255,255,255)

-- Grass Block
self.grass = mesh()
self.grass.vertices = cubeverts
self.grass.texture = "Planet Cute:Grass Block"
self.grass.texCoords = cubetexCoords
self.grass:setColors(255,255,255,255)   

-- Water block
self.water = mesh()
self.water.vertices = cubeverts
self.water.texture = "Planet Cute:Water Block"
self.water.texCoords = cubetexCoords
self.water:setColors(255,255,255,100)

    -- Leaves
self.Oak_Leaves = mesh()
self.Oak_Leaves.vertices = cubeverts
self.Oak_Leaves.texture = "Documents:Leaves"
self.Oak_Leaves.texCoords = cubetexCoords
self.Oak_Leaves:setColors(255,255,255,255)


-- Block IDs
self.blocks = { self.grass, self.dirt, self.stone, self.water, self.Oak_Leaves}

-- our scene itself
-- Flat world
--             bottom      middle      top
self.scene = { 

{ {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3}, {2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2}, {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1} },
{ {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3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1,1,1,1,1,1,1,1,1,1,1} } }
end

function Test2:draw()
pushMatrix()
pushStyle()

-- Make a floor
translate(0,-Size/2,0)
rotate(Angle,0,1,0)
rotate(90,1,0,0)

–sprite(“SpaceCute:Background”, 0, 0, 300, 300)

-- render each block in turn
for zi,zv in ipairs(self.scene) do
    for yi,yv in ipairs(zv) do
        for xi, xv in ipairs(yv) do
            -- apply each transform  need - rotate, scale, translate to the correct place
            resetMatrix()
            rotate(Angle,0,1,0)
            
            local s = Size*0.10
            scale(s,s,s)
            
            translate(xi-10, yi-5, zi-10)    -- renders based on corner
                                           -- so -2 fudges it near center
            
            if xv > 0 then
                self.blocks[xv]:draw()
            end
        end
    end
end

popStyle()
popMatrix()

end

Are you talking about moving the camera angle?

#did I help?

bold

You probably want to make a touched(touch) function, and give the player a touched function too.

I pm’d you the solution