fastRunner/TileMap.gd

36 lines
980 B
GDScript
Raw Normal View History

2024-02-22 20:33:20 -05:00
extends TileMap
@onready var player =$"../CharacterBody2D"
var rng = RandomNumberGenerator.new()
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func roller():
var rum = rng.randi_range(0, 200)
return rum
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
var playerPos = self.local_to_map(player.position)
NewScript.playerPoScore()
#var tilePos = playerPos+Vector2i(16,2)
var tilePos = Vector2i(playerPos.x+(16),11)
var tileCheck = tilePos + Vector2i(1,1)
#print(playerPos)
#print($"../TileMap".get_cell_tile_data(0,tileCheck,false))
#print(tileCheck)
if $".".get_cell_tile_data(0,tileCheck,false) == null:
set_pattern(0,tilePos +Vector2i(3,0),tile_set.get_pattern(1))
if int(player.position.x) % 7 == 0:
var rum = roller()
if rum > 180:
set_pattern(1,tilePos-Vector2i(-8,5),tile_set.get_pattern(4))
if get_cell_tile_data(1,playerPos):
NewScript.hit()