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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Reiv

Pages: [1]
1
Graphics / ImageManager
« on: June 26, 2011, 03:50:44 pm »
Hi, I am creating class that has image manager from sfmlwiki to load images and vector< vector ... <sf::Image*> ..> to keep images and animations in 1 global class for quickier access (Image manager keeps Images by string "path" and these vectores keeps Images by index and loades them from ImageManager to prevent loading the same image)
something like this:

class SuperImageManager {

  /*5d vector*/ character[sex][body part][direction][animation][frame]
  /*2d vector*/ texture[number]
  /*3d vector*/texture_animated[animation][frame]  //all sf::Image *
  ...

  ImageManager im;
};

class Character{
  int direction;
  int state; // walking/running/standing...
  int action // fighting/jumping...

  sf::Image *..*animation;
}
Character ch();
ch.animation = SuperImageManager.character[0] // eg 0 = male 1 = female...

and then:
App.draw(ch->animation[body_part][direction][state][action][int some_anim_func_Update()]);
...

The point is:
a) isnt this totally stupid? :D

b) if I reserve place for vectores in SuperImageConstructor() by this:

for ( int i = 0; i < SOMEINT; i++ )
{
  this->(*..*character).push_back ( vector< <vector... <sf::Image*> >..>);
  for ( int j = 0; j < OTHERINT; j++ )
  {
     this->(*..*character)[j].push_back ( vector< <vector... <sf::Image*> >..>);
      for (int k = 0; k < ANOTHERINT; k++)
     {
        .
        .
        .
     }            
  }
}

or vector.reserve

And I dont load every image on program start up (eg only character animations. Terraint textures, trees etc on map loading) does the vector need to realloc space when I have every sf::Image pointer reserved (I know how many pictures will I load) and I do character[j][k]..[z].LoadFromFile/ImageManager() )

Also who understand what I am trying to say with my crappy english is awesome :D

2
Graphics / sprite.SetImage efficiency?
« on: June 20, 2011, 06:16:46 pm »
Quote from: "Laurent"
malloc is for the C world, it doesn't call constructors of C++ classes. Use new instead.


yeah I figure it out and tried new too, but it gives me the same exception :/

edit: I tried try and catch(...) and now it works  :shock: nevermind then

3
Graphics / sprite.SetImage efficiency?
« on: June 20, 2011, 06:09:03 pm »
Thanks, I will look at it.

But could anyone tell me if there is something wrong with this code? It gives me Access Violation:

sf::Image *img;

img = (sf::Image *) malloc(sizeof(sf::Image) * SOME_CONST);
if (img == NULL)
{
    print and exit;
}

img[0].LoadFromFile("name.png"); << Access violation reading location at blah

*I know that name.png and number in [] is correct.

4
Graphics / sprite.SetImage efficiency?
« on: June 20, 2011, 05:10:40 pm »
Hi, I am working on character animation and I want to know if its good to:

sprite.SetImage(sf::Image animation[direction][frame]...);
App.Draw(sprite);
in game loop,

or its better to have array of sprites and do App.Draw(sprite[direc.][frame]...)?
I find the first option better, because then I can GetPosition and SetPosition etc.. only for one sprite, but the tutorial says that manipulating Images is slow, so dont I lose some efficiency?

5
Graphics / sprite detection by coordinates
« on: June 18, 2011, 08:35:15 pm »
Hi I couldn't figure how I can the application detect if eg. some mouse over some Sprite.
I have background sprite, character sprite and some npc sprite etc. I can get coordinates of every sprite by sf::sprite name.GetPosition(), but is there some other way around? Can I somehow get sf::sprite object by using coordinates.
For example I get mouse coordinates and I want to know if there is some sprite on this coordinates.
Thanks  :oops:

6
Network / UDP packet size
« on: June 16, 2011, 05:23:51 pm »
btw is there some way to send only bits? eg. for character direction in 2d game I would need only 4-bit information. (Dont look on portability right now)

7
General discussions / mmorpg server question
« on: June 12, 2011, 10:49:57 am »
And do you know how it is done? does server counts distances for players so that it knows who is closer to someone?

8
General discussions / mmorpg server question
« on: June 11, 2011, 06:09:54 pm »
but that would mean that if there is N players he compute Nx position for every player and sends it, that would means something like:
computing and sending position for 1 player (N+N) and he would have to do that for every player so: (N+N)xN operations every eg. +-half second (dont know how often to keep smooth moving of object) and computing the distance or sending it to player isnt just 1 operation either.

Or am I missing something?

9
System / Thread creation starts to fail.
« on: June 11, 2011, 05:12:58 pm »
Quote from: "Groogy"
...


Thanks for reply, I am just at the phase of making design, and learning what is best(also testing some ideas on examples I create), so I will know which way will be the best for me.

And when i saw how easiest it is to work with threads than to work with processes (at least for me, shared memory, mutex etc.. i hate that  :? ) I tried to make design in which threads works with their own proms and communicate with other threads by pipes/sockets etc.
But now I get that 1 thread that makes 1000 loop  != 10 threads making 100 loopes each

10
General discussions / mmorpg server question
« on: June 11, 2011, 04:40:35 pm »
How does mmorpg server knows to whom he should send other players position so that client A know he has to draw player from client B on x,y position, player C on x2,y2 position...

I can think only 3 solution.
1) he sends it to every player, but that would be impossible

2) he keeps players in some sorted list/array/whatever and send it just to n nearnest players (eg. for player 55 he send information about position of players 45-56)
but then keeping that list/array/whatever shorted would take the server too much work


3) he send it to every player in area, he send info on players to every player who is with him in the same area (and listening client can make distantion check (packet >> x >> y; if ( ((x - yourx) > maxdistance) || (y-youry) > maxdistance) drop packet; else process packet, draw player from packet...)

but this would mean that game areas should be small, else clients would get hundreads of informations on players that they dont need to follow (they are too far)

I just cant figure out how is this done efficiently

11
System / Thread creation starts to fail.
« on: June 11, 2011, 03:53:43 pm »
Since you are talking about threads than hypothetically what is better?
To make 1 thread for every area of mmorpg to ensure that every area is handled "at the same time" (+-100 threads) or to make few threads that would handle the same job? (I thinked concept in which main thread writes to shared proms and other threads can only read from them, so teoreticcaly scenario in which deadlock isnt problem)?

edit: on eg. 4-core 2+Ghz processor

12
Network / UDP packet size
« on: June 09, 2011, 10:33:37 pm »
of course it was just example in reality it would be bigger, but since packet adds only 4 bytes i will stick with that, thanks for reply :)

13
Network / UDP packet size
« on: June 09, 2011, 02:53:02 pm »
I am using sfml for my project and i want to ask what is the difference in size between sending bitstream(char *data, sizeof(data) and sending packet with data?

Because sizeof(sf::Packet) returns 32 B to and that seems to much to me.
Does this mean that if i make my own bitstream representation of packet (char *mypacket = "00011100 ...etc" (eg first 4 bites represents size of head etc..)) and it will be smaller than 32bytes is it than smaller then packet or does Send function wraps some other data on it?

Pages: [1]
anything