I haven’t done this for awhile, but anyways here’s another starter game for anyone who wants to add to it. To play, hold your finger on the screen about 1/4 from the bottom. A ship will appear in the middle of the screen. Move that finger around the screen to move the ship. As long as your finger remains on the screen, the ship will show. If you loose the ship off the screen, lift your finger and then touch the screen again for the ship to show in the middle. As long as the ship shows, you can shoot by tapping the screen with another finger. That will start the enemy coming from the top of the screen. Shoot the enemy, avoid the purple clouds and the flames. As long as you keep shooting, the enemy will keep coming. The farther away the enemy is when you hit it, the higher the value for the hit. Those values will show as they scroll down the screen. It you get hit by the enemy, the cloud, or a flame, the ship will disappear. To restart, just lift your finger and put it back on the screen. There is no end game, the score doesn’t get saved, so you can just keep going. You can add whatever you want to this to make it your own. The game plays in portrait mode.
EDIT: Corrected an error, changed endRound to shipHit.
displayMode(FULLSCREEN)
supportedOrientations(PORTRAIT_ANY)
function setup()
cx=WIDTH/2
cy=HEIGHT/2
jsX,jsY=0,0
mis={}
enemy={}
val={}
cTab={}
eMis={}
score=0
cnt=0
ecnt=0
end
function draw()
background(170, 223, 214, 255)
drawOurShip()
drawMissle()
drawEnemy()
checkMissleHit()
drawCloud()
drawHitValues()
drawScore()
drawEnemyMissle()
checkEnemyMissleHit()
end
function drawOurShip()
cx=cx+jsX
cy=cy+jsY
if jsId~=nil then
sprite("Space Art:Red Ship",cx,cy,60)
end
end
function drawMissle()
for z=#mis,1,-1 do
sprite("Tyrian Remastered:Firestroid",mis[z].x,mis[z].y,10)
mis[z].y=mis[z].y+20
if mis[z].y>HEIGHT+50 then
table.remove(mis,z)
end
end
end
function checkMissleHit()
for a,b in pairs(mis) do
for c,d in pairs(enemy) do
v1=b
dis=v1:dist(d)
if dis<40 then
sc=(b.y-cy)//10
score=score+sc
table.insert(val,vec3(d.x,d.y,sc))
table.remove(mis,a)
table.remove(enemy,c)
return
end
end
end
end
function drawEnemy()
for z=#enemy,1,-1 do
sprite("Tyrian Remastered:Evil Head",enemy[z].x,enemy[z].y,60)
enemy[z].y=enemy[z].y-5
-- check if enemy hit our ship
v1=enemy[z]
dis=v1:dist(vec2(cx,cy))
if dis<40 then
sprite("Tyrian Remastered:Explosion Huge",cx,cy)
shipHit()
return
end
-- check if enemy is below the screen bottom
if enemy[z].y<-50 then
table.remove(enemy,z)
end
end
end
function drawCloud()
for z=#cTab,1,-1 do
sprite("Space Art:Cloudy Nebula",cTab[z].x,cTab[z].y)
cTab[z].y=cTab[z].y-5
-- check if cloud hit our ship
v1=cTab[z]
dis=v1:dist(vec2(cx,cy))
if dis<100 then
shipHit()
return
end
-- check if cloud is below the screen bottom
if cTab[z].y<-50 then
table.remove(cTab,z)
end
end
end
function drawHitValues()
fontSize(20)
for z=#val,1,-1 do
fill(255)
ellipse(val[z].x,val[z].y,30)
fill(0, 66, 255, 255)
text(string.format("%d",val[z].z),val[z].x,val[z].y)
val[z].y=val[z].y-5
if val[z].y<-10 then
table.remove(val,z)
end
end
end
function drawScore()
fontSize(50)
fill(255, 0, 0, 255)
text(string.format("%d",score),WIDTH/2,HEIGHT-40)
end
function drawEnemyMissle()
for z=#eMis,1,-1 do
sprite("Tyrian Remastered:Flame 1",eMis[z].x,eMis[z].y,10)
eMis[z].y=eMis[z].y-10
if eMis[z].y<50 then
table.remove(eMis,z)
end
end
end
function checkEnemyMissleHit()
for a,b in pairs(eMis) do
v1=b
dis=v1:dist(vec2(cx,cy))
if dis<20 then
shipHit()
return
end
end
end
function shipHit()
cTab={}
enemy={}
mis={}
eMis={}
val={}
jsX,jsY=0,0
jsId=nil
end
function touched(t)
shoot(t)
joyStick(t)
end
function shoot(t)
if t.state==BEGAN and jsId~=nil then
table.insert(mis,vec2(cx,cy+50))
createEnemy()
createEnemy()
addCloud()
end
end
function createEnemy()
if #enemy<8 then
table.insert(enemy,vec2(math.random(50,WIDTH-50),HEIGHT+50))
ecnt=ecnt+1
if ecnt%3==0 then
table.insert(eMis,vec2(math.random(50,WIDTH-50),HEIGHT+10))
end
end
end
function addCloud()
cnt=cnt+1
if cnt>10 then
cnt=0
table.insert(cTab,vec2(math.random(50,WIDTH-50),HEIGHT+50))
end
end
function joyStick(t)
if t.state==BEGAN and jsId==nil then
cx,cy=WIDTH/2,HEIGHT/2
jsId,sx,sy=t.id,t.x,t.y
elseif t.state==MOVING and t.id==jsId then
jsX,jsY=(t.x-sx)/8,(t.y-sy)/8
elseif t.state==ENDED and t.id==jsId then
jsId,jsX,jsY=nil,0,0
end
end