Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~~
- function setup()
- supportedOrientations(ANY)
- balles = {}
- x = 0
- oi = 1
- max = 150
- maxer = 0
- maxGreat = 5
- star = {}
- be = false
- displayMode(FULLSCREEN)
- supportedOrientations(PORTRAIT)
- time_start=ElapsedTime
- frames = 0
- FPS = 60
- wall1 = physics.body(EDGE,vec2(0,0),vec2(0,HEIGHT))
- wall2 = physics.body(EDGE,vec2(0,0),vec2(WIDTH,0))
- wall3 = physics.body(EDGE,vec2(WIDTH,0),vec2(WIDTH,HEIGHT))
- wall4 = physics.body(EDGE,vec2(WIDTH,HEIGHT),vec2(0,HEIGHT))
- wall1.type = STATIC
- wall2.type = STATIC
- wall3.type = STATIC
- wall4.type = STATIC
- wall1.restitution = .5
- wall2.restitution = .5
- wall3.restitution = .5
- wall4.restitution = .5
- ~~
- if be then
- for i=1, 78 do
- table.insert(star, i, physics.body(CIRCLE, math.random(1,5)))
- star[i].x = math.random(0, WIDTH)
- star[i].y = math.random(0, HEIGHT)
- star[i].type = STATIC
- end
- end
- ~~ finishes the check if stars are gonna be rendered or not(and its loop)
- end
- ~~
- ~~
- function touched(touch)
- ~~
- if touch.state == ENDED then
- else
- ~~
- if x<max then
- table.insert(balles, x, physics.body(POLYGON,vec2(touch.x-10, touch.y+10),
- vec2(touch.x-10, touch.y-10),
- vec2(touch.x+10, touch.y-10),
- vec2(touch.x+10, touch.y+10)))
- balles[x].type = DYNAMIC
- x = x + 1
- else
- if maxer < maxGreat then
- table.insert(balles, x, physics.body(CIRCLE, math.random(25,40)))
- maxer = maxer + 1
- balles[x].x = touch.x
- balles[x].y = touch.y
- balles[x].type = DYNAMIC
- balles[x].density = balles[x].radius
- end
- ~~ --finishes the check of max particules
- end
- ~~finishes check for touch
- end
- ~~ final end
- end
- -- This function gets called once every frame
- function draw()
- physics.gravity(Gravity)
- background(0, 0, 0, 10)
- strokeWidth(3)
- stroke(255, 255, 255, 255)
- sprite("Documents:stars",WIDTH/2,HEIGHT/2)
- debugText()
- ~~
- for k, ball in pairs(balles) do
- fill(math.random(0,255),math.random(0,255), math.random(0,255), math.random(0,255))
- end
- ~~
- ~~
- for a, stars in pairs(star) do
- strokeWidth(.5)
- fill(math.random(0,255),math.random(0,255), math.random(0,255), math.random(0,255))
- ellipse(stars.x, stars.y, stars.radius*2)
- end
- ~~
- FPS = frames / ( ElapsedTime - time_start)
- frames=frames+1
- end
- function debugText()
- fill(255)
- font("Georgia-Italic")
- textSize(5)
- textMode(CORNER)
- text("Particles alive: ", 10, 1000)
- text("Little particules: "..x.. "/" ..max, 10, 980)
- text("Big particules: "..maxer.. "/" ..maxGreat, 10, 960)
- text("FPS: " ..FPS, WIDTH-60, 1000)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement