Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: some suggestions  (Read 32605 times)

0 Members and 2 Guests are viewing this topic.

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
some suggestions
« Reply #15 on: March 08, 2008, 04:29:26 pm »
Ok.. implemented my own simple imageManager..
Code: [Select]

#include <SFML/Graphics.hpp>

#include <map>
#include <string>
#include <iostream>
using namespace sf;
using namespace std;
static map<string, Image> images;

Image * RequestImage(string name)
{
  map<string, Image>::iterator iter = images.find(name);
  if( iter != images.end() )
  {
  return &(iter->second);
  }
  else
  {
  Image tmp;
  images[name]=tmp;
  if(images[name].LoadFromFile("data/gfx/"+name))
  {
  return &images[name];
  }
  else
  {
  return NULL;
  }
  }
}

void DropImage(string name)
{
images.erase(name);
}




usage:
#include "nameImageManagerFile.hpp"

sf::Image *gun=RequestImage("gun.png"); //if already loaded, will return       pointer to the old instance
DropImage("gun.png"); //of not used anymore
All grafics have to stay in data/gfx/ (but you cann simply change the path^^)
greetz TGM

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
some suggestions
« Reply #16 on: March 08, 2008, 05:27:17 pm »
some other stuff:
Make GetWidth etc available again... the user should be able to use vectors, but not forced (for example working with a physics engine suxx if one always have to convert different vector types)

Add normalize() dotProduct() crossProduct() getLength() getLengthSQ() and maybe getAngle (vec1,vec2) //gets the angle between two vectors
to the vector class

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
some suggestions
« Reply #17 on: March 09, 2008, 05:24:34 am »
Quote
Make GetWidth etc available again...

What's the difference between GetSize().x and GetWidth() ?

Quote
(for example working with a physics engine suxx if one always have to convert different vector types)

Whether the components are separate or in a single structure, you will have to construct temporary instances of your physics engine vector anyway.

Quote
Add normalize() dotProduct() crossProduct() getLength() getLengthSQ() and maybe getAngle (vec1,vec2) //gets the angle between two vectors
to the vector class

Yes, it might be useful ;)
Laurent Gomila - SFML developer

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
some suggestions
« Reply #18 on: March 09, 2008, 04:09:24 pm »
well, I prefer to write SetPosition(10.0f,10.f) to write SetPosition(sf::Vec2F(10.0f,10.0f)) that simple.. and is way faster passing two flaots but a struct with two floats to a function.
floats will be pushed on the stack, but for structs only a pointer is pushed so one derefering is needed (though this a very minor thingy..) well, mostly cause it looks better and its more easy  to write  :roll:  :oops:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
some suggestions
« Reply #19 on: March 10, 2008, 02:18:40 am »
I agree, but I still don't know if I'll put back the version taking two floats. It would duplicate a lot of functions, and make the classes interface more messy.
Laurent Gomila - SFML developer

Aszarsha

  • Full Member
  • ***
  • Posts: 200
    • MSN Messenger - aszarsha@gmail.com
    • View Profile
some suggestions
« Reply #20 on: March 10, 2008, 02:30:22 am »
I personally don't like interface using custom vector class, for reasons already discussed here, and others.

Please, Laurent, leave the interface as it is in 1.2 regarding vectors and related.
Adding vector class in not that simple to use (compared to actual interface), nor is faster. I don't really think it's a good idea nor a good addition.

tgm

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
some suggestions
« Reply #21 on: March 10, 2008, 04:40:51 pm »
adding a vector class is a great thing(I wouldn't work with SFML if it hasn't got one) but there must be the way of using multible parameters..
(at least for SetPosition etc) maybe not for Shape::Rec(*4floats here*other stuff)..

TTK-Bandit

  • Newbie
  • *
  • Posts: 21
    • View Profile
some suggestions
« Reply #22 on: March 10, 2008, 05:11:49 pm »
I dont like the idea of vectors & physics in a library like this.. this should be optional.
I am working on a game library,  and it already has a pretty good set of vectors,
if you'd use your vector class all over, I'd always have to convert before I could use stuff.
this may sound selfish in the first place, but I think there are others who would agree with me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
some suggestions
« Reply #23 on: March 11, 2008, 02:20:37 am »
Yeah, I agree. I'll probably put back all the overloads taking two floats directly.
Laurent Gomila - SFML developer