lordmauve / pgzero

A zero-boilerplate games programming framework for Python 3, based on Pygame.
https://pygame-zero.readthedocs.io/
GNU Lesser General Public License v3.0
530 stars 190 forks source link

Being able to create clones #245

Closed fillwithjoy1 closed 1 year ago

fillwithjoy1 commented 3 years ago

I've migrated from scratch and the thing I love about Scratch is the ability to create clones and code the clones independently so that they automatically delete themselves. I've been trying to search for solutions but couldn't find anything in pgzero that has something close to Scratch's cloning blocks - When I start as a clone, create clone of [x] and delete this clone. So I am opening this issue here

gotrhythm88 commented 3 years ago

@fillwithjoy1 I can make a short tutorial to show you how I make clones in Pygame Zero if you are interested. It's not that hard of a pattern, once you get used to it.

fillwithjoy1 commented 3 years ago

@gotrhythm88 Please, thank you

gotrhythm88 commented 3 years ago

No problem. Here you go: https://www.loom.com/share/378806b50f1840d9953bc0d83436b7dc

fillwithjoy1 commented 3 years ago

@gotrhythm88 Thank you. So I copied your code and it worked. However my sprite appears behind my screen.fill and therefore unable to be seen w/o removing screen.fill

PS. Can I classify or give clones a special id so they do different things if I created different clones? Plus my clone direction changes accordingly to the player so is there any way of self-destroying the clones?

fillwithjoy1 commented 3 years ago

I'm using list.pop() and .pop(1) however it deletes all the other clones except the first clone created. And the original clone keeps remaining. What to do? @gotrhythm88 Edit: after some experimenting, it seems like .pop deletes 2 clones no matter which implementation I do

gotrhythm88 commented 3 years ago

Use list.remove