Alternative (beginner) way to write this code?

How do I write the code (below) in an alternative (beginner) way? I don’t wish to use createShape, setFill and addChild. Instead, any other way to perform the same thing?

grid = createShape(GROUP)
for i in range(C*R):
    self.cell = createShape(RECT, (i%C)*S, (i//C)*S, S, S)
    self.cell.setFill(colors[i] if i in filled else 210)

Hi @millionish,

I’m sorry you couldn’t make use of the createShape() function. I can try to find another way but would you mind first explaining what exactly is the problem (1D coordinates or the shape making?) and what you are trying to do ?

This snippet alone doesn’t reveal much about your intention so it would help that you post the whole code or at least the related parts (I see a self so the corresponding class object would be nice for example)

Really, do not hesitate to share extra details, thoughts or questions. Also it would be appreciated that you keep your questions and code posted for clarity (avoid removing/deleting them) and out of respect for future readers who might have similar issues.

1 Like

Again, please post the full code.

Thank you.

It seems you forgot a parenthesis () after game.Grid in draw().

omg!!! I feel so stupid lol… Thanks anyways :slight_smile:

No problem, typos happen a lot when writing code.