-
Notifications
You must be signed in to change notification settings - Fork 6
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
Implement enemies #14
Comments
Initial try at implementation can be found in the enemy branch |
@johnthagen Any thoughts on how I broke this out (minus the obviously stand-in parts like rendering)? Not sure how idiomatic it is. |
Updated the logic in 1e03596 to account for the fact that the canvas is a torus. |
@johnthagen Check out the new push on enemy. Merged in the traits you wrote, also changed how they work a tiny bit. I feel like there has to be a better way to share more code, but this is what I have for now. Due to the architectural changes, I can't think of a clean way to feed the enemy the player's position, so it's just accelerating toward a fixed point right now. |
@mcdenhoed First off, I love how you can see the enemies' thrusters now. So funny watching it make tons of little corrections 😄 Tiny thing, I think you accidentally checked in Ah, I see what you did with the pub fn update<T: Updateable>(x: &mut T, args: UpdateArgs) {
x.update_location();
x.update_logic(args);
} And then: update(&mut self.player, args);
update(&mut self.enemy, args); Couldn't And then player.update(args)
enemy.update(args) I think it makes a little more sense to take I do like the idea of having private trait methods that get called in a default trait implementation to try to reuse code. |
I guess my thought was, if we do end up having large lists of things, would it be easier to call "update" on an updateable thing than to call the "update" method of an updatable thing? The second seems like an OOP pattern, and the first seemed to me to be more idiomatic. I can change that back though. Still not sure how we can cleanly get shared code for something like position updates with this system. Trait default implementations are still limited to calling other methods defined/guaranteed by the trait, so I feel like our hands are still tied there. |
They really are functionally equivalent, so I think it's really just semantics. To me it seemed slightly more idiomatic to keep all of the related functionality within a single One nice thing is that no matter which way, if we have large lists of
Absolutely, the only thing I can really think of is that we have to model the problem with composition. Instead of Since enemies are quite a bit more complex than the weapon #5 and asteroids #7 , maybe we should try those out first and see what kinds of shared code comes out of that. Also, I've had good luck asking this kind of question on https://users.rust-lang.org/ so we could try that too. |
I might try readding the actor code then |
@mcdenhoed Is the |
No description provided.
The text was updated successfully, but these errors were encountered: