Skip to content

Commit

Permalink
Physics Prob
Browse files Browse the repository at this point in the history
  • Loading branch information
Roaming Gamer, LLC committed Jun 24, 2018
1 parent 82fdb63 commit dbfa1ed
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 0 deletions.
Binary file added AskEd/2018/06/physicsProb.zip
Binary file not shown.
30 changes: 30 additions & 0 deletions AskEd/2018/06/physicsProb/build.settings
@@ -0,0 +1,30 @@
-- =============================================================
-- Minimalistic 'starter' build.settings
-- =============================================================
-- https://docs.coronalabs.com/guide/distribution/buildSettings/index.html
-- https://docs.coronalabs.com/guide/tvos/index.html
-- https://docs.coronalabs.com/guide/distribution/win32Build/index.html
-- https://docs.coronalabs.com/guide/distribution/osxBuild/index.html
-- =============================================================

local orientation = 'portrait' -- portrait, landscapeRight, ...


settings = {
-------------------------------------------------------------------------------
-- Orientation Settings
-------------------------------------------------------------------------------
orientation = {
default = orientation,
supported = { orientation },
},


--[[
build =
{
neverStripDebugInfo = true,
},
--]]

}
13 changes: 13 additions & 0 deletions AskEd/2018/06/physicsProb/config.lua
@@ -0,0 +1,13 @@
-- =============================================================
-- Minimalistic 'starter' config.lua
-- =============================================================
-- https://docs.coronalabs.com/guide/basics/configSettings/index.html
-- =============================================================
application = {
content = {
width = 640,
height = 960,
scale = "letterbox",
fps = 60,
},
}
Binary file added AskEd/2018/06/physicsProb/fillT.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AskEd/2018/06/physicsProb/fillW.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions AskEd/2018/06/physicsProb/main.lua
@@ -0,0 +1,79 @@
io.output():setvbuf("no")
display.setStatusBar(display.HiddenStatusBar)
-- =====================================================
--require "ssk2.loadSSK"
--_G.ssk.init( { measure = false } )
--ssk.meters.create_fps(true)
--ssk.meters.create_mem(true)
--ssk.misc.enableScreenshotHelper("s")
-- =====================================================
local cx = display.contentCenterX
local cy = display.contentCenterY
local fullw = display.actualContentWidth
local fullh = display.actualContentHeight
local left = cx - fullw/2
local right = cx + fullw/2
local top = cy - fullh/2
local bottom = cy + fullh/2
-- == Uncomment following lines if you need physics
local physics = require "physics"
physics.start()
physics.setGravity(0,0)
physics.setDrawMode("hybrid")


local group = display.newGroup()

local leftWall = display.newRect(group,0,0,5, display.contentHeight )
local rightWall = display.newRect (group,display.contentWidth, 0, 5, display.contentHeight)
local topWall = display.newRect (group,0, 0, display.contentWidth, 5)
local bottomWall = display.newRect (group,0, display.contentHeight, display.contentWidth, 5)
topWall.anchorX = 0
leftWall.anchorY = 0
leftWall.anchorX = 0
rightWall.anchorY = 0
bottomWall.anchorY = 0
bottomWall.anchorX = 0
local player = display.newRect( group,display.contentCenterX,740, 280, 401 )
physics.addBody (leftWall, "static", { bounce = 0.2} )
physics.addBody (rightWall, "static", { bounce = 0.2} )
physics.addBody (topWall, "static", { bounce = 0.2} )
physics.addBody (bottomWall, "static", { bounce = 0.2} )
physics.addBody( player ,"dynamic", {density=3.0, bounce=0.2})

local function reset()
print('resetting')
player.x = cx
player.y = cy
end


--[[
local function tiltGravity( event )
print(event.xGravity, event.yGravity, event.isShake )
physics.setGravity( 40 * event.xGravity, 40 * event.yGravity )
if event.isShake then
reset()
end
end; Runtime:addEventListener("accelerometer", tiltGravity)
--]]
local function fakeTilt( event )
print(event.xGravity, event.yGravity, event.isShake )
physics.setGravity( 40 * event.xGravity, 40 * event.yGravity )
if event.isShake then
reset()
end
end
timer.performWithDelay( 250,
function()
local event = {}
event.xGravity = math.random(-100,100)/100
event.yGravity = math.random(-100,100)/100
event.isShake = false
--event.isShake = math.random(1,100) > 90
fakeTilt(event)
end, -1 )
Binary file added AskEd/2018/06/physicsProb/protoBackX.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions AskEd/2018/06/physicsProb/ssk2j.bat
@@ -0,0 +1,2 @@
rmdir ssk2
mklink /j .\ssk2 X:\Work\00_CurentProjects\Corona\SSK2\ssk2

0 comments on commit dbfa1ed

Please sign in to comment.