Created
February 4, 2012 01:51
-
-
Save dntoshio/1734379 to your computer and use it in GitHub Desktop.
Shooting things v8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Use this function to perform your initial setup | |
function setup() | |
print("Hello World!") | |
displayMode(FULLSCREEN) | |
end | |
tap = false | |
x = 0 | |
y = 0 | |
done = true | |
hajime = ElapsedTime | |
tapbegint = 0 | |
score = 0 | |
pressed = false | |
dbl = false | |
slice = false | |
ran = 1 -- just random | |
function tap() | |
x = CurrentTouch.x | |
y = CurrentTouch.y | |
if ((CurrentTouch.tapCount == 2) and CurrentTouch.state == BEGAN ) then | |
dbl = true | |
elseif (CurrentTouch.state == BEGAN) then | |
pressed = true | |
end | |
if pressed or dbl then | |
if (CurrentTouch.state == ENDED) then | |
--each tap renew seed | |
math.randomseed((ElapsedTime - hajime)*1000000) | |
pressed = false | |
done = false | |
dbl = false | |
end | |
end | |
end | |
chax = 0 | |
chay = 0 | |
delete = 0 | |
stop = true | |
function draw() | |
background(0, 0, 0, 255) | |
tap() | |
displayhp() | |
playerpos() | |
showteki() | |
--showgravfall() | |
--lvlup thing | |
if (score > 2000) and atklvl == 3 then | |
atklvl = 5 | |
for h = 4, atklvl do | |
for i = 1, 1 do | |
atk[h] = {} | |
atk[h].num = 1 | |
atk[h].dama = {} | |
atk[h].dama[i] = {} | |
atk[h].dama[i].x = playerx | |
atk[h].dama[i].y = playery | |
atk[h].dama[i].w = 5 | |
atk[h].dama[i].l = 20 | |
atk[h].dama[i].tox = 0 | |
atk[h].dama[i].toy = 1 | |
atk[h].dama[i].koe = false | |
end | |
end | |
atk[4].dama[1].x = playerx - 20 | |
atk[4].dama[1].tox = 1 | |
atk[4].dama[1].toy = 3 | |
atk[5].dama[1].x = playerx + 20 | |
atk[5].dama[1].tox = 1 | |
atk[5].dama[1].toy = 3 | |
end | |
fill(255, 255, 255, 255) | |
text("Score " ..score, 400, HEIGHT - 20) | |
if atklvl <= 3 then | |
text("Level 1", 200, HEIGHT - 20) | |
end | |
if atklvl <= 5 then | |
text("Level 2", 200, HEIGHT - 20) | |
end | |
fill(159, 171, 183, 255) | |
text("weird shooting game by Toshio aka CY", 800, HEIGHT - 20) | |
end | |
--Playerandatk: | |
playerx = WIDTH/2 | |
playery = 100 | |
fhp = 100 | |
hp = 100 | |
watch("hp") | |
atklvl = 7 -- currently programmed lvl 7 possible | |
atk = {} | |
for i = 1, atklvl do | |
atk[i] = {} | |
atk[i].num = 1 | |
end | |
atktime = 1 | |
shott = 0 | |
atktime = 1 -- for double or more atk bonus | |
bulletspd = 12 --how fast bullet travels | |
shotspd = 0.4 --time between each shot, shorter the faster atk | |
--bullettype = "fire" | |
bullettype = "normal" | |
--lvl7 rev shot | |
function revini() | |
rev = {} | |
for i = 1, 16 do | |
rev[i] = {} | |
end | |
-- time btw switching spot | |
revt = 1 | |
-- time at that spot | |
revs = ElapsedTime | |
-- current pos num | |
revpos = 1 | |
rev.x = 0 | |
rev.y = 0 | |
rev2 = {} | |
rev2pos = 9 | |
rev2.x = 0 | |
rev2.y = 0 | |
--revatk spd | |
revt = ElapsedTime | |
revspd = 0.05 | |
end | |
function revolve() | |
--rev1 to 16 for pos around playerx,y keep renewing every frame,somehow failed | |
rev[1].x = playerx rev[1].y = playery + 100 | |
rev[2].x = playerx + 39 rev[2].y = playery + 92 | |
rev[3].x = playerx + 85 rev[3].y = playery + 85 | |
rev[4].x = playerx + 92 rev[4].y = playery + 39 | |
rev[5].x = playerx + 100 rev[5].y = playery | |
rev[6].x = playerx + 92 rev[6].y = playery - 39 | |
rev[7].x = playerx + 85 rev[7].y = playery - 85 | |
rev[8].x = playerx + 39 rev[8].y = playery - 92 | |
rev[9].x = playerx rev[9].y = playery - 100 | |
rev[10].x = playerx - 39 rev[10].y = playery - 92 | |
rev[11].x = playerx - 85 rev[11].y = playery - 85 | |
rev[12].x = playerx - 92 rev[12].y = playery - 39 | |
rev[13].x = playerx - 100 rev[13].y = playery | |
rev[14].x = playerx - 92 rev[14].y = playery + 39 | |
rev[15].x = playerx - 85 rev[15].y = playery + 85 | |
rev[16].x = playerx - 39 rev[16].y = playery + 92 | |
--[[dont need and it doesnt work if shooting anyway | |
if (ElapsedTime - revs) > revt then | |
if revpos < 16 then | |
revpos = revpos + 1 | |
revs = ElapsedTime | |
else revpos = 1 | |
revs = ElapsedTime | |
end | |
if rev2pos < 16 then | |
rev2pos = rev2pos + 1 | |
else rev2pos = 1 | |
end | |
end]] | |
-------------------------- | |
rev.x = rev[revpos].x | |
rev.y = rev[revpos].y | |
sprite("Pictures:star", rev.x, rev.y) | |
rev2.x = rev[rev2pos].x | |
rev2.y = rev[rev2pos].y | |
sprite("Pictures:star", rev2.x, rev2.y) | |
end | |
revini() | |
---------- | |
--lvlatk setup | |
---------- | |
-- expt change | |
for h = 1, atklvl do | |
for i = 1, 1 do | |
atk[h].dama = {} | |
atk[h].dama[i] = {} | |
atk[h].dama[i].x = playerx | |
atk[h].dama[i].y = playery | |
atk[h].dama[i].w = 5 | |
atk[h].dama[i].l = 20 | |
atk[h].dama[i].tox = 0 | |
atk[h].dama[i].toy = 1 | |
atk[h].dama[i].koe = false | |
end | |
end | |
--lvl2+ atk direction adjust | |
atk[2].dama[1].x = playerx - 10 | |
atk[2].dama[1].tox = -1 | |
atk[2].dama[1].toy = 3 | |
atk[3].dama[1].x = playerx + 10 | |
atk[3].dama[1].tox = 1 | |
atk[3].dama[1].toy = 3 | |
if atklvl == 4 then | |
atk[4].dama[1].x = playerx - 20 | |
atk[4].dama[1].tox = 1 | |
atk[4].dama[1].toy = 3 | |
end | |
if atklvl >= 5 then | |
atk[5].dama[1].x = playerx + 20 | |
atk[5].dama[1].tox = 1 | |
atk[5].dama[1].toy = 3 | |
end | |
if atklvl >= 6 then | |
atk[6].dama[1].x = rev.x | |
atk[6].dama[1].y = rev.y | |
atk[6].dama[1].tox = 0 | |
atk[6].dama[1].toy = 4 | |
end | |
if atklvl >= 7 then | |
atk[7].dama[1].x = rev2.x | |
atk[7].dama[1].y = rev2.y | |
atk[7].dama[1].tox = 0 | |
atk[7].dama[1].toy = 4 | |
end | |
function displayhp() | |
noStroke() | |
for i = 1, 100 do | |
fill(145, 133, 133, 255) | |
ellipse(35 + i , HEIGHT - 20, 10, 15) | |
i = i + 1 | |
end | |
for i = 1, (hp / fhp * 100) do | |
fill(244, 27, 27, 255) | |
ellipse(35 + i , HEIGHT - 20, 10, 15) | |
i = i + 1 | |
end | |
end | |
function playerpos() | |
---------------------------- | |
--player the spacecraft | |
---------------------------- | |
tint(255, 0, 0, 255,188) | |
sprite("Pictures:plane", playerx, playery) | |
revolve() | |
-- make player follow dragging | |
if CurrentTouch.state == BEGAN then | |
tapbegint = ElapsedTime | |
ox = CurrentTouch.x | |
oy = CurrentTouch.y | |
--print("begin") | |
end | |
-- yay somehow got rid of move-stop-yet-still-moving problem, not really =-= | |
if ((ElapsedTime - tapbegint) > 1) then | |
ox = CurrentTouch.x | |
oy = CurrentTouch.y | |
tapbegint = ElapsedTime | |
end | |
if CurrentTouch.state == MOVING then | |
newx = CurrentTouch.x | |
newy = CurrentTouch.y | |
end | |
if CurrentTouch.state ~= ENDED and | |
((ox~= newx) and (oy ~= newy))then | |
playerx = playerx + CurrentTouch.deltaX | |
playery = playery + CurrentTouch.deltaY | |
end | |
--prevent offscreen | |
if playerx > WIDTH - 50 then playerx = WIDTH - 50 end | |
if playerx < 50 then playerx = 50 end | |
if playery > HEIGHT - 50 then playery = HEIGHT - 50 end | |
if playery < 50 then playery = 50 end | |
--^ worked -- | |
------------------------------player the end------ | |
-- call the playershoot() | |
playershoot() | |
end | |
function playershoot() | |
---------------------------------------------- | |
--keeps shooting every shotspd second lvl5- | |
---------------------------------------------- | |
if (ElapsedTime - shott) > shotspd then | |
shott= ElapsedTime | |
-- test double atk | |
for d = 1, atktime do | |
for i = 1, atklvl do | |
--v7 | |
atkgen = false | |
for j = 1, atk[i].num do | |
if (atk[i].dama[j] == nil) and not atkgen then | |
if i < 6 then | |
atk[i].dama[j] = {} | |
atk[i].dama[j].x = playerx | |
atk[i].dama[j].y = playery | |
atk[i].dama[j].w = 5 | |
atk[i].dama[j].l = 20 | |
atk[i].dama[j].tox = 0 | |
atk[i].dama[j].toy = 1 | |
atk[i].dama[j].koe = false | |
end | |
if i == 2 then | |
atk[i].dama[j].x = playerx - 10 | |
atk[i].dama[j].tox = -1 | |
atk[i].dama[j].toy = 3 | |
end | |
if i == 3 then | |
atk[i].dama[j].x = playerx + 10 | |
atk[i].dama[j].tox = 1 | |
atk[i].dama[j].toy = 3 | |
end | |
if i == 4 then | |
atk[i].dama[j].x = playerx - 20 | |
atk[i].dama[j].tox = -1 | |
atk[i].dama[j].toy = 3 | |
end | |
if i == 5 then | |
atk[i].dama[j].x = playerx +20 | |
atk[i].dama[j].tox = 1 | |
atk[i].dama[j].toy = 3 | |
end | |
atkgen = true | |
break | |
end | |
if not atkgen then | |
if i < 6 then | |
atk[i].num = atk[i].num + 1 | |
atk[i].dama[atk[i].num] = {} | |
atk[i].dama[atk[i].num].x = playerx | |
atk[i].dama[atk[i].num].y = playery | |
atk[i].dama[atk[i].num].w = 5 | |
atk[i].dama[atk[i].num].l = 20 | |
atk[i].dama[atk[i].num].tox = 0 | |
atk[i].dama[atk[i].num].toy = 1 | |
atk[i].dama[atk[i].num].koe = false | |
end | |
if i == 2 then | |
atk[i].dama[atk[i].num].x = playerx - 10 | |
atk[i].dama[atk[i].num].tox = -1 | |
atk[i].dama[atk[i].num].toy = 3 | |
end | |
if i == 3 then | |
atk[i].dama[atk[i].num].x = playerx + 10 | |
atk[i].dama[atk[i].num].tox = 1 | |
atk[i].dama[atk[i].num].toy = 3 | |
end | |
if i == 4 then | |
atk[i].dama[atk[i].num].x = playerx - 20 | |
atk[i].dama[atk[i].num].tox = -1 | |
atk[i].dama[atk[i].num].toy = 3 | |
end | |
if i == 5 then | |
atk[i].dama[atk[i].num].x = playerx +20 | |
atk[i].dama[atk[i].num].tox = 1 | |
atk[i].dama[atk[i].num].toy = 3 | |
end | |
atkgen = true | |
end | |
end | |
end | |
end -- testing double or more atk | |
end | |
------------ | |
--atk6,7 diff rate | |
------------ | |
if (atklvl > 5) and (atklvl < 8) then | |
if (ElapsedTime - revt > revspd) then | |
revt = ElapsedTime | |
-- yay if revolve here it works -- | |
if revpos < 16 then | |
revpos = revpos + 1 | |
else revpos = 1 | |
end | |
if rev2pos < 16 then | |
rev2pos = rev2pos + 1 | |
else rev2pos = 1 | |
end | |
for d = 1, atktime do | |
for i = 6, 7 do | |
atkgen = false | |
for j = 1, atk[i].num do | |
if (atk[i].dama[j] == nil) and not atkgen then | |
atk[i].dama[j] = {} | |
atk[i].dama[j].w = 10 | |
atk[i].dama[j].l = 10 | |
atk[i].dama[j].koe = false | |
if i == 6 then | |
atk[i].dama[j].x = rev.x | |
atk[i].dama[j].y = rev.y | |
atk[i].dama[j].tox = 0 | |
atk[i].dama[j].toy = 4 | |
end | |
if i == 7 then | |
atk[i].dama[j].x = rev2.x | |
atk[i].dama[j].y = rev2.y | |
atk[i].dama[j].tox = 0 | |
atk[i].dama[j].toy = 4 | |
end | |
atkgen = true | |
end | |
if not atkgen then | |
atk[i].num = atk[i].num + 1 | |
atk[i].dama[atk[i].num] = {} | |
atk[i].dama[atk[i].num].w = 10 | |
atk[i].dama[atk[i].num].l = 10 | |
atk[i].dama[atk[i].num].koe = false | |
if i == 6 then | |
atk[i].dama[atk[i].num].x = rev.x | |
atk[i].dama[atk[i].num].y = rev.y | |
atk[i].dama[atk[i].num].tox = 0 | |
atk[i].dama[atk[i].num].toy = 4 | |
end | |
if i == 7 then | |
atk[i].dama[atk[i].num].x = rev2.x | |
atk[i].dama[atk[i].num].y = rev2.y | |
atk[i].dama[atk[i].num].tox = 0 | |
atk[i].dama[atk[i].num].toy = 4 | |
end | |
atkgen = true | |
end | |
end | |
end | |
end | |
revt = ElapsedTime | |
end | |
end | |
----------------- | |
--show the atks | |
----------------- | |
-- change v4 | |
for i = 1, atklvl do | |
for j = 1, atk[i].num do | |
if atk[i].dama[j] ~= nil then | |
if (i == 1) then | |
sprite("Pictures:beam", atk[i].dama[j].x, | |
atk[i].dama[j].y, atk[i].dama[j].w+10, atk[i].dama[j].l+10) | |
end | |
if (i >= 2) and (i <=3) then | |
sprite("Pictures:ball", atk[i].dama[j].x, | |
atk[i].dama[j].y, atk[i].dama[j].w+10, atk[i].dama[j].l+10) | |
end | |
if (i >= 4) and (i <= 5) then | |
sprite("Pictures:ball1", atk[i].dama[j].x, | |
atk[i].dama[j].y, atk[i].dama[j].w+10, atk[i].dama[j].l+10) | |
end | |
if (i >= 6) and (i <= 7) then | |
sprite("Pictures:star", atk[i].dama[j].x, | |
atk[i].dama[j].y, atk[i].dama[j].w+10, atk[i].dama[j].l+10) | |
end | |
if i == 1 or ((i >= 6) and (i <= 7)) then | |
atk[i].dama[j].x = atk[i].dama[j].x + atk[i].dama[j].tox*bulletspd | |
atk[i].dama[j].y = atk[i].dama[j].y + atk[i].dama[j].toy*bulletspd | |
end | |
if (i >= 2) and (i <= 5) then | |
atk[i].dama[j].x = atk[i].dama[j].x + atk[i].dama[j].tox*bulletspd*0.06 | |
atk[i].dama[j].y = atk[i].dama[j].y + atk[i].dama[j].toy*bulletspd*0.3 | |
end | |
-- detect off screen | |
--so it doesn't freeze for the for loop missing num | |
if (atk[i].dama[j] ~= nil) then | |
if ( (atk[i].dama[j].x < 0) or (atk[i].dama[j].x > WIDTH) or | |
(atk[i].dama[j].y < 0) or (atk[i].dama[j].y > HEIGHT) ) then | |
--v7 | |
atk[i].dama[j] = nil | |
--so if is done, extra bullet is deleted why lag still D: | |
end | |
end | |
end | |
end | |
end | |
----- show the atk ./end ------------------------ | |
end | |
--Tekigen: | |
tekiNum = 3 | |
teki = {} | |
tekiatk = {} | |
for i = 1, tekiNum do | |
teki[i] = {} | |
teki[i].x = WIDTH/2 | |
teki[i].y = HEIGHT - 100 | |
teki[i].hp = 30 | |
teki[i].move = false | |
teki[i].dx = 0 | |
teki[i].dy = 0 | |
teki[i].tox = 0 | |
teki[i].toy = 0 | |
teki[i].mspd = 0 | |
teki[i].atk = {} | |
teki[i].tekiatkspd = 1 | |
teki[i].tekiatkt = ElapsedTime | |
teki[i].atk[1] = {} | |
teki[i].atknum = 1 | |
teki[i].atk[1].x = teki[i].x | |
teki[i].atk[1].y = teki[i].y | |
teki[i].atk[1].w = 17 | |
teki[i].atk[1].l = 17 | |
teki[i].atk[1].dx = teki[i].atk[1].x - playerx | |
teki[i].atk[1].dy = teki[i].atk[1].y - playery | |
teki[i].atk[1].tox = teki[i].atk[1].dx/ | |
(math.abs(teki[i].atk[1].dx) + math.abs(teki[i].atk[1].dy) ) | |
teki[i].atk[1].toy = teki[i].atk[1].dy/ | |
(math.abs(teki[i].atk[1].dx) + math.abs(teki[i].atk[1].dy) ) | |
teki[i].atk[1].tekibulletspd = 3 | |
teki[i].tekiatkspd = 2.5 | |
teki[i].tekiatkt = ElapsedTime | |
end | |
score = watch("score") | |
teki[2].x = 200 | |
teki[3].x = 500 | |
arawaret = 2 --new teki every this sec | |
arawared = ElapsedTime | |
teki1atknum= 0 | |
tekixmove = 5 | |
----------------------- | |
--teki atk related | |
----------------------- | |
function showtekiatk() | |
for i = 1, tekiNum do | |
if teki[i] ~= nil then | |
for k = 1, teki[i].atknum do | |
--very laggy loading too many pictures | |
--v7 | |
if teki[i].atk[k] ~= nil then | |
sprite("Pictures:shot", teki[i].atk[k].x, | |
teki[i].atk[k].y, teki[i].atk[k].w, teki[i].atk[k].l) | |
teki[i].atk[k].x = teki[i].atk[k].x - (teki[i].atk[k].tox*teki[i].atk[k].tekibulletspd) | |
teki[i].atk[k].y = teki[i].atk[k].y - (teki[i].atk[k].toy*teki[i].atk[k].tekibulletspd) | |
--check collision on player, - hp | |
if ( ((playerx - 40) < (teki[i].atk[k].x-(teki[i].atk[k].w / 2))) and | |
((playerx + 40) > (teki[i].atk[k].x+(teki[i].atk[k].w / 2))) and | |
((playery - 60) < (teki[i].atk[k].y-(teki[i].atk[k].l / 2))) and | |
((playery + 60) > (teki[i].atk[k].y+(teki[i].atk[k].l / 2))) ) | |
then | |
hp = hp - 1 | |
end | |
end --v7 | |
end | |
end -- if not nil ends here | |
end | |
--gen tekibullet every tekiatkspd second | |
for i = 1, tekiNum do | |
if teki[i] ~= nil then | |
if ((ElapsedTime - teki[i].tekiatkt) > teki[i].tekiatkspd) then | |
tekiatkgen = false | |
for k = 1, teki[i].atknum do --v7 | |
if (teki[i].atk[k] == nil) and not tekiatkgen then | |
teki[i].atk[k] = {} | |
teki[i].atk[k].x = teki[i].x | |
teki[i].atk[k].y = teki[i].y | |
teki[i].atk[k].w = 17 | |
teki[i].atk[k].l = 17 | |
teki[i].atk[k].dx = teki[i].x - playerx | |
teki[i].atk[k].dy = teki[i].y - playery | |
teki[i].atk[k].tox = teki[i].atk[teki[i].atknum].dx | |
/(math.abs(teki[i].atk[teki[i].atknum].dx) + math.abs(teki[i].atk[teki[i].atknum].dy)) | |
teki[i].atk[k].toy = teki[i].atk[teki[i].atknum].dy | |
/(math.abs(teki[i].atk[teki[i].atknum].dx) + math.abs(teki[i].atk[teki[i].atknum].dy) ) | |
teki[i].atk[teki[i].atknum].tekibulletspd = 3 | |
--teki[i].atk[teki[i].atknum].tekiatkspd = 0.5 | |
teki[i].tekiatkt = ElapsedTime | |
tekiatkgen = true | |
break | |
end | |
end | |
if (teki[i].atk[k] ~= nil) and not tekiatkgen then | |
teki[i].atknum = teki[i].atknum + 1 | |
teki[i].atk[teki[i].atknum] = {} | |
--print("teki bullet no", teki[i].atknum) | |
teki[i].atk[teki[i].atknum].x = teki[i].x | |
teki[i].atk[teki[i].atknum].y = teki[i].y | |
teki[i].atk[teki[i].atknum].w = 17 | |
teki[i].atk[teki[i].atknum].l = 17 | |
--print("teki bullet 2 l", teki[i].atk[teki[i].atknum].l) | |
teki[i].atk[teki[i].atknum].dx = teki[i].x - playerx | |
teki[i].atk[teki[i].atknum].dy = teki[i].y - playery | |
teki[i].atk[teki[i].atknum].tox = teki[i].atk[teki[i].atknum].dx | |
/(math.abs(teki[i].atk[teki[i].atknum].dx) + math.abs(teki[i].atk[teki[i].atknum].dy)) | |
teki[i].atk[teki[i].atknum].toy = teki[i].atk[teki[i].atknum].dy | |
/(math.abs(teki[i].atk[teki[i].atknum].dx) + math.abs(teki[i].atk[teki[i].atknum].dy) ) | |
teki[i].atk[teki[i].atknum].tekibulletspd = 3 | |
--teki[i].atk[teki[i].atknum].tekiatkspd = 0.5 | |
teki[i].tekiatkt = ElapsedTime | |
tekiatkgen = true | |
end | |
--^v7genatk | |
--teki1atknum = teki1atknum + 1 | |
end | |
end -- teki not nil ends her | |
end | |
--new tekiatk gen done | |
--delete teki atk when done, first it is if hit player, then offscreen | |
if not tekiatkkesu then | |
for i = 1, tekiNum do | |
if teki[i] ~= nil then | |
for k = 1, teki[i].atknum do | |
--v7 | |
if teki[i].atk[k] ~= nil then | |
if (( ((playerx - 40) < (teki[i].atk[k].x-(teki[i].atk[k].w / 2))) and | |
((playerx + 40) > (teki[i].atk[k].x+(teki[i].atk[k].w / 2))) and | |
((playery - 60) < (teki[i].atk[k].y-(teki[i].atk[k].l / 2))) and | |
((playery + 60) > (teki[i].atk[k].y+(teki[i].atk[k].l / 2))) )) or | |
(teki[i].atk[k].x > WIDTH) or (teki[i].atk[k].x < 0) or | |
(teki[i].atk[k].y > HEIGHT) or (teki[i].atk[k].y < 0) then | |
teki[i].atk[k] = nil | |
tekikesu = true | |
--temptekiatk = temptekiatk + 1 | |
end | |
end -- v7 | |
if tekiatkkesu then break end | |
end | |
if tekiatkkesu then break end | |
end | |
tekiatkkesu = false | |
end --if teki not nil ends here | |
end | |
end | |
function araware() | |
if (((ElapsedTime - arawared) > arawaret) or (tekiNum < 3)) then | |
math.randomseed((ElapsedTime - hajime)*1000000) | |
tekiNum = tekiNum + 1 | |
teki[tekiNum] = {} | |
teki[tekiNum].x = math.random(50, WIDTH - 50) | |
teki[tekiNum].y = math.random(520, HEIGHT - 80) | |
teki[tekiNum].hp = 30 + math.random(10, 20) | |
teki[tekiNum].move = false | |
teki[tekiNum].dx = 0 | |
teki[tekiNum].dy = 0 | |
teki[tekiNum].tox = 0 | |
teki[tekiNum].toy = 0 | |
teki[tekiNum].mspd = 0 | |
arawared = ElapsedTime | |
--initialize new teki's atk too | |
teki[tekiNum].atk = {} | |
teki[tekiNum].tekiatkspd = 1.5 | |
teki[tekiNum].tekiatkt = ElapsedTime | |
teki[tekiNum].atk[1] = {} | |
teki[tekiNum].atknum = 1 | |
teki[tekiNum].atk[1].x = teki[tekiNum].x | |
teki[tekiNum].atk[1].y = teki[tekiNum].y | |
teki[tekiNum].atk[1].w = 10 | |
teki[tekiNum].atk[1].l = 10 | |
teki[tekiNum].atk[1].dx = teki[tekiNum].atk[1].x - playerx | |
teki[tekiNum].atk[1].dy = teki[tekiNum].atk[1].y - playery | |
teki[tekiNum].atk[1].tox = teki[tekiNum].atk[1].dx/ | |
(teki[tekiNum].atk[1].dx+teki[tekiNum].atk[1].dy) | |
teki[tekiNum].atk[1].toy = teki[tekiNum].atk[1].dy/ | |
(teki[tekiNum].atk[1].dx+teki[tekiNum].atk[1].dy) | |
teki[tekiNum].atk[1].tekibulletspd = 3 | |
teki[tekiNum].tekiatkt = ElapsedTime | |
end | |
-- try gen stronger teki that moves v5 | |
math.randomseed((ElapsedTime - hajime)*1000000) | |
if math.random(1000) > 995 then | |
tekiNum = tekiNum + 1 | |
teki[tekiNum] = {} | |
teki[tekiNum].x = math.random(50, WIDTH - 50) | |
teki[tekiNum].y = math.random(50, HEIGHT - 50) | |
teki[tekiNum].hp = 30 + math.random(10, 20) | |
teki[tekiNum].move = true | |
teki[tekiNum].dx = teki[tekiNum].x - playerx | |
teki[tekiNum].dy = teki[tekiNum].y - playery | |
teki[tekiNum].tox = teki[tekiNum].dx/(math.abs(teki[tekiNum].dx)+ | |
(math.abs(teki[tekiNum].dy))) | |
teki[tekiNum].toy = teki[tekiNum].dy/(math.abs(teki[tekiNum].dx)+ | |
(math.abs(teki[tekiNum].dy))) | |
teki[tekiNum].mspd = 3 | |
--moving teki' atk | |
teki[tekiNum].atk = {} | |
teki[tekiNum].tekiatkspd = 0.5 | |
teki[tekiNum].tekiatkt = ElapsedTime | |
teki[tekiNum].atk[1] = {} | |
teki[tekiNum].atknum = 1 | |
teki[tekiNum].atk[1].x = teki[tekiNum].x | |
teki[tekiNum].atk[1].y = teki[tekiNum].y | |
teki[tekiNum].atk[1].w = 10 | |
teki[tekiNum].atk[1].l = 10 | |
teki[tekiNum].atk[1].dx = teki[tekiNum].atk[1].x - playerx | |
teki[tekiNum].atk[1].dy = teki[tekiNum].atk[1].y - playery | |
teki[tekiNum].atk[1].tox = teki[tekiNum].atk[1].dx/ | |
(teki[tekiNum].atk[1].dx+teki[tekiNum].atk[1].dy) | |
teki[tekiNum].atk[1].toy = teki[tekiNum].atk[1].dy/ | |
(teki[tekiNum].atk[1].dx+teki[tekiNum].atk[1].dy) | |
teki[tekiNum].atk[1].tekibulletspd = 3 | |
teki[tekiNum].tekiatkspd = 2.5 | |
teki[tekiNum].tekiatkt = ElapsedTime | |
end | |
end | |
function showteki() | |
--gen new teki | |
araware() | |
for i = 1, tekiNum do | |
-- normal teki | |
if teki[i] ~= nil then | |
if not teki[i].move then | |
tint(255, 255, 255, 255) | |
sprite("Tyrian Remastered:Evil Head", teki[i].x, teki[i].y) | |
else | |
tint(255, 255, 255, 255) | |
sprite("Tyrian Remastered:Mine Spiked Huge",teki[i].x, teki[i].y, 100) | |
teki[i].x = teki[i].x - teki[i].tox*teki[i].mspd | |
teki[i].y = teki[i].y - teki[i].toy*teki[i].mspd | |
end | |
end | |
end | |
-- minus hp v4 change | |
for i = 1, atklvl do | |
for j = 1, atk[i].num do | |
for k = 1, tekiNum do | |
if teki[k] ~= nil then | |
if atk[i].dama[j] ~= nil then | |
if ( ((atk[i].dama[j].x - 48) < teki[k].x) and | |
((atk[i].dama[j].x + 48) > teki[k].x) and | |
((atk[i].dama[j].y - 48) < teki[k].y) and | |
((atk[i].dama[j].y + 48) > teki[k].y) )then | |
if atklvl <4 then | |
teki[k].hp = teki[k].hp - 1 | |
score = score + 1 | |
elseif atklvl < 6 then | |
teki[k].hp = teki[k].hp - 2 | |
score = score + 2 | |
elseif atklvl < 8 then | |
teki[k].hp = teki[k].hp - 3 | |
score = score + 3 | |
end | |
--add collide sprite | |
tint(255, 255, 255, 255) | |
sprite("Pictures:x", atk[i].dama[j].x, atk[i].dama[j].y, | |
math.random(55, 85)) | |
if not atk[i].dama[j].koe then | |
sound(SOUND_HIT, 38753) | |
atk[i].dama[j].koe = true | |
end | |
end | |
end | |
end | |
end | |
end | |
end | |
--check and delete | |
for i = 1, tekiNum do | |
--v8 f1 12 new delete | |
if teki[i] ~= nil then | |
if (teki[i].hp < 0) then | |
teki[i] = nil | |
sound(SOUND_EXPLODE, 13517) | |
--tempteki = tempteki + 1 | |
end | |
end | |
end | |
showtekiatk() | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment