Re: (Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread eXodiquas via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 15:35:57 UTC, Adam D. Ruppe wrote: On Wednesday, 28 April 2021 at 15:09:36 UTC, eXodiquas wrote: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); This `new` is actually run at compile time, so every instance of Particle refers to the

Re: (Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 28 April 2021 at 15:09:36 UTC, eXodiquas wrote: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); This `new` is actually run at compile time, so every instance of Particle refers to the same instance of CircleShape (unless you rebind it).

(Maybe) Strange Behaviour of Field Initialization

2021-04-28 Thread eXodiquas via Digitalmars-d-learn
Hello everyone, I am playing around with DSFML and drawing some stuff on the screen. It works like a charm but I got some unexpected behavior when building a `Particle` class. My class looks like this: ```d class Particle : Drawable { CircleShape shape = new CircleShape(5); this(int x,