Combo demo#24
Conversation
NathanLovato
left a comment
There was a problem hiding this comment.
The main issue I have with this code is how it relies on individual variables to handle combos. It is functional but does not teach our students something very useful for them.
We should at least show an approach that is somewhat scalable or applicable to the kinds of games that people want to make.
| var _previous_light_combo := "light_combo_3" | ||
| var _previous_heavy_combo := "heavy_combo_2" |
There was a problem hiding this comment.
This isn't great. I'd rather have something a bit more of a system that makes editing combos efficient. An array of attacks you used as part of a combo would be preferable
| func set_accept_next_attack() -> void: | ||
| _accept_next_attack = true |
There was a problem hiding this comment.
If you're going to have a setter function, you might as well make the property public, use setget, and give the setter function a default argument of true.
func set_accept_next_attack(value := true) -> void:
accept_next_attack = valueOtherwise you're making a function that works differently from most functions named set_*
| func _unhandled_input(event: InputEvent) -> void: | ||
| if event.is_action_pressed("light_attack") and _accept_next_attack: | ||
| _previous_heavy_combo = "heavy_combo_2" | ||
|
|
||
| _state = States.LIGHT_ATTACK | ||
| _accept_next_attack = false | ||
|
|
||
| _animation_player.stop() | ||
| _animation_player.play("idle") | ||
|
|
||
| match _previous_light_combo: | ||
| "light_combo_1": | ||
| _animation_player.play("light_combo_2") | ||
| "light_combo_2": | ||
| _animation_player.play("light_combo_3") | ||
| "light_combo_3": | ||
| _animation_player.play("light_combo_1") | ||
|
|
||
| _previous_light_combo = _animation_player.current_animation | ||
| return | ||
|
|
||
| if event.is_action_pressed("heavy_attack") and _accept_next_attack: | ||
| _previous_light_combo = "light_combo_3" | ||
|
|
||
| _state = States.HEAVY_ATTACK | ||
| _accept_next_attack = false | ||
|
|
||
| _animation_player.stop() | ||
| _animation_player.play("idle") | ||
|
|
||
| match _previous_heavy_combo: | ||
| "heavy_combo_1": | ||
| _animation_player.play("heavy_combo_2") | ||
| "heavy_combo_2": | ||
| _animation_player.play("heavy_combo_1") | ||
|
|
||
| _previous_heavy_combo = _animation_player.current_animation | ||
| return |
There was a problem hiding this comment.
This is the code I think we should change the most about this demo because it's very hard-coded.
It is completely fine in the context of a game where all you're going to have is one or two combos. But as we make these demos for educational purposes, we have to design them with what our students want to learn in mind.
No description provided.