Added one leeway, can add multiple end commands to a single line. End commands take up a lot of lines.
Yeah it’s going to be a challenge to think of a game simple enough.
At the instant I thought of cookie clicker, but that’s just pretty basic and not very amusing. I’ll try to think of other better stuff
I think I’ll give this a try. just need to come up with an idea that can fit within that :).
I’ll give it a go!
No outside links, Codea assets only.
Tyrian has a bunch of decent assets. Hardest part will be a good background.
To quite noone… “can we use loadstring to read code from a saved file? XD”
I’ll be entering in this one for sure
That said, you should move it to the “competition” area instead of the general one
You have no idea how long I have been waiting for a competition. I’ll cook up something.
To quote @Briarfox, “Can http be used ? >:)”
@jmv I thought about both, but I liked the idea that the player teleports, and I really like the fixed locations. ^.^
Both of those are pretty fun games! Good job guys! I need to finish mine up.
Here’s a game I made for a fifty line challenge that I never got to enter (note: not my actual entry, just for fun). Rotate the circle to collect the red dots, don’t lift your finger or let the red ones get to the center or you lose!
function setup()
if not readLocalData("highscore") then saveLocalData("highscore",0) end
t,tt,e,score,angle=0,ElapsedTime,{},0,math.pi/2
end
function draw()
if ElapsedTime-t > 2-(1*(tt/120)) then
q,t = (math.random()-.5)*math.pi,ElapsedTime
if math.random()>.5 then
e[#e+1],e[-#e-1]=vec2(WIDTH/2+700*math.cos(q),HEIGHT/2+700*math.sin(q)),-5
else
e[#e+1],e[-#e-1]=vec2(WIDTH/2+700*math.cos(q+math.pi/2),HEIGHT/2+700*math.sin(q+math.pi/2)),5
end
end
tt = tt + DeltaTime
if tt>60 then tt=60 end
background(40, 40, 50)
fill(0,0)
stroke(255)
strokeWidth(5)
ellipse(WIDTH/2,HEIGHT/2,300)
strokeWidth(100)
ellipse(WIDTH/2+150*math.cos(angle),HEIGHT/2+150*math.sin(angle),50)
stroke(255,0,0)
for a=#e,1,-1 do
e[a]=e[a]+vec2(e[-a],0):rotate(math.atan2(e[a].y-HEIGHT/2,e[a].x-WIDTH/2))
if e[a]:dist(vec2(WIDTH/2,HEIGHT/2)) < 50 then
ishighscore(true)
table.remove(e,a)
elseif e[a]:dist(vec2(WIDTH/2+150*math.cos(angle),HEIGHT/2+150*math.sin(angle))) < 40 then
score = score + 1
ishighscore()
table.remove(e,a)
else
ellipse(e[a].x,e[a].y,30)
end
end
fill(255)
fontSize(100)
text(score,WIDTH/2,HEIGHT/2)
fontSize(20)
text(readLocalData("highscore"),WIDTH/2,HEIGHT-20)
end
function touched(t)
angle = (math.atan2(t.y-HEIGHT/2,t.x-WIDTH/2))
if t.state==ENDED or t.state==CANCELLED then ishighscore(true) end
end
function ishighscore(reset)
if score>readLocalData("highscore")then saveLocalData("highscore",score)end
if reset then score,tt=0,0 end
end
@Saturn031000 I added 2 lines of code to your program to show you what the cause is that you’re getting .02 or .03 . When the game ends, the ball is still moving around the screen. If it collides with the edge of the screen and you restart the game, you get the .02 .03 error. See the 2 lines below in the “if fsm” that I added the comment to.
if fsm=="dead" then
text("You lasted:\
"..string.format("%.2f", scoreTimer).." seconds", WIDTH/2, HEIGHT/3*2)
text("AGAIN", WIDTH/2, HEIGHT/3)
fill(255, 50)
ellipse(WIDTH/2, HEIGHT/3, 300)
fill(255) -- added this line
ellipse(player.x, player.y, 40) -- added this line
end
Hey guys, here’s my submission to the 100 line challenge. The game is pretty simple. Use the touch screen to move the ship. Try to avoid space mines. Each one you hit costs a life.
function setup()
displayMode(FULLSCREEN)
x = WIDTH/2
y = HEIGHT/2
Otime = 0
Ocount = 1
gS = false
fade = 0
minScore = 0
score = 0
lives = 10
plusLev = 50
levBounus = false
pluslives = 50
level = 0
adlives = false
l = true
m2 = 0
Star = {}
Obs = {}
end
function O()
obs = {x = 1050,y = math.random(0,750)}
table.insert(Obs,obs)
end
function S()
star = {x = 1050, y = math.random(0,750), w = math.random(2,10)}
table.insert(Star,star)
end
function draw()
background(0)
m2 = m2 + 1 -- this plays music in infinite loop
if m2 == 60 * 161 then l = true m2 = 0 end
if l == true then music("Game Music One:Pulsar") l = false end
if gS == false then -- this set condition for start screen
if fade < 255 then fade = fade + 1 end
fill(0, 255, 246, fade)
fontSize(100)
text("Tap to play",WIDTH/2,HEIGHT/2)
end
if gS == true then -- this sets condition for game
S()
fill(255)
fontSize(25)
text(lives,WIDTH-WIDTH+50,HEIGHT-50)
sprite("SpaceCute:Health Heart",WIDTH-WIDTH+75,HEIGHT-50,20,20)
text(score,WIDTH-50,HEIGHT-50)
if score >= plusLev*2 and score <= plusLev*2+10 then -- set levels
table.remove(Obs,i)
if levBonus == true then level = level + 1 Ocount = Ocount + .5 levBonus = false end
if score == plusLev*2+10 then plusLev = plusLev + 50 end
text("Level "..level.. " Complete",WIDTH/2,HEIGHT/2)
end
minScore = minScore + .1 -- paces score count
if minScore >= 1 then score = score + 1 minScore = 0 end
if score == pluslives then adlives = true pluslives = pluslives + 50 end
if adlives == true then lives = lives + 1 adlives = false levBonus = true end
fade = 0
Otime = Otime + DeltaTime -- timer to draw obstical in increments
if Otime > 1/Ocount then O() Otime = 0 end
for i,obs in pairs(Obs) do -- draws obsticals
obs.x = obs.x - 3
sprite("Tyrian Remastered:Mine Spiked Huge",obs.x,obs.y)
if obs.x < -200 then table.remove(Obs,i) end
if x >= obs.x - 75 and x < obs.x + 75 and y >= obs.y - 75 and y < obs.y + 75 then
sprite("Tyrian Remastered:Explosion Huge",obs.x,obs.y)
table.remove(Obs,i)
lives = lives - 1
sound("Game Sounds One:Explode Big")
end
end
for i,star in pairs(Star) do -- draws background
star.x = star.x - 5
sprite("Space Art:Star",star.x,star.y,star.w,star.w)
if star.x < -200 then table.remove(Star,i) end
end
sprite("Space Art:UFO",x,y) -- character
end
if lives < 1 then -- sets condtion for lose screen
table.remove(Obs,i)
gS = false
background(fade,0,0,255)
fill(255,255,255,fade)
fade = fade + 1
fontSize(100)
text("Game Over",WIDTH/2,HEIGHT/2)
fontSize(50)
text("Tap to try again", WIDTH/2-30,HEIGHT/5)
text("score was "..score,WIDTH/2-30,HEIGHT/20)
end
end
function touched(touch)
if lives < 1 or gS == false then -- sets condition for restart
if touch.state == BEGAN then gS = true score = 0 lives = 10
end
end
if touch.state == MOVING then x = touch.x y = touch.y end
end
My submission
Got a little help from SkyTheCoder because I couldn’t get the ship to stop then you stop touching the screen.
The collision is also a bit wonky, I need to figure out how to do round collision boxes.
Touch the left side of screen to move ship left, right side of screen to move ship right.
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
function setup()
ast={}
ship=readImage("Space Art:Red Ship")
asteroid=readImage("Space Art:Asteroid Large")
astFreq=1.5
astSpeed=-9
score=0 -- starting score
timer=0
rectMode(CENTER)
if readLocalData("HS")== nil then
saveLocalData("HS", 0)
end
music("A Hero's Quest:Battle",true,.5)
gameState=0
font("Futura-CondensedExtraBold")
fontSize(64)
fill(0, 255, 0, 255)
shipX=WIDTH/2
shipY=HEIGHT/4
end
function spawn()
table.insert(ast,vec2(math.random(96,WIDTH-96),1152))
end
function draw()
if gameState==0 then
background(0, 0, 0, 255)
text("PLAY",WIDTH/2,HEIGHT/2)
if CurrentTouch.state==BEGAN then
if CurrentTouch.x>WIDTH/2-256 and CurrentTouch.x<WIDTH/2+256
and CurrentTouch.y>HEIGHT/2-128 and CurrentTouch.y<HEIGHT/2+128 then
gameState=1
end
end
end
if gameState==1 then
background(0, 0, 0, 255)
pushStyle()
text("Score: "..score, WIDTH/2, HEIGHT/1.2)
popStyle()
for a,b in pairs(ast) do
sprite(asteroid,b.x,b.y,192,256)
b.y=b.y+astSpeed
end
timer=timer+DeltaTime
if timer>astFreq then
spawn()
spawn()
spawn()
timer=0
end
for a,b in pairs(ast) do
if b.y<-128 then
table.remove(ast,a)
score=score+10
end
end
if CurrentTouch.x <= WIDTH / 2 and CurrentTouch.state ~= ENDED and CurrentTouch.state ~= CANCELLED then
shipX=shipX-12
end
if CurrentTouch.x>WIDTH/2 and CurrentTouch.state ~= ENDED and CurrentTouch.state ~= CANCELLED then
shipX=shipX+12
end
sprite(ship,shipX,shipY,64,96)
for a,b in pairs(ast) do
if b.y-96<=shipY+48 and b.y+160>=shipY-48 and
b.x-96<=shipX+32 and b.x+96>=shipX-32 then
gameState=2
end
end
if shipX-32<0 or shipX+32>WIDTH then
gameState=2
end
end
if gameState==2 then
background(0, 0, 0, 255)
text("RETRY",WIDTH/2,HEIGHT/4)
if score > readLocalData("HS") then
saveLocalData("HS", score)
end
text("Score: "..score, WIDTH/2,HEIGHT/1.2)
text("HighScore: "..readLocalData("HS"),WIDTH/2,HEIGHT/2)
if CurrentTouch.state==BEGAN then
if CurrentTouch.x>WIDTH/2-128 and CurrentTouch.x<WIDTH/2+128
and CurrentTouch.y>HEIGHT/4-64 and CurrentTouch.y<HEIGHT/4+64 then
score=0
gameState=0
shipX=WIDTH/2
for i,t in pairs(ast) do ast[i]= nil
end
end
end
end
end
Classic = class()
function Classic:init(x)
self.b1 = physics.body(CIRCLE, 70)
self.b1.x = WIDTH/2
self.b1.y = HEIGHT * .8
self.b1.color = color(255,250,0,255)
self.points = 0
end
function Classic:draw()
background(255-self.b1.color.r, 255-self.b1.color.g, 255-self.b1.color.b)
fill(0, 0, 0, 255)
rect(-1,0-1,WIDTH/5 + 2, HEIGHT + 2)
fill(127, 127, 127, 255)
rect(WIDTH/5*2-1,0-1,WIDTH/5 + 2, HEIGHT + 2)
fill(255, 255, 255, 255)
rect(WIDTH/5*4-1,0-1,WIDTH/5 + 2, HEIGHT + 2)
fill(self.b1.color)
ellipse(self.b1.x, self.b1.y, self.b1.radius * 2)
fill(255-self.b1.color.r, 255-self.b1.color.g, 255-self.b1.color.b)
fontSize(40)
text(self.points, self.b1.x, self.b1.y)
if self.b1.y < -self.b1.radius then
if self.points > hs then
saveLocalData("hs", self.points)
end
hs = self.points
mode = GameOver()
end
end
function Classic:touched(t)
if vec2(t.x,t.y):dist(vec2(self.b1.x, self.b1.y)) < self.b1.radius and t.state == BEGAN then
self.b1.color.r = math.random(60,240)
self.b1.color.g = math.random(30,240)
self.b1.color.b = math.random(60,240)
self.b1.y = HEIGHT * .8
self.b1.x = WIDTH / 5 * (math.random(5) -1)+ WIDTH/10
self.points = self.points + 1
self.b1.linearVelocity = vec2(0,-self.points * 10)
end
end
GameOver = class()
function GameOver:init()
self.time = os.clock()
end
function GameOver:draw()
background(255, 0, 211, 255)
text("Tap to Play Again", WIDTH/2, HEIGHT/2)
text("High Score: ".. readLocalData("hs"), WIDTH/2, HEIGHT*.8)
text("Current Score: "..hs, WIDTH/2, HEIGHT*.65)
end
function GameOver:touched(touch)
if os.clock() - self.time > .2 then
mode = Classic()
end
end
function setup()
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
hs = readLocalData("hs") or 0
mode = TitleScreen()
end
function draw()
mode:draw()
end
function touched(t)
mode:touched(t)
end
TitleScreen = class()
function TitleScreen:draw()
background(0, 255, 174, 255)
text("[Tap to play]", WIDTH/2, HEIGHT/2)
end
function TitleScreen:touched(t)
mode = Classic()
end
So here’s a second entry just for the hell of it ^.^
Using some really ugly formatting I came up with this, it could most likely be simplified to 100 lines and better formatting, but there weren’t super clear formatting rules, so I didn’t bother, for now.
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
function setup()
if not readLocalData("highscore") then saveLocalData("highscore",0) end
boat,angle,mna,mxa,wheel,wheela,w,p,frame,physics.continuous,b,score,e,time =vec2(WIDTH/2,WIDTH/2+(HEIGHT-WIDTH)),90,0,math.pi,vec2(WIDTH/4, (HEIGHT-WIDTH)),math.pi/2,readImage("Planet Cute:Water Block"), readImage("Tyrian Remastered:Plane Boss"),0,true,{},0,{},ElapsedTime
settween()
end
function draw()
collectgarbage()
background(40, 40, 50)
for i=0,9 do
for j=0,14 do
sprite(w,i*100,HEIGHT-80*j) end end
stroke(255)
for i=#b,1,-1 do
if b[i] and b[i].type then ellipse(b[i].x,b[i].y,10)
if b[i].x < 0 or b[i].x > WIDTH or b[i].y < 0 or b[i].y > HEIGHT then b[i]:destroy()
table.remove(b,i) end end end
stroke(255,0,0)
for i=#e,1,-1 do
if e[i] and e[i].type then sprite("Tyrian Remastered:Evil Orb",e[i].x,e[i].y,60,60) end--ellipse(e[i].x,e[i].y,60) end
if e[i] and e[i].type and e[i].position:dist(boat) < 45 then
setup()
dall()
tween.stop(tr) end
if e[i] and e[i].type and (e[i].x<-30 or e[i].x > WIDTH+30 or e[i].y < HEIGHT-WIDTH-30 or e[i].y > HEIGHT+30) then
e[i]:destroy()
table.remove(e,i) end end
fill(255)
text("Score: "..score.."\
High Score: "..readLocalData("highscore"),75,HEIGHT-20)
noStroke()
rect(0,0,WIDTH,HEIGHT-WIDTH)
fill(0,0)
strokeWidth(5)
ellipse(WIDTH/4,(HEIGHT-WIDTH)/2,HEIGHT-WIDTH+1)
strokeWidth(100)
ellipse(wheel.x,wheel.y,60)
if tx then stroke(255,0,0,125) end
ellipse(3*WIDTH/4,(HEIGHT-WIDTH)/2,(HEIGHT-WIDTH)/2)
translate(boat.x,boat.y)
rotate(angle+90)
sprite(p,0,0,p.width/2,p.height/2)
angle = angle + (wheela-math.pi/2)/(math.pi/2)*2
boat = boat + vec2(2,0):rotate(math.rad(angle))
if boat.y > HEIGHT or boat.y < HEIGHT-WIDTH or boat.x>WIDTH or boat.x < 0 then angle=angle-180 end
if tx then frame = frame + 1
if math.floor(frame/1)%30==0 then
b[#b+1]=physics.body(CIRCLE,5)
b[#b].position,b[#b].gravityScale,b[#b].bullet=boat,0,true
b[#b]:applyForce(vec2(100,0):rotate(math.rad(angle))) end end end
function touched(t)
if not tw and t.state == BEGAN and vec2(t.x,t.y):dist(wheel) < 60 then
tw=t end
if tw and t.id==tw.id and t.state == MOVING then
wheela = math.atan2(t.y-(HEIGHT-WIDTH)/2,t.x-WIDTH/4)
if -wheela > mxa-math.pi/2 then wheela = mxa end
if wheela < mna then wheela = mna end
wheel=vec2(WIDTH/4+((HEIGHT-WIDTH)/2)*math.cos(wheela),((HEIGHT-WIDTH)/2)+((HEIGHT-WIDTH)/2)*math.sin(wheela)) end
if tw and t.state == ENDED and t.id == tw.id then
tw,wheela=nil,math.pi/2
wheel=vec2(WIDTH/4+((HEIGHT-WIDTH)/2)*math.cos(wheela),((HEIGHT-WIDTH)/2)+((HEIGHT-WIDTH)/2)*math.sin(wheela)) end
if not tx and t.state == BEGAN and vec2(t.x,t.y):dist(vec2(3*WIDTH/4,(HEIGHT-WIDTH)/2)) < (HEIGHT-WIDTH)/2 then tx,frame = t,-1 end
if tx and t.state ==ENDED and t.id == tx.id then tx = nil end
end
function collide(contact)
if contact.state == BEGAN and ((contact.bodyA.bullet and not contact.bodyB.bullet) or (not contact.bodyA.bullet and contact.bodyB.bullet)) then
contact.bodyA:destroy()
contact.bodyB:destroy()
score = score + 1
if score > readLocalData("highscore") then saveLocalData("highscore",score) end end
end
function settween()
tr = tween.delay(2-(math.min(1.5*((ElapsedTime-time)/120),1.5)),function() makebody() settween() end)
end
function makebody()
e[#e+1] = physics.body(CIRCLE,30)
e[#e].position,e[#e].gravityScale=vec2(math.random(WIDTH),math.random(HEIGHT-WIDTH,HEIGHT)),0
while e[#e].position:dist(boat) <80 do
e[#e].position = vec2(math.random(WIDTH),math.random(HEIGHT-WIDTH,HEIGHT)) end
e[#e]:applyForce(vec2(300-math.random(600),300-math.random(600)))
end
function dall()
for i=#b,1,-1 do
b[i]:destroy()
table.remove(b,i)
end
for i=#e,1,-1 do
e[i]:destroy()
table.remove(e,i)
end
end
EDIT: I played all of your entries, and all I can say is…great job everybody!!!