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

Pages: [1] 2
1
https://bitbucket.org/makerimages/chtt3r

I draw in TextBox.cpp, it causes an access violation, the call stack looks like this
        sfml-graphics-d-2.dll!5492a253()        Unknown
        [Frames below may be incorrect and/or missing, no symbols loaded for sfml-graphics-d-2.dll]    
        sfml-graphics-d-2.dll!54932951()        Unknown
>       Chtt3r.exe!TextBox::TextBox(float x, float y, float w, float h, ChatObject * cO) Line 16        C++
        Chtt3r.exe!NotSignedInStage::NotSignedInStage(sf::RenderWindow * rW) Line 23    C++
        Chtt3r.exe!main() Line 16       C++
        Chtt3r.exe!__tmainCRTStartup() Line 536 C
        Chtt3r.exe!mainCRTStartup() Line 377    C
        kernel32.dll!75821174() Unknown
        ntdll.dll!778fb3f5()    Unknown
        ntdll.dll!778fb3c8()    Unknown

 
After I get the violation, VS leads me to    this line:
 spriteCursor=*chat->getSpriteManager()->getSprite(0);

What may the cause be and how to fix?

2
Graphics / Re: Positioning button sides equally
« on: December 13, 2013, 10:19:12 pm »
heres a schematic Im tring to do:

E TTTTTTTT E
E TTT E

T- text
E-button side sprite

as you can see, the buttons are not witht he same size,so what I asked for was how to make them the same size, no matter what txt is in them?

3
Graphics / Positioning button sides equally
« on: December 13, 2013, 02:28:44 pm »
Hey, I have this that makes my buttons:
contentT=sf::Text(content,*game->getGuiFont());
        contentT.setColor(sf::Color::Black);
        contentT.setCharacterSize(18);
        contentT.setPosition(xPos-content.length()/(2*contentT.getCharacterSize()), yPos-2);
        sprLeft=*game->getSpriteManager()->getSprite(3);
        sprLeft.setPosition(xPos-57,yPos);
       
        //sprLeft.setPosition(xPos-(content.length()/2)*(contentT.getCharacterSize()/(content.length()/2)),yPos);
        sprRight=*game->getSpriteManager()->getSprite(4);
        //sprRight.setPosition(xPos+(content.length()*content.length()*1.9),yPos);
        sprRight.setPosition(xPos+177,yPos);
 

what the matter here is, is that the sprLeft and sprRight are not aligned to equal positions on x when buttons are different in text lenght.

So for example

button with content "New Game" would be different sized than a button with content "Options", how could I make the buttons be equally sized/aligned no matter what the content lenght is?

4
General / sfml event handling for my buttons
« on: December 11, 2013, 08:46:14 pm »
Hey, I got a button class like this:
#include "Button.h"


Button::Button(std::string content,int x, int y,GameObject* gameO,GameWindow* wI): xPos(x), yPos(y),game(gameO), windowIn(wI)
{
        sprLeft=game->getSpriteManager()->getSprite(3);
        sprLeft->setPosition(xPos-content.length()/2,yPos);
        sprRight=game->getSpriteManager()->getSprite(4);
        sprRight->setPosition(xPos+(content.length()*content.length()*1.9),yPos);

        contentT=sf::Text(content,*game->getGuiFont());
        contentT.setColor(sf::Color::Black);
        contentT.setCharacterSize(18);
        contentT.setPosition(xPos-content.length()/2, yPos-2);
}


Button::~Button(void)
{
}
void Button::draw()
{
                windowIn->getWindow()->draw(*sprLeft);

        windowIn->getWindow()->draw(contentT);
                        windowIn->getWindow()->draw(*sprRight);

}
Button::Button(void)
{}
 

and it is made and drawin in a class like this:
#include "MainMenuWindow.h"


MainMenuWindow::MainMenuWindow(GameObject* gameO, sf::RenderWindow *rW)
{
        game=gameO;
        window=rW;
        newGameButton=Button("New Game",window->getSize().x/2-50,window->getSize().y/2-60,game,this);
}



