[002] Snake
[002] Snake
- streamlined 'menu' system
- single file logic (make it work first)
- no need to organize early
- need to improve pseudocode writing skills
Create Alternative Tiles in Tilemap
[code]
var _my_source: TileSetAtlasSource = tile_set.get_source(0) as TileSetAtlasSource var _tile_id: int = _my_source.create_alternative_tile(Vector2i.ZERO) var _tile_data: TileData = _my_source.get_tile_data(Vector2i.ZERO, _tile_id)
Optimal Tilemap Movement
[pseudocode]
only change the head and tail of the snake keep track of each snake tiles keep track of tail index (start at 0) on each step track old tail index track old head index [tail_index - 1] track new head index = old head_index + direction on move old tail index in array = new head remove old tail tile add new head tile tail_index += 1 if tail_index == snake_array.size(): tail_index = 0
Snake Color
[pseudocode]
lerp_step = 1.0 / snake size lerp_curr = lerp_step var index: int = tail_index for i in snake_size: tile_data[index].modulate = TAIL_COLOR.lerp(HEAD_COLOR, lerp_curr) lerp_curr += lerp_step index += 1 if index == snake_size: index = 0
Status | Released |
Platforms | HTML5 |
Author | QuietGodot |
Made with | Godot |
Leave a comment
Log in with itch.io to leave a comment.