TriCot-Game-Studio / bullets

bullet heck game
MIT License
0 stars 0 forks source link

make enemies face the way theyre going #31

Closed AdamSpannbauer closed 3 years ago

AdamSpannbauer commented 3 years ago

if x part of velocity is less than zero flip image asset horizontally

aikios commented 3 years ago

i don't think i can assign to myself, so let this serve as my self-assignement

AdamSpannbauer commented 3 years ago

awesome, I've been on vacation away from the computer, hows this going?

aikios commented 3 years ago

Currently sidetracked by school, but I think I have a general idea for the solution (python imaging library)

AdamSpannbauer commented 3 years ago

Instead of introducing a new library I think that pygame.transform.flip should have us covered. The toughest part of this issue will be where/how to place flag indicating that the flip needs to be done. Perhaps as an instance attribute somewhere in the object hierarchy.

aikios commented 3 years ago

Yeah, that's what I was having trouble with. I saw that in most if not all of the cases, the image variable is passed in initialization, so in the current system, with my knowledge, there's no way to change image without initializing the whole thing over again so far

aikios commented 3 years ago

Do you know of a possible fix/resolution? I couldn't find anything on the internet, and a friend I asked said PIL was probably the better solution

AdamSpannbauer commented 3 years ago

There's an example image transformation in body.py; you can use the flip transform in the same way. PIL would work just as well to flip the image, but it's unneeded. The logic of telling the process when to flip is what's needed.

Maybe Body has a flip_img attribute added to it and bullets check their x velocity on update to set this attribute. There could be some interesting interactions with the rotate+flip logic but that should be solvable.

aikios commented 3 years ago

OK, I'll take a look once I get a chance.

aikios commented 3 years ago

@AdamSpannbauer see pull request

aikios commented 3 years ago

@AdamSpannbauer - tested and fixed (see new commits), enemies now turn around like they should