Log In  

function _init()
    cls()
    things = {}
    add_thing()
end

function _update()
    add_thing()

    for t in all(things) do
        t:update()
    end
end

function _draw()
 cls()
    for t in all(things) do
        t:draw()
    end
end

function add_thing()
    add(
        things,
        {
         my_color=rnd(16)-1,
            x=rnd(128),
            y=rnd(128),
            dx=rnd(2)-1,
            dy=rnd(2)-1,
            life=160,
            prevx=63,
            prevy=63,

            draw=function(self)             
                pset(self.x, self.y, self.my_color)
            end,

            update=function(self)
             if (self.sprite_num == 1) then
                self.sprite_num = 2             
             else
                self.sprite_num = 1
             end
                self.prevx=x
                self.prevy=y
                self.x += self.dx
                self.y += self.dy

                self.life-=1

                if(self.life<0) then
                    del(bullet,self)
                end
            end,                        
        }
    )
end
P#101442 2021-12-04 15:24 ( Edited 2021-12-04 16:12)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 19:50:37 | 0.005s | Q:9