Re: [Dgame] Sprite loading and setting position in another class

2015-08-25 Thread Namespace via Digitalmars-d-learn
Thank you for answering so quickly. If you don't mind me asking 
when will v0.7 be out?


Not so soon. But maybe I'll release v0.6.5 with this feature at 
the end of september.

For now you need to store your Texture in e.g. a Texture manager.


Re: [Dgame] Sprite loading and setting position in another class

2015-08-25 Thread Jack via Digitalmars-d-learn

On Tuesday, 25 August 2015 at 13:22:43 UTC, Namespace wrote:

Edit:

 Basically my code is:
 //Texman.d//

 Class TextureManager
 {
  //variables

void addSprite(string sprite_file, string name)
{   
Surface wiki_img = Surface(sprite_file);
Texture wiki_tex = Texture(wiki_img);
sprite_list[name] = new Sprite(wiki_tex);
sprite_list[name].setPosition(1,1); //tried to
 remedy by this 
}
 }


You have to store your Texture. See My Sprite is only a white 
Rectangle on http://dgame-dev.de/index.php?controller=faq


I'll change that with v0.7, so that Sprite will manage the 
Texture by himself.


Thank you for answering so quickly. If you don't mind me asking 
when will v0.7 be out?


Re: [Dgame] Sprite loading and setting position in another class

2015-08-25 Thread Namespace via Digitalmars-d-learn

Edit:

 Basically my code is:
 //Texman.d//

 Class TextureManager
 {
  //variables

void addSprite(string sprite_file, string name)
{   
Surface wiki_img = Surface(sprite_file);
Texture wiki_tex = Texture(wiki_img);
sprite_list[name] = new Sprite(wiki_tex);
sprite_list[name].setPosition(1,1); //tried to
 remedy by this 
}
 }


You have to store your Texture. See My Sprite is only a white 
Rectangle on http://dgame-dev.de/index.php?controller=faq


I'll change that with v0.7, so that Sprite will manage the 
Texture by himself.


Re: [Dgame] Sprite loading and setting position in another class

2015-08-25 Thread Jack via Digitalmars-d-learn

On Tuesday, 25 August 2015 at 12:50:50 UTC, Jack wrote:
So I've been using Dgame to learn about game development and 
I'm having an error when I'm trying to set a sprite's position 
initialized and stored in another class.


Basically my code is:
//Texman.d//

Class Texman
{
  //variables

void addSprite(string sprite_file, string name)
{
Surface wiki_img = Surface(sprite_file);
Texture wiki_tex = Texture(wiki_img);
sprite_list[name] = new Sprite(wiki_tex);
sprite_list[name].setPosition(1,1); //tried to 
remedy by this		

}
}

//GameObject.d

class GameObject
{
Sprite sprite;
float location_x;
float location_y;
//other variables

void setLocation(float x, float y)
{
sprite.setPosition(x,y);
location_x = x;
location_y = y;
}
}

//main.d/


void create()
{
wnd = Window(1024, 720, Dgame Test);
sample_object = new GameObject();
texman = new TextureManager();
texman.addSprite(images.png, kirino);
sample_object.setSprite(texman.getSprite(kirino));
sample_object.setLocation(500,500);
}
//

And I'm having an error namely
First-chance exception: core.exception.AssertError null
pointing at the setLocation on GameObject.d.

I tried to remove the setLocation method and tried to set 
Location on TextureManager itself and it worked.


So is setting the position of a sprite outside of the class it 
initialized into forbidden, or am I doing something wrong here?


Edit:

 Basically my code is:
 //Texman.d//

 Class TextureManager
 {
  //variables

void addSprite(string sprite_file, string name)
{   
Surface wiki_img = Surface(sprite_file);
Texture wiki_tex = Texture(wiki_img);
sprite_list[name] = new Sprite(wiki_tex);
sprite_list[name].setPosition(1,1); //tried to
 remedy by this 
}
 }


[Dgame] Sprite loading and setting position in another class

2015-08-25 Thread Jack via Digitalmars-d-learn
So I've been using Dgame to learn about game development and I'm 
having an error when I'm trying to set a sprite's position 
initialized and stored in another class.


Basically my code is:
//Texman.d//

Class Texman
{
  //variables

void addSprite(string sprite_file, string name)
{
Surface wiki_img = Surface(sprite_file);
Texture wiki_tex = Texture(wiki_img);
sprite_list[name] = new Sprite(wiki_tex);
sprite_list[name].setPosition(1,1); //tried to 
remedy by this		

}
}

//GameObject.d

class GameObject
{
Sprite sprite;
float location_x;
float location_y;
//other variables

void setLocation(float x, float y)
{
sprite.setPosition(x,y);
location_x = x;
location_y = y;
}
}

//main.d/


void create()
{
wnd = Window(1024, 720, Dgame Test);
sample_object = new GameObject();
texman = new TextureManager();
texman.addSprite(images.png, kirino);
sample_object.setSprite(texman.getSprite(kirino));
sample_object.setLocation(500,500);
}
//

And I'm having an error namely
First-chance exception: core.exception.AssertError null
pointing at the setLocation on GameObject.d.

I tried to remove the setLocation method and tried to set 
Location on TextureManager itself and it worked.


So is setting the position of a sprite outside of the class it 
initialized into forbidden, or am I doing something wrong here?


Re: [Dgame] Sprite loading and setting position in another class

2015-08-25 Thread Namespace via Digitalmars-d-learn
Note that Texture is (in constrast to Sprite) a struct and not a 
class, so it is a value type. Dgame tries to use as many value 
types as possible to reduce the amount of garbage.