[ create a new paste ] login | about

Link: http://codepad.org/whtbECZT    [ raw code | fork ]

Lua, pasted on Feb 28:
-- The chasing attack from the documentation example.
spawntimer = 0
spawntimer = spawntimer + 1.5
bullets = {}

    if spawntimer%30 == 0 then
		chasingbullet = CreateProjectile('bullet', Arena.width/2, Arena.height/2)
		chasingbullet.SetVar('xspeed', 0)
		chasingbullet.SetVar('yspeed', 0)
		table.insert(bullets, bullet)
	end
	
spawntime = 0	
spawntime = spawntime + 1.5
bulletz = {}

	if spawntime%30 == 0 then
		chaserbullet = CreateProjectile('bullet', 2*Arena.width/2, Arena.height/2)
		chaserbullet.SetVar('xspeed2', 0)
		chaserbullet.SetVar('yspeed2', 0)
		table.insert(bulletz, bullet)
	end

function OnHit(bullet)
	local atk = GetGlobal("atk")
	varvalue = GetGlobal("atk")
	Player.Hurt(atk)
end

function Update()
    local xdifference = Player.x - chasingbullet.x
    local ydifference = Player.y - chasingbullet.y
    local xspeed = chasingbullet.GetVar('xspeed') / 2 + xdifference / 50
    local yspeed = chasingbullet.GetVar('yspeed') / 2 + ydifference / 50
    chasingbullet.Move(xspeed, yspeed)
    chasingbullet.SetVar('xspeed', xspeed)
    chasingbullet.SetVar('yspeed', yspeed)
	
	local xdifference2 = Player.x - chaserbullet.x
    local ydifference2 = Player.y - chaserbullet.y
    local xspeed2 = chaserbullet.GetVar('xspeed2') / 2 + xdifference2 / 50
    local yspeed2 = chaserbullet.GetVar('yspeed2') / 2 + ydifference2 / 50
	chaserbullet.Move(xspeed2, yspeed2)
    chaserbullet.SetVar('xspeed2', xspeed2)
    chaserbullet.SetVar('yspeed2', yspeed2)
end


Output:
No errors or program output.


Create a new paste based on this one


Comments: