-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combo demo #24
base: main
Are you sure you want to change the base?
Combo demo #24
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
combo-demo/player/Player.gd
Outdated
var _previous_light_combo := "light_combo_3" | ||
var _previous_heavy_combo := "heavy_combo_2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
combo-demo/player/Player.gd
Outdated
func set_accept_next_attack() -> void: | ||
_accept_next_attack = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 = value
Otherwise you're making a function that works differently from most functions named set_*
combo-demo/player/Player.gd
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.