Devlog #3 'My own scrolling background script'
One of the main issues i had when start making Gunrun, was finding a way the backgroung scrolls, creating a feeling of movement. Searched in similar runner games gain to find and script that filled my needs. Finally i found a script that used a textureRect node with a material using a sprite (i made it with gimp from using the tilepalette).
shader_type canvas_item; uniform float scroll_speed; void fragment() { vec2 u = UV; u.x += scroll_speed * TIME; vec4 col = texture(TEXTURE, u); COLOR = col; }
It did his job pretty well until i export to HTML5. When i exported the game goes well except for the buged background. So i though that now from the time i started programming the game i learned enough to make my own background, and i wrote this cript:
extends Node export var speed = 3 var reset = Vector2(1152, 0) func _process(delta): $TileMap1.position.x -= speed $TileMap2.position.x -= speed if $TileMap1.position.x == 0: $TileMap1.set_position(reset) elif $TileMap2.position.x == 0: $TileMap2.set_position(reset)
Where 'reset' is the place you want to put the tilemap after he reaches (0,0) and leave the screen. Why is so high? Because since _process(delta) occurs once per a frame and speed don't, the speed has to be a divirsor number of the X on reset. Since i needed speed = 3, i need to use a mutiple of three, as result any of my tileset has to mesure X = 576. Looking like this:
I hope i explain my self well enough, and thank you for reading. Also i hope soon i could make a mobile version, for android as for HTML5.
Files
Get Gunrun longrun
Gunrun longrun
Hectormarq
More posts
- UPDATE #2 'The tactil buttons'Aug 20, 2021
- Devlog #2 'HTML5 joins the Rungun'Aug 12, 2021
- Devlog #1 'Now you can Duck'Aug 11, 2021
Leave a comment
Log in with itch.io to leave a comment.