This is my first complete Codea game. The code looks pretty trashy, but that’s because I’m used to rblxlua. The objective of the game is to challenge your friends to a duel to see who can tap the fastest. Have fun!
--# Main
-- Tap Em Vs
-- Use this function to perform your initial setup
function setup()
displayMode(FULLSCREEN_NO_BUTTONS)
p1=0
p2=0
V=0
Vs=1
Time = 10*60
Time2 = 4*60
Start = false
End = false
end
-- This function gets called once every frame
function draw()
V=V+Vs
if V>=20 then Vs=-Vs end
if V<=-40 then Vs=-Vs end
background(52, 24, 230, 255)
-- Do your drawing here
fill(255, 0, 17, 255)
rect(-1,-1,(WIDTH/2), HEIGHT+2)
fill(52, 24, 230, 255)
fontSize(40)
text("Player1: "..p1, WIDTH/4, HEIGHT/2)
fill(255, 0, 17, 255)
text("Player2: "..p2, (WIDTH/4)*3, HEIGHT/2)
if Time <= 0 then
End=true
Time2=Time2-1
if p1>p2 then
fill(255, 255, 255, 255)
text("Player 1 Wins!", WIDTH/2, (HEIGHT/8)*7)
speech.stop()
speech.say("Player 1 Wins")
else
fill(255, 255, 255, 255)
text("Player 2 Wins!", WIDTH/2, (HEIGHT/8)*7)
speech.stop()
speech.say("Player 2 Wins")
end
if Time2 <=1 then
setup()
end
else
if Start ~= true then
fill(255, 255, 255, 255)
text("Start Tapping to begin!!!", WIDTH/2, (HEIGHT/8)*7)
rotate(V)
sprite("Documents:Hand", WIDTH/4, HEIGHT/2)
else
if End ~= true then
Time = Time -1
fill(255, 255, 255, 255)
text(math.floor(Time/60), WIDTH/2, (HEIGHT/8)*7)
end
end
end
end
function touched(Touch)
if End == true then return end
if Touch.state == BEGAN and Start == false then Start = true return end
if Touch.state == BEGAN then
if Touch.x > WIDTH/2 then
p2=p2+1
sound(SOUND_PICKUP, 25264)
else
p1=p1+1
sound(SOUND_PICKUP, 25300)
end
end
end