On Monday, 9 July 2018 at 09:38:30 UTC, ag0aep6g wrote:
The `win` you're creating in `init` is a function-local
variable. It ceases to exist when `init` returns. It's not
`this.win`.
In `run`, you're accessing `this.win`. It's still null because
you never assigned anything there.
So change
On 07/09/2018 11:18 AM, Flaze07 wrote:
class Game
{
[...]
RenderWindow win;
[...]
void init()
{
[...]
auto win = new RenderWindow( VideoMode( 600, 600 ), "snake" );
[...]
}
void run()
{
[...]
writeln( win is null );
[...]
}
}
the p
On Monday, 9 July 2018 at 09:18:50 UTC, Flaze07 wrote:
I am using DSFML
module game;
[...]
oh, and I forgot, I had
Game myGame;
static this()
{
myGame = new Game;
}
below the Game class
I am using DSFML
module game;
import core.time;
import std.stdio: writeln;
import dsfml.graphics;
import dsfgui.button;
import apple;
import snake;
class Game
{
private:
enum State { menu, playing }
State state;
Font font;
Button playBtn;
Snake snake;
Apple apple;