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

Pages: [1]
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 / 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?

3
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.

4
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?

5
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?

6
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.

7
General / Setting up on notepad++
« on: June 17, 2013, 12:36:29 pm »
Hello there!
I thought to re-learn c++ and SFML and I wan  to use notepad++ as my editor, compile with MinGW using a custom .bat file. How should I set Up SFML so that It would run?

My current .bat file
gcc -o DreadDylum source/main.cpp
DreadDylum
PAUSE

 

8
Hi, I have a header file, which includes the graphics.hpp, in it I make a texture:

sf::Texture texture;
texture.loadFromFile("/data/textures/menu/New Game.pdn");

In another.h file, in which I include this .h file, I create a sprite:

sf::Sprite sprite(texture);



In my main.cpp, I include both of these headers and the graphics.hpp and I do:

window.draw(sprite);
If I now build and run the code, then It errors in the texture.loadFromFile line, saying:

Expected constructor, deconstructo or type conversion before . token

How to fix??

9
Graphics / Sprites into an array
« on: December 28, 2012, 12:59:07 pm »
Hello, how can I load a bunch of sprites into a array in a separate file (should it be .h or .cpp), so that I can later display them  (and set as a variable) in a different file by using the index??? 


Edit: could I make the sprites before making an array and then load either a pointer to those or those directly to an array???

10
General / simple way for multiple screens
« on: December 27, 2012, 12:08:52 pm »
Hello, I`m new here and I only started learning C++ and SFML about 2 months ago.

I`d like to know if there is a simple way to handle multiple screens in a game. Since Eng is not my native (I`m from Estonia) the http://www.sfml-dev.org/wiki/en/tutoriels/multiecransjeu_en was a bit tricky to undrestand( i do know english VERY GOOD, it just that the overall construction of the screen management reamined a bit fuzzy).

If you know any simple multiple screen managements or can describe how it works in general, I`d be very happy

Pages: [1]
anything