Tile.gd 847 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. class_name Tile
  2. extends Sprite2D
  3. var biteSprite := preload("res://pacbiite.png")
  4. var powerSprite := preload("res://pacpower.png")
  5. var hasBite: bool:
  6. set (val):
  7. hasBite = val
  8. updateMe()
  9. var hasPower: bool:
  10. set (val):
  11. hasPower = val
  12. updateMe()
  13. var isWall: bool:
  14. set (val):
  15. isWall = val
  16. updateMe()
  17. var isPacmanIntersection: bool:
  18. set (val):
  19. isPacmanIntersection = val
  20. updateMe()
  21. var isGhostIntersection: bool:
  22. set (val):
  23. isGhostIntersection = val
  24. updateMe()
  25. func _init(hb:bool, hp:bool, wall:bool, pint:bool, gint:bool):
  26. hasBite = hb
  27. hasPower = hp
  28. isWall = wall
  29. isPacmanIntersection = pint
  30. isGhostIntersection = gint
  31. func updateMe():
  32. if hasBite:
  33. texture = biteSprite
  34. elif (!hasBite):
  35. texture = Texture2D.new()
  36. if hasPower:
  37. texture = powerSprite
  38. elif (!hasPower && !hasBite):
  39. texture = Texture2D.new()