summaryrefslogtreecommitdiff
path: root/src/entities/food/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/entities/food/scripts')
-rw-r--r--src/entities/food/scripts/food.gd3
-rw-r--r--src/entities/food/scripts/food_basic.gd4
-rw-r--r--src/entities/food/scripts/food_manager.gd7
-rw-r--r--src/entities/food/scripts/food_special.gd4
4 files changed, 11 insertions, 7 deletions
diff --git a/src/entities/food/scripts/food.gd b/src/entities/food/scripts/food.gd
index 386f0e5..e4bbc21 100644
--- a/src/entities/food/scripts/food.gd
+++ b/src/entities/food/scripts/food.gd
@@ -21,7 +21,7 @@ func update_texture() -> void:
_sprite.texture = texture[properties["type"]]
-func set_properties(pos: Vector2, loc: Vector2, special: bool, type: int, points: int=1, ttl: float = -1.0) -> void:
+func set_properties(pos: Vector2, loc: Vector2, special: bool, type: int, points: int=1, special_points: int=1, ttl: float = -1.0) -> void:
properties["global_position"] = pos
global_position = pos
properties["location"] = loc
@@ -29,6 +29,7 @@ func set_properties(pos: Vector2, loc: Vector2, special: bool, type: int, points
properties["type"] = type
properties["points"] = points
+ properties["special_points"] = special_points
properties["ttl"] = ttl
if properties["ttl"] != -1.0:
timer.wait_time = properties["ttl"]
diff --git a/src/entities/food/scripts/food_basic.gd b/src/entities/food/scripts/food_basic.gd
index 8090cdc..cfeec18 100644
--- a/src/entities/food/scripts/food_basic.gd
+++ b/src/entities/food/scripts/food_basic.gd
@@ -3,10 +3,12 @@ extends Food
enum Type {
APPLE,
- BANANA
+ BANANA,
+ RAT
}
func _ready():
texture[Type.APPLE] = preload("res://entities/food/sprites/apple.png")
texture[Type.BANANA] = preload("res://entities/food/sprites/banana.png")
+ texture[Type.RAT] = preload("res://entities/food/sprites/rat.png")
diff --git a/src/entities/food/scripts/food_manager.gd b/src/entities/food/scripts/food_manager.gd
index a605f9e..e6c7248 100644
--- a/src/entities/food/scripts/food_manager.gd
+++ b/src/entities/food/scripts/food_manager.gd
@@ -41,7 +41,10 @@ func _place_new_basic_food() -> void:
var loc: Vector2 = pos_loc[1]
# need to set the position first, else it will spawn on the middle and the moved
- food.set_properties(pos, loc, false, type)
+ if type == FoodBasic.Type.RAT:
+ food.set_properties(pos, loc, false, type, Global.POINTS_TO_GROW / 2)
+ else:
+ food.set_properties(pos, loc, false, type)
add_child(food)
food.update_texture()
current_basic_food.append(loc)
@@ -57,7 +60,7 @@ func _place_new_special_food() -> void:
var loc: Vector2 = pos_loc[1]
# need to set the position first, else it will spawn on the middle and the moved
- food.set_properties(pos, loc, true, type, Global.POINTS_TO_GROW)
+ food.set_properties(pos, loc, true, type, Global.POINTS_TO_GROW, Global.POINTS_TO_GROW / Global.POINTS_TO_GROW)
add_child(food)
food.update_texture()
current_special_food.append(loc)
diff --git a/src/entities/food/scripts/food_special.gd b/src/entities/food/scripts/food_special.gd
index c2fde78..45d0c56 100644
--- a/src/entities/food/scripts/food_special.gd
+++ b/src/entities/food/scripts/food_special.gd
@@ -3,9 +3,8 @@ extends Food
enum Type {
BUNNY,
- FROG,
TURTLE,
- RAT
+ FROG
}
@@ -13,4 +12,3 @@ func _ready():
texture[Type.BUNNY] = preload("res://entities/food/sprites/bunny.png")
texture[Type.FROG] = preload("res://entities/food/sprites/frog.png")
texture[Type.TURTLE] = preload("res://entities/food/sprites/turtle.png")
- texture[Type.RAT] = preload("res://entities/food/sprites/rat.png")