Asteroid Destroyer

Hi everyone. Sorry for my bad english=)
I am new in Defold and lua, so my game will be very simple, because i want to understand all concepts of engine and lua.
I am making a simple arcade. Where you shoot asteroids.
The main idea
1)player shoot asteroids and get scores
2)the more time you play, the faster appearing new asteroids

gitnub
demo

It will be good, if you give me some advices on my code in lua=)
Sorry for my bad english again=)

3 Likes

Nice! Congratulations on creating a game using Defold. I took a very quick look at the code and nothing sticks out, it looks organised and well written. One minor thing though, if you don’t use the update() function (or any of the other lifecycle functions) it is recommended to remove them since they will be called and you will waste precious CPU cycles.

3 Likes

@Oleg_The_Evangelist, for your list of games :slight_smile:

1 Like

Why defold have not got ui elements:buttons, checkboxes, sliders etc.
It is easy to create them, but i think this elements must be in engine.
I use checkbox to enbale/disable sounds.

function M.getCheckBox(checked,imageOn,imageOff,node)
    local checkBox = {imageOn=imageOn, imageOff=imageOff,checked=true,node=node}
    checkBox.setChecked = 
        function(checked)
            checkBox.checked=checked 
            local animation=checkBox.imageOn
            if(not checked)then animation=checkBox.imageOff end
            gui.play_flipbook(node,animation)
            if(not (checkBox.callback == nil))then
                checkBox.callback(checkBox.checked)
            end
            return checkBox
        end
    checkBox.clicked = 
        function(action)
            if(gui.pick_node(node, action.x, action.y) and action.pressed)then
                checkBox.setChecked(not checkBox.checked)
                return true
            else
                return false
            end
        end
    checkBox.setChecked(checked)    
    return checkBox        
end

function M.get_button(up,down,node)
    local button = {up=up, down=down,over=nil,node=node}
    button.clicked =
         function(action)
            if(gui.pick_node(node, action.x,action.y)) then
                if(action.released)then
                    print("clicked")
                    gui.play_flipbook(node,up)
                    return true
                elseif(action.pressed or not(action.repeated == nil)) then
                    gui.play_flipbook(node,down)
                    return false
                end    
            else
                gui.play_flipbook(node,up)
                return false
            end
        end
    return button    
end

People will always want some custom behavior. So these kinds of things are better suited for a library. Either community contributed or official. If you make some good UI controls share and others may too.

1 Like

what’s new

  • Add particle to bullets
  • Add explosion animation
  • Add pause.
  • Add slow-motion when released finger
  • some ui and game fixes

Game is done. I think a learned a basic things of defold and lua. And now it is time to think about normal indie game.

2 Likes

Congrats on your first Defold game!

1 Like