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

Pages: [1]
1
General / Re: SFML Font [Vector error] Vector erase iterator outside range
« on: November 24, 2015, 05:20:52 am »
Debug Mode

Frist of all, I have forgotten to say, that the first error disapeared (Vector erase iterator outside range). I didnt do much, just tried to change code to make it workable, came back to code from my first post and oops, now there is another Break Error... (Screen Attached)

In Debug Mode it is talking about sfml-window-d-2.dll...

    sfml-window-d-2.dll!0f361bc3()   Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for sfml-window-d-2.dll]   
    sfml-window-d-2.dll!0f361a26()   Unknown
    sfml-window-d-2.dll!0f3610aa()   Unknown
    sfml-window-d-2.dll!0f35feb8()   Unknown
>   tanks_v1.3.exe!main() Line 25   C++           //this is line 25:       while (window.pollEvent(event))
    [External Code]   

2
General / Re: SFML Font [Vector error] Vector erase iterator outside range
« on: November 24, 2015, 05:12:01 am »
Two other screens:

3
General / Re: SFML Font [Vector error] Vector erase iterator outside range
« on: November 24, 2015, 05:10:59 am »
Thanks Hapax for reply.

When I try to Release I'm getting an error that says - "Impossible to start program. Coz there is no sfml-system-d-2.dll" (I attached screen(unfortuanetely it is in russian..., but close translation is above))

when I close this error message, I'm getting this Break Message - "Unhandled exception at 0x775C9610 (ntdll.dll) in tanks_v1.3.exe: VTGuard instrumentation code detected an attempt to use an illegal virtual function table."

Well, ok... I understand that it might miss  this SFML lib file: "sfml-system-d-2.dll", it is located in Debug folder near .exe file. (Screen Attached)

"Call Stack" doesnt send me anywhere around my code, while it is in Realse Mode.

I also attached Linker -> Input Screen, just in case

Will post all results in Debug mode in a few minutes.

4
General / SFML Font [Vector error] Vector erase iterator outside range
« on: November 23, 2015, 01:53:08 pm »
Hi there,

I use SFML 2.2. MS Visual Studio Express 2013. I'm trying to create a menu for my game.

The problem is when I try to create a text in another class, I'm getting an error that says "Vector erase iterator outside range" and game doesnt want to start... If I use text in the main.cpp everything is fine...

menu.h
#pragma once

#include <SFML/Graphics.hpp>

#define MAX_NUMBER_OF_ITEMS 2

using namespace sf;

class menu
{
public:
    menu(float width, float height);
    ~menu();

    void draw(RenderWindow &window);
    void moveUp();
    void moveDown();

private:
    int selectedItemIndex;
    Font font;
    Text startMenu[MAX_NUMBER_OF_ITEMS];
};
 

menu.cpp
#include <iostream>
#include "menu.h"

menu::menu(float width, float height)
{
        if (!font.loadFromFile("res/consolab.ttf"))
        {
                std::cout << "cannot load font: consolab.ttf" << std::endl;
        }

        startMenu[0].setFont(font);
        startMenu[0].setColor(Color::Red);
        startMenu[0].setString("Play");
        startMenu[0].setPosition(Vector2f(width / 2, (MAX_NUMBER_OF_ITEMS + 1) * 1));

        startMenu[1].setFont(font);
        startMenu[1].setColor(Color::White);
        startMenu[1].setString("Exit");
        startMenu[1].setPosition(Vector2f(width / 2, (MAX_NUMBER_OF_ITEMS + 1) * 2));
}


menu::~menu()
{
}

void menu::draw(RenderWindow &window)
{
        for (int i = 0; i < MAX_NUMBER_OF_ITEMS; i++)
        {
                window.draw(startMenu[i]);
        }
}

main.cpp
#include <SFML/Graphics.hpp>

#include "tank.h"
#include "menu.h"

using namespace sf;

int main()
{
        RenderWindow window(VideoMode(800, 600), "Tanks v1.3");

        menu startingMenu(window.getSize().x, window.getSize().y);
       
        Tank player1;
        player1.addTankAttributes(650, 500, Color(255, 0, 0), "Player 1");
        Tank player2;
        player2.addTankAttributes(50, 500,  Color(0, 0, 255), "Player 2");

        while (window.isOpen())
        {

                Event event;
                while (window.pollEvent(event))
                {
                       

                        if (event.type == Event::Closed)
                                window.close();

                }

                if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) //move up
                {
                        player1.moveRight();
                }
                else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) //move down
                {
                        player1.moveLeft();
                }

                window.clear(Color(21,196,202));
                startingMenu.draw(window);
                player1.drawTank(window);
                player2.drawTank(window);
                window.display();
        }

        return 0;
}

One more class that I've got, I tryed to use text there as well, the same problem...

Tank.h
#ifndef TANK_H
#define TANK_H

#include <SFML/Graphics.hpp>
#include <iostream>


using namespace sf;

class Tank
{

public:
        void addTankAttributes(int x, int y, Color &color, String name);
        void drawTank(RenderWindow &window);
        void moveLeft();
        void moveRight();


        Tank();
        ~Tank();

private:
        const float rotation = 0.04;

        Texture tankTexture;
        Texture turretTexture;

        Sprite tankSprite;
        Sprite turretSprite;

        Font font;
        Text text;
};

Tank::Tank()
{
        if (!tankTexture.loadFromFile("res/tank.png"))
                std::cout << "no tank.png file" << std::endl;

        tankSprite.setTexture(tankTexture);

        if (!turretTexture.loadFromFile("res/turret.png"))
                std::cout << "no turret.png file" << std::endl;

        turretSprite.setTexture(turretTexture);
}

void Tank::addTankAttributes(int x, int y, Color &color, String name)
{
        tankSprite.setColor(color);
        tankSprite.setPosition(x, y);

        turretSprite.setColor(color);
        turretSprite.setPosition(x+15, y+2);
        turretSprite.setOrigin(0, 0);
}

void Tank::drawTank(RenderWindow &window)
{
        window.draw(turretSprite);
        window.draw(tankSprite);
}

void Tank::moveLeft()
{
        if (turretSprite.getRotation() > 152 || turretSprite.getRotation() < 17)
        {
                turretSprite.rotate(-rotation);
        }
}
void Tank::moveRight()
{
        if (turretSprite.getRotation() > 150 || turretSprite.getRotation() < 15)
        {
                turretSprite.rotate(rotation);
        }
}

Tank::~Tank()
{
}

#endif TANK_H

Pages: [1]