Hello! My Twitter is @Cvax4.
This is a very** easy** game… I am doing a real game ---- It will has many things.
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
-- Use this function to perform your initial setup
function setup()
print("Hello World!")
-- effect
-- speed
ballspeed = 3.8
yourspeed = 5
speedtime = 300
speedrandom = 0
isspeed = false
-- invisible
invrandom = 0
invtime = 400
isinv = false
inv = 255
--
font("Futura-Medium")
--[[
c1 = math.random(1,255)
c2 = math.random(1,255)
c3 = math.random(1,255)
--]]
yourx = 700 - 700%yourspeed
youry = 950 - 950%yourspeed
mbx = WIDTH/2
mby = HEIGHT/2
ballx = math.random(25,WIDTH/2-100)
bally = math.random(25,HEIGHT/2-100)
ballx = ballx - ballx%ballspeed
bally = bally - bally%ballspeed
ballmbx = yourx - yourx%ballspeed
ballmby = youry - youry%ballspeed
game = 1
gamestart = false
------------------
time = 0
sec = 0
------------------
finaltouchx = 0
finaltouchy = 0
iii = 0
------------------
-- effect
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
background(152, 59, 181, 107)
--[[ if CurrentTouch.x == 0 and CurrentTouch.y == 0 and gamestart == false then
game = 2
gamestart =0
end --]]
-- print("1 "..game)
if CurrentTouch.x == 0 and CurrentTouch.y == 0 and gamestart == false then
fontSize(150)
fill(0, 143, 255, 255)
text("Avoid it!",WIDTH/2,HEIGHT/2+200)
fontSize(30)
text("Touch the screen to start game",WIDTH/2,HEIGHT/2)
text("V0.3 By Soul Studio",WIDTH/2,40)
end
if CurrentTouch.x ~= 0 and CurrentTouch.y ~= 0 and gamestart == false then
game = 2
end
-- game = 2
-- print("2 "..game)
if game == 2 then
time = time + 0.5
sec = string.format("%.2f",time/60)
-- fontSize(30)
-- fill(255, 0, 0, 115)
-- text(sec,WIDTH/2,HEIGHT/2)
gamestart = true
stroke(255, 255, 255, 125)
-- line(yourx,youry,mbx,youry)
line(yourx,youry,mbx,mby)
-----------------------------------------------
if CurrentTouch.state == ENDED or CurrentTouch.state == MOVING then
mbx = CurrentTouch.x - CurrentTouch.x%yourspeed
mby = CurrentTouch.y - CurrentTouch.y%yourspeed
print(mbx,mby,yourx,youry)
end
if mbx > yourx then
yourx = yourx - yourx%yourspeed
yourx = yourx + yourspeed
end
if mbx < yourx then
yourx = yourx - yourx%yourspeed
yourx = yourx - yourspeed
end
if mby > youry and mbx == yourx then
youry = youry + yourspeed
line(yourx,youry,mbx,mby)
end
if mby < youry and mbx == yourx then
youry = youry - yourspeed
end
fill(0, 104, 255, 255)
stroke(255, 255, 255, 255)
ellipse(yourx,youry,50)
-- print(yourx,youry)
fill(255, 93, 0, 100)
-- ellipse(mbx,mby,150)
----------------------------------------------
fill(255, 0, 0, inv)
--[[
if ballmbx > ballx then
ballx = ballx + ballspeed
end
if ballmbx < ballx then
ballx = ballx - ballspeed
end
if ballmby > bally then
bally = bally + ballspeed
end
if ballmby < bally then
bally = bally - ballspeed
end
--]]
ballx = move(ballx,bally,ballmbx,ballmby,ballspeed-1.25,1)
bally = move(ballx,bally,ballmbx,ballmby,ballspeed-1.25,2)
ballmbx = yourx - yourx%ballspeed
ballmby = youry - youry%ballspeed
stroke(255, 255, 255, inv)
ellipse(ballx,bally,50)
-- print(ballx,yourx)
------------------------------
-- print(speedrandom)
-- text(speedrandom,WIDTH/2,HEIGHT-50)
if isspeed == false then
speedrandom = math.random(1,100)
end
if speedrandom >= 75 then
isspeed = true
ballspeed = 4.2
fontSize(30)
fill(255, 0, 0, 255)
text("Faster : "..math.floor(speedtime/60),WIDTH/2,HEIGHT/2)
speedtime = speedtime - 1
if speedtime == 0 then
ballspeed = 3.2
speedtime = 300
isspeed = false
end
end
if speedrandom >= 50 and speedrandom < 75 then
isspeed = true
yourspeed = 7
fontSize(30)
fill(0, 165, 255, 255)
text("Faster : "..math.floor(speedtime/60),WIDTH/2,HEIGHT/2)
speedtime = speedtime - 1
if speedtime == 0 then
yourspeed = 5
speedtime = 300
isspeed = false
end
end
if speedrandom < 50 then
isspeed = true
speedtime = speedtime - 1
if speedtime <= 0 then
speedtime = 300
isspeed = false
end
end
---- speed
if isinv == false then
invrandom = math.random(1,100)
end
if invrandom >= 80 then
isinv = true
if inv > 0 then
inv = inv - 2
if inv < 0 then
inv = 0
end
end
invtime = invtime - 1
if invtime <= 0 then
invtime = 300
inv = 255
isinv = false
end
end
if invrandom < 80 then
isinv = true
invtime = invtime - 1
if invtime <= 0 then
invtime = 400
if inv <= 255 then
inv = inv + 1
else isinv = false
end
-- isinv = false
end
end
---------------Effect-------------
if math.abs(ballx - yourx) < 30 and math.abs(bally - youry) < 30 then
finaltouchx = CurrentTouch.x
finaltouchy = CurrentTouch.y
game = 3
end
end
if game == 3 then
fontSize(150)
fill(0, 120, 255, 255)
text(sec,WIDTH/2,HEIGHT/2+150)
fontSize(30)
text("Touch twice to restart game!",WIDTH/2,HEIGHT/2)
if (CurrentTouch.x ~= finaltouchx or CurrentTouch.y ~= finaltouchy) and CurrentTouch.state == ENDED then
iiii = 1
end
if iiii == 1 and CurrentTouch.state == BEGAN then
restart()
end
end
-- This sets the line thickness
strokeWidth(5)
-- Do your drawing here
end
function move(leftx,upy,rightx,downy,speed,tf)
if xx == nil then xx = leftx end
if yy == nil then yy = upy end
if bs == nil then bs = 0 end
v1=vec2(leftx,upy)
v2=vec2(rightx,downy)
x = v1:dist(v2)
Time = x/speed
speedx = (math.abs(rightx-leftx))/Time
speedy = (math.abs(downy-upy))/Time
--if bs == 0 then
if (rightx > xx) and (downy > yy) then bs = 1 end
if (rightx < xx) and (downy > yy) then bs = 2 end
if (rightx > xx) and (downy < yy) then bs = 3 end
if (rightx < xx) and (downy < yy) then bs = 4 end
-- end
if (bs == 1) and ((rightx-xx >= 0) or (downy-yy >= 0)) then
xx = xx + speedx
yy = yy + speedy
-- print(xx.."=xx")
-- print(xx,yy)
end
if (bs == 2) and ((xx-rightx >= 0) or (downy-yy >= 0)) then
xx = xx - speedx
yy = yy + speedy
-- print(xx,yy)
end
if (bs == 3) and ((rightx-xx >= 0) or (yy-downy >= 0)) then
xx = xx + speedx
yy = yy - speedy
-- print("WOWOWOWOW")
-- print(xx,yy)
end
if (bs == 4) and ((xx-rightx >= 0) or (yy-downy >= 0)) then
xx = xx - speedx
yy = yy - speedy
-- print(xx,yy)
end
-- print(bs,speedx)
-- sprite(picture_name,xx,yy,wid,hei)
if tf == 1 then return xx end
if tf == 2 then return yy end
-- ellipse(xx,yy,40)
end