# Can you give me hints to improve my defold programmation? (SOLVED)

**URL:** <https://forum.defold.com/t/can-you-give-me-hints-to-improve-my-defold-programmation-solved/3709>\
**Category:** Questions\
**Created:** [December 17, 2016, 8:19pm UTC](https://forum.defold.com/t/can-you-give-me-hints-to-improve-my-defold-programmation-solved/3709 "2016-12-17T20:19:53Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [December 18, 2016, 9:48am UTC](https://forum.defold.com/t/can-you-give-me-hints-to-improve-my-defold-programmation-solved/3709/2 "2016-12-18T09:48:11Z")

</div>

That looks pretty good to me. A few notes:

1. Updating the position of a game object can be done in two ways, either by calling `go.set_position()` or by “tweening” (or animating) the “position” property. When you want to set the position from input or when you have logic tied to the movement your solution is good.

2. The `local speed` on the first line is unused so you can safely drop that.

3. You might want to look into using the variable “dt” that is sent to `update()`. It contains the delta time since last frame. Usually this is 1/60 (0,0166666) seconds if you run at 60 frames per seconds. Your speed `self.speed` is currently expressed as “6 pixels per frame” which works fine as long as you don’t drop any frames. It is good practice to express movement in units per second instead so:

```lua
function init(self)
   ...
   self.speed = 360 -- 360 pixels per second
   ...
end

local function goToRight(self, dt)
    local p = go.get_position()
    p.x = p.x + self.speed * dt -- <---- multiply with the delta t value
    ...
end

function update(self, dt)
     goToRight(self, dt)
end

```

---

_[View the full topic](https://forum.defold.com/t/can-you-give-me-hints-to-improve-my-defold-programmation-solved/3709)._
