This is a tiny demo of a system for scripting shmups by attaching scripts to bullets and executing them asynchronously. It was inspired by my previous work using BulletML and my huge dislike for scripting things in XML. object.lua provides an API that does almost everything BulletML does (rank is missing, because I haven't implemented it), and since your bullet scripts will have access to more than just the BulletML API, you can do some things that BulletML can't do.
The demo comes with two patterns based on patterns from a certain popular shmup series. The first one is pretty simple (and trivially expressible in BulletML):
Code: Select all
function border_of_wave_and_particle(self)
local theta = 0
local dtheta = 0
while true do
local this_turn_angle = theta * degrees
for i=tau/3, tau, tau/3 do
self:fire(8, this_turn_angle + i)
end
dtheta = (dtheta + 0.2) % 360
theta = theta + dtheta
wait(2)
end
end
Code: Select all
function wander(self)
while true do
wait(120)
-- Choose a random spot to wander to
local x = random(300) + 250
local y = random(200)
local r, theta = get_polar(x-self.x, y-self.y)
self:change_speed(r/30, 30)
self:change_direction(theta, 1)
wait(30)
self:change_speed(0, 30)
wait(30)
end
end
function fujiwara_197_spawner(self)
while true do
wait(20)
self:fire(4, facing_up, fujiwara_197_bouncer)
self:fire(4, facing_down, fujiwara_197_bouncer)
end
end
function fujiwara_197_bouncer(self)
while true do
wait(1)
if self.y < 0 or self.y > 600 then
self:fire(self.speed/2, self.direction+tau/2)
self:vanish()
end
end
end
function fujiwara_197(self)
while true do
wait(45)
self:fire(1.25, facing_right, fujiwara_197_spawner)
self:fire(1.25, facing_left, fujiwara_197_spawner)
self:fire(4, facing_up, fujiwara_197_bouncer)
self:fire(4, facing_down, fujiwara_197_bouncer)
wait(135)
end
end