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

Pages: [1]
1
General / Re: Malloc Error
« on: December 16, 2018, 08:16:04 am »
Well of course, it's now working with a new download of SFML. Surprise surprise

2
General / Re: Malloc Error
« on: December 16, 2018, 07:29:28 am »
Didn't find a solution and walked away for a while. Just got back to it and still am having the same problem. It's clear that the error is coming from the sf::Font/sf::Text. Apparently this issue was relatively common in older versions of Xcode and was fixed with an update to SFML. I am using Xcode 10.1 so that can't be the problem. And I am quite certain the version of SFML I'm using is stable.

I made the Game's instances of sf::Text/sf::Font members of the class and now the error occurs after the return statement in main. So again, clearly that is the issue. Just don't know how to solve it

3
General / Re: Malloc Error
« on: October 21, 2018, 11:56:17 pm »
In main, a Game object is instanced

Game myGame;

The Game's constructor initializes all Game components and enters the main run loop

void Game::_init() {
        // Initialize Media
        _initializeMedia();

        // Initialize System
        _initializeSystem();   

        // Run the game
        _run();
}

void Game::_run() {
        sf::Clock frameClock;

    while (_window.isOpen()) {
                // Update animation timing
                sf::Time frameTime = frameClock.restart();

                _updateWindow();
                _updateView();
       
                if (_state == PLAY)
                        _updatePlayers(frameTime);
       
        _draw();
    }
}

There is a method within the main loop that runs the pause logic which prints the pause menu and other things (as shown in the code in my previous post). This is the method that is causing my issues

4
General / Re: Malloc Error
« on: October 06, 2018, 02:22:00 am »
No to all. The sf::Font is a member of the class. The sf::Text is a local variable in the class method. Here is a simple version of the method that is causing the error:

void Game::_pauseGame() {
        sf::Text pause, resume, options;

        // Each of these cause the error
        pause.setFont(_font);
        resume.setFont(_font);
        options.setFont(_font);
       
        // Set string of the text variables
        ....

        // Set the size and positioning of the text variables
        ....

        // Trying to draw each of the text variables causes the error as well
        _window.draw(pause);
        _window.draw(resume);
        _window.draw(options);
        _window.draw(_pauseSword);
}

I also get the error when exiting the application, but I think that has something to do with the destruction of either the sf::Text or sf::Font variables.

Also, I didn't mention in my first post, but I'm using Xcode. It works fine in VS

5
General / Re: Malloc Error
« on: October 05, 2018, 02:27:18 am »
I found the source of the error, it happens when I try to draw some text to the screen. Don't know why this causes the error, but I'll keep digging

6
General / Malloc Error
« on: October 05, 2018, 02:03:42 am »
I'm having a weird problem with my program that I don't understand at all. Whenever I close the program I get this message in the output:

malloc: *** error for object 0x100c7ef68: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

I put in the breakpoint, but don't know how to read it really. When I run the program and it gets to that breakpoint, there doesn't seem to be anything wrong. But when I continue I get to a line in the "new" system file at the
__builtin_operator_delete(__ptr);
line. It says
Thread 1: signal SIGABRT
. I don't know how to begin to analyze this, has anyone every had this same issue?

7
General / Re: Travis build file?
« on: August 16, 2018, 07:33:47 am »
Gotcha, I was under the impression it was supposed to work.

Thanks for everyone's help

8
General / Re: Travis build file?
« on: August 16, 2018, 02:08:38 am »
Well I finally got it working. The question I have goes back to the original post about the SFML 2.5 migration. eXpl0it3r linked the libraries like this:

target_link_libraries(SFMLTest sfml-graphics sfml-audio)

whereas it was suggested to do this:

target_link_libraries(SFMLTest SFML::graphics SFML::audio)

When I tried the latter, it gave me a cmake linking error. Whereas when I did the former, it worked as it was supposed to. Why is that? I thought the two syntax choices were interchangeable?

9
General / Re: Travis build file?
« on: August 15, 2018, 09:51:13 pm »
Ok makes sense, thanks. I'll keep working at it

10
General / Re: Travis build file?
« on: August 15, 2018, 08:14:40 pm »
This all may be too advanced for me..