MainMenuWindow::~MainMenuWindow(void)
{
}
void MainMenuWindow::draw(void)
{

        newGameButton.draw();
}

 

what I would like to do, is get mouse click coords in my Main.cpp event loop(standard one) and do something if newGameButton was clicked, how could I do so? Bare in mind that the  Button class is meant to create multiple buttons, all with different actions.

5
Graphics / [2.1] sf::Text wrap at a specific X co-ord
« on: December 11, 2013, 03:03:08 pm »
hey, lets say I have a text like this:
contentT=sf::Text(content,*game->getGuiFont());
        contentT.setColor(sf::Color::Black);
        contentT.setCharacterSize(16);
        contentT.setPosition(xPos-170, yPos-70);
 

and it has a long piece of text(like ddddddddddddddddiwwwwwwwwwwwwwwwwwwwwwwwwwwwaaaaa) in it, the xPos and yPos are relative to the current object these are in, the whole container width is 349px

How could I now make the contentT, when drawed- do a line wrap at lets say xPos+170 ? and go to the next line at xPos-170 again?

6
SFML wiki / Re: Animated Sprite class
« on: December 01, 2013, 12:37:23 pm »
using this for some experimenting, seems simple and easy enough to grab a hold of in a few minutes. What would be nice though, is to be able to set the frame to one fixed frame and then be able to for example only animate frames 2-6 and return pack to frame 1 when done, or something like that.

7
Graphics / Re: Having the infamous white square problem
« on: November 15, 2013, 02:39:24 pm »
Got it working aftrall, simplert thanthat, no need for shared_ptrs

8
Graphics / Re: Having the infamous white square problem
« on: November 15, 2013, 01:58:43 pm »
Code update! Tried this for the shared_ptr, still getting a white square

TextureManager.h
#pragma once
#include <SFML\Graphics.hpp>
#include <memory>
class TextureManager
{
public:

        TextureManager(void);
        ~TextureManager(void);
        std::shared_ptr<sf::Texture> getTexture(int id);
                        void InitTextures();


private:
        sf::Texture textureArray[20];
};


 

TextureManager.cpp
#include "TextureManager.h"

using namespace std;

TextureManager::TextureManager(void)
{
       
}


TextureManager::~TextureManager(void)
{
}

void TextureManager::InitTextures()
{
        printf("Starting texture loading process \n");
        textureArray[0].loadFromFile("data/graphics/map/grassTile.jpg"); // 0
        textureArray[1].loadFromFile("data/graphics/map/mountainTile.png");
        printf("Texture Loading ended! \n");
}
std::shared_ptr<sf::Texture> TextureManager::getTexture(int id)
{
        return std::make_shared<sf::Texture>(textureArray[id]);
        //return textureArray[id];
}
 

SpriteManager.h
#pragma once
#include <SFML\Graphics.hpp>
#include "TextureManager.h"
class SpriteManager
{
public:
                TextureManager texManager;
                std::shared_ptr<sf::Sprite> getSprite(int id);
        SpriteManager(TextureManager tm);
        ~SpriteManager(void);
private:
        sf::Sprite spriteArray[20];
        void initSprites();

};


 

SpriteManager.cpp
#include "SpriteManager.h"

using namespace std;
SpriteManager::SpriteManager(TextureManager tm):texManager(tm)
{
        texManager.InitTextures();
        initSprites();
}


SpriteManager::~SpriteManager(void)
{

}
void SpriteManager::initSprites()
{
        printf("Started loading sprites! \n");
        spriteArray[0].setTexture(*texManager.getTexture(0)); //0
        spriteArray[1].setTexture(*texManager.getTexture(1));
        printf("Sprite loading complete! \n");
}
std::shared_ptr <sf::Sprite> SpriteManager::getSprite(int id)
{

        return std::make_shared<sf::Sprite>(spriteArray[id]);
}
 

main.cpp
#include <SFML\Graphics.hpp>
#include <conio.h>
#include "SpriteManager.h"

