Hey there,
I changed my render script to center the camera and zoom in if the screen has a larger resolution than the game or zoom out if the screen has a smaller one according to this thread:
The update function of the render script looks like this:
function update(self)
width_original = render.get_width()
height_original = render.get_height()
width_current = render.get_window_width()
height_current = render.get_window_height()
zoom_factor = math.min(width_current / width_original, height_current / height_original)
width_scaled = width_original * zoom_factor
height_scaled = height_original * zoom_factor
render.set_depth_mask(true)
render.clear({[render.BUFFER_COLOR_BIT] = self.clear_color, [render.BUFFER_DEPTH_BIT] = 1,[render.BUFFER_STENCIL_BIT] = 0})
render.set_viewport((width_current - width_scaled) / 2, (height_current - height_scaled) / 2, width_scaled, height_scaled)
render.set_view(self.view)
render.set_depth_mask(false)
render.disable_state(render.STATE_DEPTH_TEST)
render.disable_state(render.STATE_STENCIL_TEST)
render.enable_state(render.STATE_BLEND)
render.set_blend_func(render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA)
render.disable_state(render.STATE_CULL_FACE)
render.set_projection(vmath.matrix4_orthographic(0, width_original, 0, height_original, -1, 1))
render.draw(self.tile_pred)
render.draw(self.particle_pred)
render.draw_debug3d()
render.set_view(vmath.matrix4())
render.enable_state(render.STATE_STENCIL_TEST)
render.draw(self.gui_pred)
render.draw(self.text_pred)
render.disable_state(render.STATE_STENCIL_TEST)
render.set_depth_mask(false)
render.draw_debug2d()
end
Now the question is how to transform the x and y or screen_x and screen_y components of the passed action in the on_input function to world space (x should be negative if left from the game screen or greater than 720 if it’s right from it, y should be negative if below the game screen and greater than 1280 if it’s above it).
Kindly regards
André