nbml - BulletML-like shmup scripting

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
sharpobject
Prole
Posts: 44
Joined: Fri Mar 18, 2011 2:32 pm
Location: California
Contact:

nbml - BulletML-like shmup scripting

Post by sharpobject » Mon Apr 18, 2011 11:59 am

Image

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
The second one is a bit longer and slightly less possible to implement in BulletML. In particular, you can't make wander or fujiwara_197_bouncer using BulletML.

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
Have fun! ^^;
Attachments
nbml.love
(2.31 MiB) Downloaded 159 times

paclito
Prole
Posts: 35
Joined: Wed Apr 22, 2009 8:33 pm

Re: nbml - BulletML-like shmup scripting

Post by paclito » Wed Apr 20, 2011 8:13 pm

I've see your very code but I don't understand, can you please put a simple example of a bullet like this in the example........ i know my example is the worst of the world but I can understand the ball move, how can i put your library to move my ball?

thankyou!
Attachments
bulet.love
(2.99 KiB) Downloaded 89 times

User avatar
sharpobject
Prole
Posts: 44
Joined: Fri Mar 18, 2011 2:32 pm
Location: California
Contact:

Re: nbml - BulletML-like shmup scripting

Post by sharpobject » Fri Apr 22, 2011 12:20 pm

If you want to make a shmup with a lot of bullets that aren't of constant velocity (or need to be able to spawn other bullets), I would recommend using the ObjMan and Object classes defined in objman.lua and object.lua. Make an ObjMan when your game starts. Register a function with it that does stuff for your level. Call its run method at 60hz (or modify it to not require something so silly). Call its draw method every frame.

If you just want to make the ball move, I would recommend not using this stuff.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests