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 - ILostMyAccount

Pages: [1] 2
1
DotNet / Re: How easy is it gonna be to port my engine in .net?
« on: November 01, 2015, 11:41:31 am »
Strictly speaking of SFML, no, the API is exactly the same. For the rest... it all depends on your skills ;)
Ok, thank you.

Do you think I'm gonna lose a lot as far as performance goes?

2
DotNet / How easy is it gonna be to port my engine in .net?
« on: November 01, 2015, 10:58:10 am »
Do you think is going to be difficult porting my C++/SFML engine to C#/SFML?

3
Graphics / Re: Sprite bounds problem?
« on: February 20, 2015, 02:05:41 pm »
Test against the global bounds, not the local ones.
Thank you, that fixed the problem

4
Graphics / Sprite bounds problem?
« on: February 20, 2015, 01:04:18 pm »
I'm trying to make a button, everything is working fine, except for one thing.
If I try to move or scale the button the bounds don't change, and obviously the mouseclick still gets detected at the initial position.

This is my button update code:
                mCDTime = mCDClock.getElapsedTime();
                if (mEnabled && mCDTime > sf::Time(sf::seconds(0.30f)))
                {
                        auto spriteBounds = mSprite.getLocalBounds();
                        auto mousePosition = sf::Mouse::getPosition(*mWindowPtr);
                        if (spriteBounds.contains(static_cast<sf::Vector2f>(mousePosition)) && sf::Mouse::isButtonPressed(sf::Mouse::Button::Left))
                        {
                                OnClick();
                                mCDClock.restart();
                        }
                        mText.setPosition(mSprite.getPosition());
                        mText.setScale(mSprite.getScale());
                        mText.setRotation(mSprite.getRotation());
                }

5
Graphics / Sprite batching?
« on: February 17, 2015, 11:11:58 am »
Can someone explain me what exactly is the sprite batching?
And can you link me an example of code in SFML?

Thank you.

6
Graphics / Is this correct?
« on: February 06, 2015, 01:20:05 pm »
As the title says, is this correct?

7
SFML projects / Re: Moonman (my sfml game is on kickstarter!)
« on: February 06, 2015, 08:39:51 am »
Wow, this is so good, not my kind of game but it's really well done and the graphic style is incredible.
Also this kind of games it's usually popular on YT, have you thought about giving it for free to a few youtubers?
you could get a lot of attention in that way.

--
Also code related question, if I can ask, you said that you are for the most part using sf::sprites, for the terrain too? doesn't that cause issues? or the culling is enough to avoid problems?

8
General / SFML + Box2D?
« on: January 29, 2015, 01:18:27 pm »
Hi, I don't know if posting this is against the rules but I've learned a decent part of SFML now, and since I wouldn't even be able to create a decent physic/collision system Box2D should be able to help me, though I have no idea where to start, can you link me a good guide to use SFML + Box2D?

9
General / Re: Is this going to cause performance issues?
« on: January 28, 2015, 11:27:21 am »
Now it's like this
        sf::Texture texture;
        texture.loadFromFile("Resources/Sprites/SpriteSheet.png");
        sf::Sprite sprite[16];
        int count = 0;
        for (int line = 0; line <= 64; line += 64)
        {
                for (int column = 0; column < 512; column += 64)
                {
                        sprite[count].setTexture(texture);
                        sprite[count].setTextureRect(sf::IntRect(column, line, 64, 64));
                        count++;
                }
        }
 

10
General / Re: Is this going to cause performance issues?
« on: January 28, 2015, 11:21:26 am »
Why do you want to create a texture for each rect?

Just load the whole image into your texture and draw the needed rect with a sprite.
See setSubRect(...) in the sf::Sprite class.
Ok, thank you!

11
General / Is this going to cause performance issues?
« on: January 28, 2015, 11:12:58 am »
I'm loading the textures like this:
        sf::Texture texture[16];
        int count = 0;
        for (int line = 0; line <= 64; line += 64)
        {
                for (int column = 0; column < 512; column += 64)
                {
                         texture[count].loadFromFile("Resources/Sprites/SpriteSheet.png",sf::IntRect(column,line,64,64));
                         count++;
                }
        }
Am I going to take any advantage from the fact that they are on the same image file? Or is this just going to make things worse?

12
Network / TCP fail to send data
« on: January 21, 2015, 03:16:14 pm »
What's wrong with this? :
        while (!done)
        {
                std::cout << "Creating connection" << std::endl;
                sf::TcpSocket socket;
                sf::Socket::Status status = socket.connect("192.168.0.5", 53000);
                if (status != sf::Socket::Done)
                {
                        std::cout << "Client Error" << std::endl;
                }
                std::cout << "Created" << std::endl;
                char data[100] = { 'H', 'e', 'l', 'l', 'o', '\0' };
                system("pause");
                if (socket.send(data, 100) != sf::Socket::Done)
                {
                        std::cout << "Client Error : Couldn't send data" << std::endl;
                }
        }

Basically it sends the data the first time, then fail the second, and work the third, and fail the fourth and... you get what I mean...

How do I fix it?

(Ignore the "system("pause")" it's just to test and it's faster than typing something everytime.

13
General / Re: How should the code be organized?
« on: December 24, 2014, 10:44:42 pm »
Thank you for the answers.
Yes, a tutorial/guide or a good project to refer to would be nice, I'm just starting with SFML, I've read these: http://www.sfml-dev.org/tutorials/2.2/ but I really have no idea how to organize everything, I hate when I have too much stuff in my main if it's not necessary.


14
General / Re: How should the code be organized?
« on: December 23, 2014, 08:08:40 pm »
Hey guys sorry if I keep posting dumb questions but it's basically the first time in game development without an engine that takes care of everything, so...

Based on your suggestions I wrote this:

#include "Engine.h"


Engine::Engine(sf::RenderWindow *window)
{
        window_ = window;
}

Engine::Engine(sf::RenderWindow *window, bool vsync)
{
        window_ = window;
        window_->setVerticalSyncEnabled(vsync);
        vsync_status_ = vsync;
}

Engine::~Engine()
{
}

void Engine::Update(sf::Time elapsed_time)
{
        sf::Event e;
        while (window_->pollEvent(e))
        {
                if (e.type == sf::Event::Closed)
                {
                        window_->close();
                        this->~Engine();
                }
        }
        //Do something like:
        //map.Draw();
        //player.Update(e,elapsed_time);
        //enemy1.Update(elapsed_time);
        //enemy2.Update(elapsed_time);
        //using global instances maybe?
        window_->clear();
        //Engine related draws...
        window_->display();
}


void Engine::ChangeRenderWindow(sf::RenderWindow *window)
{
        window_ = window;
}

void Engine::ToggleVsync()
{
        vsync_status_ = !vsync_status_;
        window_->setVerticalSyncEnabled(vsync_status_);
}

bool Engine::GetVsyncStatus()
{
        return vsync_status_;
}
 

I'm quite sure the Update it's completely inefficient so... suggestions?

15
General / Re: How should the code be organized?
« on: December 23, 2014, 01:16:22 pm »
Now that I've seen a bit more code, yeah, a class would definitely be better.

These may sound like nitpicks, but the problems with structuring your code that way are:
1) You may try to use one of the filepaths or the texture from some other code, when it probably has no purpose outside these two files.
2) It's possible to try and use mouseover_sprite before LoadSprites() has been called.
3) A sprite isn't really a "resource", so I would typically let somebody else make the sprites and get textures from this file.  For a game where you expect to be adding and removing lots of sprites at runtime, you definitely want someone else handling the sprites, but maybe it's a non-issue for you.

To solve 1 and 2, I would recommend using a class here.  In your main(), you already need to have
Resources::LoadSprites();
so we might as well change that to:
Resources resources; // constructor handles loading all the textures

This class could then mark as private the things that should be private, and the use of a constructor ensures it's impossible to try using mouseover_sprite before the texture loading has been done.


P.S. Use code tags to make your post more readable.  When you write a post there's a little "Code" box in the top right.  Select C++ from it to get the C++ code tags I was just using.
Thank you for the help! I'll use a class then   :D
I guess i was blind I couldn't find the "Code" anywhere in the page so i used quote instead  :-[

Pages: [1] 2