int main()
{
        printf("Starting game \n");

        TextureManager texManager;
        SpriteManager spriteManager(texManager);
        sf::RenderWindow window(sf::VideoMode(800,600),"NeverLand");
       
       
               
        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type==sf::Event::Closed)
                        {
                                window.close();
                        }
                }
               
       
               
                window.clear();
                window.draw(*spriteManager.getSprite(0));
                window.display();
        }
        return 0;
}
 

9
Graphics / Re: Having the infamous white square problem
« on: November 15, 2013, 01:35:00 pm »
did so, found nothing I could easiliy implement...

EDIT: can I easliy convert a shared_ptr back tot he object it reffers to for sprite.setTexture() ???

10
Graphics / Re: Having the infamous white square problem
« on: November 15, 2013, 01:12:24 pm »
Then you could use a shared_ptr

how?

11
I`m 99% sure you cant pass in a hard directory for the file path. move the test.png to your active workspace for Debug and remove the C:\ in the path

12
Graphics / Re: Having the infamous white square problem
« on: November 15, 2013, 12:53:06 pm »
But I cant seTexture when I have the getTexture return a pointer for an example.

13
Graphics / Having the infamous white square problem
« on: November 15, 2013, 07:37:27 am »
HAving the white square problem, but can figure out where the issue exactly is.

TextureManager.h
#pragma once
#include <SFML\Graphics.hpp>
class TextureManager
{
public:

        TextureManager(void);
        ~TextureManager(void);
                sf::Texture getTexture(int id);
                        void InitTextures();


private:
        sf::Texture textureArray[20];
};


 

TextureManager.cpp
#include "TextureManager.h"

using namespace std;

TextureManager::TextureManager(void)
{
       
}


TextureManager::~TextureManager(void)
{
}

void TextureManager::InitTextures()
{
        printf("Starting texture loading process \n");
        textureArray[0].loadFromFile("data/graphics/map/grassTile.jpg"); // 0
        textureArray[1].loadFromFile("data/graphics/map/mountainTile.png");
        printf("Texture Loading ended! \n");
}
sf::Texture TextureManager::getTexture(int id)
{
        return textureArray[id];
}
 

SpriteManager.h

#pragma once
#include <SFML\Graphics.hpp>
#include "TextureManager.h"
class SpriteManager
{
public:
                TextureManager texManager;
        sf::Sprite getSprite(int id);
        SpriteManager(TextureManager tm);
        ~SpriteManager(void);
private:
        sf::Sprite spriteArray[20];
        void initSprites();

};


 

SpriteManager.cpp

#include "SpriteManager.h"

using namespace std;
SpriteManager::SpriteManager(TextureManager tm):texManager(tm)
{
        texManager.InitTextures();
        initSprites();
}


SpriteManager::~SpriteManager(void)
{

}
void SpriteManager::initSprites()
{
        printf("Started loading sprites! \n");
        spriteArray[0].setTexture(texManager.getTexture(0)); //0

        spriteArray[1].setTexture(texManager.getTexture(1));
        printf("Sprite loading complete! \n");
}
sf::Sprite SpriteManager::getSprite(int id)
{
         
        return spriteArray[id];
}
 

main.cpp
#include <SFML\Graphics.hpp>
#include <conio.h>
#include "SpriteManager.h"

int main()
{
        printf("Starting game \n");

        TextureManager texManager;
        SpriteManager spriteManager(texManager);
        sf::RenderWindow window(sf::VideoMode(800,600),"NeverLand");
       
       
               
        while(window.isOpen())
        {
                sf::Event event;
                while(window.pollEvent(event))
                {
                        if(event.type==sf::Event::Closed)
                        {
                                window.close();
                        }
                }
               
       
               
                window.clear();
                window.draw(spriteManager.getSprite(0));
                window.display();
        }
        return 0;
}
 

Can anyone figure out where exactly do I lose the texture and what to do to avoid it?

14
General / VS2013 support
« on: November 09, 2013, 09:47:20 am »
Will VBE2013 be supported anytime soon? I want to get back to learning c++ and sfml.

15
General / Re: Setting up on notepad++
« on: June 17, 2013, 01:50:57 pm »
That goes at the end of the first line in the .bat file ,right?

Pages: [1] 2