Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Use this function to perform your initial setup
- function setup()
- displayMode(STANDARD)
- oldangx=0
- oldangy=0
- watch ("angx")
- watch ("angy")
- availableTests = { Test2()}
- currentTest = availableTests[1]
- iparameter("SceneSelect",1,#availableTests,1)
- r=0
- parameter("Size",50,500,150)
- parameter("CamHeight", 0, 1000, 300)
- parameter("Angle",-360, 360, 0)
- parameter("FieldOfView", 10, 140, 45)
- camera(0,0,0)
- the3DViewMatrix = viewMatrix()
- watch("the3DViewMatrix")
- --displayMode(FULLSCREEN_NO_BUTTONS)
- print("This example tracks multiple touches and colors them based on their ID")
- -- keep track of our touches in this table
- touches = {}
- dx= 0
- dy=0
- lx=-1
- ly=-1
- rx=-1
- ry=-1
- olx=-1
- oly=-1
- orx=-1
- ory=-1
- ran =0
- ranl=0
- ranr=0
- ld =0
- rd =0
- angx =0
- tlx=0
- tlz=0
- angy =0
- le=0
- re=0
- rr=0
- watch("WIDTH/10")
- watch("oldangx")
- watch("oldangy")
- watch("angx")
- watch("angy")
- watch ("dx")
- watch ("dy")
- watch ("lx")
- watch ("ly")
- watch ("rx")
- watch ("ry")
- watch ("olx")
- watch ("oly")
- watch("rdx")
- watch ("orx")
- ry=0
- watch ("ory")
- watch("ran")
- lo=0
- watch ("tlx")
- watch("tlz")
- watch("oldrx")
- watch("oldry")
- oldrx=0
- oldry=0
- ro=0
- dx=0
- -- These watches are evaluated after draw() is finished
- -- Thus the contents are not as interesting
- watch("viewMatrix()")
- watch("modelMatrix()")
- watch("projectionMatrix()")
- end
- function touched(touch)
- if touch.state == ENDED then
- touches[touch.id] = nil
- else
- touches[touch.id] = touch
- end
- end
- -- This function gets called once every frame
- function draw()
- -- Set the currentTest to the selected scene
- -- boarder=nil
- 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(40, 40, 50)
- -- 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("MyriadPro-Bold")
- fontSize(30)
- text(currentTest:name(), WIDTH/2, HEIGHT - 30)
- --background(0, 0, 0, 255)
- lx=-1
- ly=-1
- rx=-1
- ry=-1
- ran=0
- ranl=0
- ranr=0
- rdx=0
- for k,touch in pairs(touches) do
- ran =1
- ldx =0
- ldy=0
- rdx=0
- -- print(rr)
- rdy=0
- -- Use the touch id as the random seed
- math.randomseed(touch.id)
- -- This ensures the same fill color is used for the same id
- fill(255, 255, 255, 255)
- if touch.state== ENDED then
- oldangx=angx
- oldangy=angy
- if touch.prevx <0 then
- lx=-1
- ly=-1
- olx=-1
- oly=-1
- else
- rx=-1
- ry=-1
- orx=-1
- ory=-1
- end
- else
- if touch.x < WIDTH/2 then
- ranl =1
- lx = touch.x
- ly = touch.y
- if olx ==-1 then
- olx = lx
- oly = ly
- end
- if olx == lx or oly ==ly then
- ldx=0
- ldy=0
- else
- ldx = touch.deltax
- ldy = touch.deltay
- end
- else
- ranr=1
- rx = touch.x
- ry = touch.y
- if orx ==-1 then
- print("down")
- rr=0
- orx = rx
- ory = ry
- else
- rr=1
- end
- --print(touch.x-touch.prevX)
- -- print(touch.deltaX)
- -- print(touch.prevX)
- if rr==1 then
- if touch.prevX-touch.x==0 then
- print(rdx)
- rdx=0
- print(rdx)
- else
- print(touch.deltaX)
- rdx = touch.deltaX
- print(rdx)
- end
- print (touch.prevY)
- if touch.prevY-touch.y==0 then
- print(rdy)
- rdy=0
- print(rdy)
- else
- print(touch.deltaY)
- rdy = touch.deltaY
- print(rdy)
- end
- else
- r=1
- end
- if oldrx==rx then
- rdx=0
- end
- if oldry==ry then
- rdy=0
- end
- if orx == rx or ory == ry then
- rdx=0
- rdy=0
- else
- end
- oldrx=rx
- oldry=ry
- end
- -- Draw ellipse at touch position
- end
- -- ellipse(touch.x, touch.y, 100, 100)
- end
- if r==1 then
- if rdx==0 and rdy==0 then
- r=0
- elseif rdx > 0 then
- rdx = rdx - .5
- elseif rdy>0 then
- rdy=rdy-.5
- end
- end
- if ran==0 then
- ldx=0
- ldy=0
- rdx=0
- rdy=0
- if ranl==0 then
- olx=-1
- oly=-1
- end
- if ranr==0 then
- orx=-1
- ory=-1
- end
- end
- if ranr==0 then
- --rr=0
- else
- --rr=1
- end
- le=1
- re=1
- if ran==0 then
- ldx=0
- ldy=0
- rdx=0
- rdy=0
- if ranl==0 then
- olx=-1
- oly=-1
- end
- if ranr==0 then
- -- oldangx =angx
- -- oldangy =angy
- orx=-1
- ory=-1
- end
- if ranl ==1 or ranr == 1 then
- print("s")
- end
- if ranl==0 then
- olx=-1
- oly=-1
- end
- if ranr==0 then
- orx=-1
- ory=-1
- end
- if ranr==0 then
- ro=0
- end
- end
- popStyle()
- fill(255,255,255,255)
- strokeWidth(15)
- if le ==1 then
- if olx==-1 then
- else
- if lx==-1 then
- olx=-1
- else
- line(olx,oly,lx,ly)
- end
- end
- end
- if re==1 then
- if orx==-1 then
- else
- if rx==-1 then
- orx=-1
- else
- line(orx,ory,rx,ry)
- end
- end
- -- boarder = nil
- strokeWidth(0)
- if orx ==-1 then
- rx=-1
- else
- ellipse(orx,ory,100,100)
- end
- end
- if le==1 then
- if olx ==-1 then
- lx=-1
- else
- ellipse(olx,oly,100,100)
- end
- end
- if re==1 then
- if orx ==-1 then
- rx=-1
- else
- ellipse(rx,ry,50,50)
- end
- end
- if le==1 then
- if olx ==-1 then
- lx=-1
- else
- ellipse(lx,ly,50,50)
- end
- end
- pushStyle()
- if ranr == 1 then
- if angx ==0 and angy ==0 then
- if oldangx <= 0 then
- else
- angx = oldangx
- angy=oldangy
- end
- if oldangy <= 0 then
- else
- angx = oldangx
- angy=oldangy
- end
- end
- -- if rr==1 then
- angx =(angx+rdx/10)--(rx-orx)/10)
- angy =(angy+rdy/10)--(ry-ory)/10)
- oldangx=rdx
- oldangx = angx
- oldangy = oldangy
- else
- --oldangx=angx
- -- oldangy=angy
- --end
- end
- if ranl ==1 then
- dx = dx + lx-olx
- dy = dy + ly-oly
- end
- translate(dy,dx,0)
- print("aa")
- print(boarder)
- if boarder == 1 then
- displayMode(FULLSCREEN_NO_BUTTONS)
- end
- if boarder ==2 then
- displayMode(STANDARD)
- end
- if rx>WIDTH -WIDTH/15 then
- boarder = 1
- print("b")
- end
- print("a")
- print(rx)
- if lx<WIDTH/15 then
- if lx==-1 then
- else
- boarder=2
- end
- end
- if rr==1 then
- rdx=rdx
- print(rdx)
- end
- tlz = .2*(ly-oly) +tlz
- tlx=tlx + .2*(lx-olx)
- strokeWidth(5)
- --line(WIDTH-WIDTH/10,0,WIDTH-WIDTH/10,HEIGHT)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement