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.


Topics - Kerachi

Pages: [1]
1
Network / Receiving data
« on: December 18, 2017, 06:07:04 pm »
I'm trying to learn sfml network, but there are so few example, and even if I find some, those are wrong or just weird.
For example, this code:
https://github.com/SFML/SFML/wiki/Source:-Network-Chat-Example
seems okay, but in the DoStuff thread, the
Code: [Select]
sf::Packet packetSend;
globalMutex.lock();
packetSend << msgSend;
globalMutex.unlock();

socket.send(packetSend);
part constantly sending(spamming) data and it's eats a ton of processing power, however if I delete that part, then the socket.receive(packetReceive); simply won't run, even if I send data, from another client.

Why is that?
Can someone give me a good source code for client-server game program? (I don't mind if it complex)
I think I already know the basics theory, but that would be great, if someone share with me a good free article, book or video about sfml network.

I hope it's something obvious thing (just not for me :) )

2
General / A noob can't handle lists
« on: November 26, 2017, 04:12:43 pm »
I have a Wall Class, and I store them in a list:
std::list<Wall> walls;

But when I add a wall like:

Code: [Select]
texture.loadFromFile("wall.png");
walls.push_back(Wall(texture, 500.f, 490.f, 4)); //arguments: texture, position X, postion Y, direction 4 = down

Then it's works, but the texture shown like it would be a nullptr. (So it's a white rectangle)
I draw it the walls this way:

Code: [Select]
for (Wall const &wal : walls)
wal.draw(window);

But if I add another wall to the list, then the first one is appear fine, but the second one is white, like:


And if I add different textured walls like:
Code: [Select]
texture.loadFromFile("wall.png");
walls.push_back(Wall(texture, 500.f, 490.f, 4));
walls.push_back(Wall(texture, 563.f, 490.f, 4));
walls.push_back(Wall(texture, 626.f, 490.f, 4));
walls.push_back(Wall(texture, 500.f, 600.f, 4));
walls.push_back(Wall(texture, 563.f, 600.f, 4));
walls.push_back(Wall(texture, 626.f, 600.f, 4));

texture.loadFromFile("wall2.png");
walls.push_back(Wall(texture, 720.f, 540.f, 0));

then 6. (the one before texture changes) will be corrupted:



I spend about 6 days of free time to figure out what could be the problem, and so far I managed to identify that the poblem is with my list, but I don't know what.

Because, if I create walls without adding to the a list, and draw them, then everything works, as intended.
(Of course I tried vectors , arrays, and so on, but I thing it would be reasonable to store them in a list)

The entire source code could be found at my GitHub: https://github.com/Kerachi/Kerachi

Any idea?

3
General / text.setColor declared deprecated
« on: November 23, 2017, 09:47:36 pm »
Hi everyone!

It worked perfectly in CodeBlocks, but I keep getting this error in Visual Studio:


Any idea what am I doing wrong?

4
Graphics / One Big Image VS Lot Little
« on: November 12, 2017, 08:05:22 pm »
Hi everybody!

I'm pretty new to SFML, but I like it so far, and I would like to ask about that, should I use one big image and slice it, or use lot but little images as texture?

For example:
One big PLAYER.png file, but it contains all moves and animations, VS lot little png files, like:
player_animaton 1.png
player_animaiton 2.png
player_animaiton 3.png
...
and store them in a vector or list, like:  std::vector<sf::Image> ...

I thought store the player moves and acts in lot but little images is better organized, but whenever I see a tutorial everyone use the one big image mode  :(

Like:
Texture.loadFromFile("player.png", sf::IntRect(X_beginning, Y_beginning, X_end, Y_end));

But it seem slow to me, I do like better this way:
Texture.update(imageList[currentImage]);

//imageList is a vector which contains, the already readed images...
//currentImage is a number, which is the next frame...
/*btw, I don't know the difference between Texture.update() and Texture.loadFromImage(), but I assume the update is faster */

I'm not sure what's wrong with this mode, is it slow, or is it better? Why no one use it? Or if I try to make a game like diablo 2, then should I use 3D models, instead?

Sorry for the lot questions, but I'm not sure, I'm in the right way  :(

Pages: [1]