I took a look at both of your files. The script doesn't complete because it can't find a SFML_LINUX dir. I don't even know what that's supposed to be. Is that a directory cmake creates when building SFML (in your configuration)? I'm not really sure how to debug this because I don't know what the files are.

Where is the SFML directory? Is that where it's supposedly installed? This is the part that I'm really confused about.

It might also help to show what error you are getting on travis, maybe someone else already encountered them (I've had plenty of cases where it build locally but failed on travis in the past, usually by stupid mistakes).

This is what I'm getting:

...
By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SFML", but
  CMake did not find one.
...

My understanding is that SFML 2.5+ doesn't use an FindSFML.cmake file so I shouldn't be getting this error if I'm doing it right, which clearly I'm not

11
General / Re: Travis build file?
« on: August 15, 2018, 04:25:37 am »
That's the yaml file that I basically used, except for the deployment stuff. Can you explain where to set the SFML_DIR? That was the part that I tried to set but wasn't exactly sure what the sfml root prefix was. Is that part of the cmake cache files after building SFML? That's probably what I'm doing wrong.

Why would it work on my local machine and not travis though?

12
General / Travis build file?
« on: August 14, 2018, 10:21:22 am »
Can somebody post an example .travis.yml file? I just got introduced to it and I'm trying to get it to work. I've gotten through 13 failed builds without getting much of anywhere. I'm not really sure why because I'm running the same steps on my local Ubuntu distro which is actually giving me results. I barely have a working knowledge of cmake/travis-ci so this has been a bit of a challenge.

It might be worth noting that I can't find any info on this on here or anywhere on Google. Which means to me that either I'm doing something terribly wrong or I'm just not that bright

13
General / Re: Game States
« on: August 13, 2018, 09:38:15 pm »
@ex
Edit2: I've created a new repository on GitHub, so it would be easier to share the code and make adjustments to it: SmallGameEngine

Random question on your GitHub repo, perhaps this deserves a new post: do you not store your xcode project (or whatever you use) on the repo? I can see why you wouldn't, but I'm curious what you usually do for your projects

14
General / How to resize background
« on: August 09, 2018, 10:27:01 am »
I'm trying to figure out how to resize the contents of a window accurately when the window is resized. My goal is to have the view zoomed in depending on how much bigger the window is. I also do not want stretching. The background (for now) is a simple side-scrolling map with a fixed height of 798 pixels. I've programmed it so that there is always a margin above and below the graphic. I've figured it out for the most part, but the part that I'm not sure how to deal with is the zoom. I move the view based on if the "player" is moving towards the left side of the screen and is a certain distance from the center of the view. That gets all messed up after I zoom in. How to I accurately determine the change in distance from before/after I zoom the view?

I know I probably am not making much sense. Views have been a confusing topic for me but I am determined to understand them and implement them correctly and efficiently. I've been following this tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Using-View) but some of it has been confusing to me. Also, for reference, here is my updateView code:

void Game::_updateViewPos() {
    sf::Vector2f size = static_cast<sf::Vector2f>(_window.getSize());
   
    // Minimum size
    if(size.x < 1080)
        size.x = 1080;
    if(size.y < 958)
        size.y = 958;
   
    // Apply possible size changes
    _window.setSize(static_cast<sf::Vector2u>(size));
    _view = sf::View(sf::FloatRect(0.f, 0.f, size.x, size.y));
   
    // Move view down to have the bg centered vertically
    _view.move(0.f, -(float)((_window.getSize().y - _background.getTextureRect().height) / 2));
   
    // Zoom in to account for window size
    float zoomAmount = (float)HEIGHT / (float)_window.getSize().y;
    _view.zoom(zoomAmount);
   
    // Center up on player pos
    _view.setCenter(_player.getPosition().x, _view.getCenter().y);
   
    // Adjust so the view doesn't spill over if the player is on the far right or left side
    if (_view.getCenter().x < _window.getSize().x / 2) {
        _view.setCenter(_window.getSize().x / 2, _view.getCenter().y);
                _view.setCenter(_window.getSize().x / 2, _view.getCenter().y);
    }
        if (_view.getCenter().x > (_background.getTextureRect().width) - (_window.getSize().x / 2)) {
                _view.setCenter((_background.getTextureRect().width) - (_window.getSize().x / 2), _view.getCenter().y);
        }
   
    // Update the text positions
    _updateTextPos();
}

Pages: [1]