Hello! New Defold user here. ![]()
I am trying to create a low-res (288x208px) flappy bird clone to get a feel for Defold. You can view the project here: GitHub - BLTspirit/rocket-cherry: Flappy bird clone created to learn Defold · GitHub
The Issue
I am scrolling two seamless background sprites that are 288x208 each but there is a seemingly random stutter that is happening with each background layer.
Current Setup Overview
- Using fixed timestep and fixed update frequency of 60
- High DPI off
- Display is set to 288x208
- Texture filters set to nearest
- Fixed camera with 4.0 ortho zoom
- I have a GO with two sprite components that represent two copies of the 288x208 seamless background sprite. They are horizontally adjacent to one another and scroll to the left infinitely via the following code:
-- Define instance (script) properties
go.property("anim", hash("")) --Assigns the proper background layer
go.property("scroll_mult", 1) -- Closest layer scrolls at full speed x1 and furthest layer doesnt scroll (x0)
go.property("depth", -1)
local SPEED = 120
function init(self)
local pos = go.get_position()
pos.z = self.depth
go.set_position(pos)
msg.post("#sprite", "play_animation", {id = self.anim})
msg.post("#sprite1", "play_animation", {id = self.anim})
end
function fixed_update(self, dt)
local pos = go.get_position()
local effective_speed = SPEED * self.scroll_mult * dt
pos.x = pos.x - effective_speed
if pos.x <= -288 then -- If left bg sprite goes completely offscreen, move it to the original position
pos.x = 0
end
pos.x = math.floor(pos.x + 0.5)
go.set_position(pos)
end
- I upscale the window 4x via a game_manage.script in the bootstrap collection:
local level_data = {
"#level_proxy"
}
local scroll_speed = 0
local scroll_acceleration = {1, 2, 3} -- update based on level
local current_level = 1
local state = "menu"
function init(self)
msg.post("#level_proxy", "load")
local width, height = window.get_size()
local scale_factor = 4
local window_w = width * scale_factor
local window_h = height * scale_factor
window.set_size(window_w, window_h)
local window_x = 1920/2 - window_w /2
local window_y = 1080/2 - window_h/2
window.set_position(window_x, window_y)
end
function on_message(self, message_id, message, sender)
if message_id == hash("proxy_loaded") then
msg.post(sender, "init")
msg.post(sender, "enable")
msg.post(sender, "acquire_input_focus")
end
end
Please clarify further, or check out the project. Thanks!!
