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

Pages: [1] 2
1
Graphics / SFML Button
« on: November 13, 2013, 07:54:40 am »
Hi, I made a small Button set since SFML doesnt have a button class directly inputted into it, so I tried to make my own, and I got this, you can add/change/modify it to your liking

//Get the position of the Mouse
int MouseX = sf::Mouse::getPosition().x;
int MouseY = sf::Mouse::getPosition().y;

//Create a Shape for the button
sf::RectangleShape button; //Doesnt have to be a rectangle

//Give the Button a color
button.setFillColor(sf::Color::Blue);

//Set size of the button
button.setSize(sf::Vector2f(100,48)); //Make it what ever you like

//Set the position of the button
button.setPosition(200,200);//or where ever you like

//The Fun Stuff!!
if(button.getGlobalBounds().width <=> MouseX
&& button.getGlobalBounds().height <=> MouseY){
//Do What you want to do with the button
button.setFillColor(sf::Color::Green);
}

 

Now this may not be the most efficient way to do this, but it worked for me when I tried it.

2
Graphics / Re: Handleing First Chance Error when loading images
« on: November 02, 2013, 08:18:19 am »
I know how to use them a bit. But I have put it there because I get the following error once I debug without the pointer.

d:\game\lengine.cpp(55): error C2664: 'sf::Shape::setTexture' : cannot convert parameter 1 from 'sf::Texture' to 'const sf::Texture *'
          No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called

3
Graphics / Handleing First Chance Error when loading images
« on: November 02, 2013, 08:11:42 am »
Hi, whenever I run my application, and I want to set rect image to the grass. It keeps on giving me a first chance exception. Here is the 2 stacktraces

First-chance exception at 0x1004ab8d in Game.exe: 0xC0000005: Access violation writing location 0x00000000.
Unhandled exception at 0x1004ab8d in Game.exe: 0xC0000005: Access violation writing location 0x00000000.

I'm a little confused, could anybody tell me what is going on? I have added the code that is drawing and setting the rect on the screen below.

sf::RectangleShape rect;

sf::Texture* grass;
grass->loadFromFile("grass.png");

rect.setSize(sf::Vector2f(16,16));
rect.setTexture(grass);
rect.setPosition(x * 16, y * 16);
window.draw(rect);

window.setView(map_view);
window.display();

4
General / Re: Entry point must be defined
« on: October 12, 2013, 12:41:37 am »
I am getting

First-chance exception at 0x78aa1f34 in Game.exe: 0xC0000005: Access violation reading location 0x00133000.
Unhandled exception at 0x78aa1f34 in Game.exe: 0xC0000005: Access violation reading location 0x00133000.

With this code

#include "LEngine.h"
#include <SFML\Graphics.hpp>

void LEngine::Sprites(){
        sf::Texture t_grass;
        sf::Texture t_stone;
        sf::Texture t_water;

        t_grass.loadFromFile("grass.png");
        t_stone.loadFromFile("stone.png");
        t_water.loadFromFile("water.png");

        sf::Sprite grass;
        sf::Sprite stone;
        sf::Sprite water;

        grass.setTexture(t_grass);
        stone.setTexture(t_stone);
        water.setTexture(t_water);
}

void LEngine::Map(){
        int m_draw[50][50];

        for(int x = 0; x < 50; x++){
                for(int y = 0; y < 50; y++){
                        m_draw[x][y] = 50;
                }
        }

        sf::RectangleShape rect;
        rect.setSize(sf::Vector2f(16,16));

        for(int x = 0; x < 50; x++){
                for(int y = 0; y < 50; y++){
                        switch (m_draw[x][y]){
                        case 0:
                                rect.setFillColor(sf::Color::Green);
                                rect.setPosition(5 * 16, 5 * 16);
                                window->draw(rect);
                                break;
                        }
                }
        }
}

bool LEngine::Init(){
        window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

        if(!window)
                return false;

        return true;
}

void LEngine::Events(){
        sf::Event evt;
        //Loop through all window events
        while(window->pollEvent(evt)){
                if(evt.type == sf::Event::Closed)
                        window->close();
        }
}

void LEngine::MainLoop(){
        while(window->isOpen()){
                Sprites();
                Map();
        }
}

void LEngine::boot(){
        if(!Init())
                throw "Could not initialize Engine";

        MainLoop();
}

5
General / Re: Entry point must be defined
« on: October 11, 2013, 03:39:47 pm »
Anybody?

6
General / Re: Entry point must be defined
« on: October 11, 2013, 02:54:37 pm »
Still doesn't help with the error on why it crashes

7
General / Re: Entry point must be defined
« on: October 11, 2013, 02:48:22 pm »
I have sf::RenderWindow* window; in the header file.
That's what I mean: Just use
sf::RenderWindow window;

Or do you want to reduce compile-time dependencies (Pimpl idiom)?

What do you mean by "reduce compile-time dependencies"?

8
General / Re: Entry point must be defined
« on: October 11, 2013, 02:45:52 pm »
I have sf::RenderWindow* window; in the header file.

It also stops the startup at : 'Game.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', Cannot find or open the PDB file

9
General / Re: Entry point must be defined
« on: October 11, 2013, 02:40:09 pm »
Also what does

First-chance exception at 0x103159da (msvcr100d.dll) in Game.exe: 0xC0000005: Access violation reading location 0xccccccc0.
Unhandled exception at 0x103159da (msvcr100d.dll) in Game.exe: 0xC0000005: Access violation reading location 0xccccccc0.
 

mean? Using the same code as before

10
General / Re: Entry point must be defined
« on: October 11, 2013, 02:38:01 pm »
Where is you int main() { }?

Opps, I forgot to make that xD

11
General / Re: Entry point must be defined
« on: October 11, 2013, 02:26:48 pm »
I've tried google, I've try almost everything, but I cannot get it work.

12
General / Entry point must be defined
« on: October 11, 2013, 02:25:20 pm »
Hi, I'm having troubles setting up:

I get  LINK : fatal error LNK1561: entry point must be defined with this code

#include "LEngine.h"
#include <SFML\Graphics.hpp>

void LEngine::Sprites(){
        sf::Texture t_grass;
        sf::Texture t_stone;
        sf::Texture t_water;

        t_grass.loadFromFile("grass.png");
        t_stone.loadFromFile("stone.png");
        t_water.loadFromFile("water.png");

        sf::Sprite grass;
        sf::Sprite stone;
        sf::Sprite water;

        grass.setTexture(t_grass);
        stone.setTexture(t_stone);
        water.setTexture(t_water);
}

void LEngine::Map(){
}

bool LEngine::Init(){
        window = new sf::RenderWindow(sf::VideoMode(800, 600, 32), "RPG");

        if(!window)
                return false;

        return true;
}

void LEngine::Events(){
        sf::Event evt;
        //Loop through all window events
        while(window->pollEvent(evt)){
                if(evt.type == sf::Event::Closed)
                        window->close();
        }
}

void LEngine::MainLoop(){
        while(window->isOpen()){
                Sprites();
                Map();
        }
}

void LEngine::boot(){
        if(!Init())
                throw "Could not initialize Engine";

        MainLoop();
}

13
General / Converting a sf::Image to a sf::Texture
« on: October 01, 2013, 12:36:53 pm »
Hi, I need to convert a image to a texture for my application, but I cannot find anywhere that tells you how to do so.

Could anybody link me to a post or a post some code or a way they would do it ?

Cheers TheDianamu

14
Graphics / setImage not a member of sf::Sprite
« on: September 29, 2013, 04:10:54 am »
I'm having troubles with my tile class for my engine. I'm using the SFML 2.1 and coding visual c++ 2010

I get the following on compile:
'setImage' : is not a member of 'sf::Sprite'

Tile.cpp:
#include "Tile.h"
#include <SFML\Graphics.hpp>

Tile::Tile(sf::Image& image)
{
        baseSprite.setImage(image, true);
}

Tile::~Tile()
{

}

void Tile::Draw(int x, int y, sf::RenderWindow* rw)
{
        baseSprite.setPosition(x, y);
        rw->draw(baseSprite);
}

Tile.h:

#ifndef _TILE_H
#define _TILE_H

#include <SFML\Graphics.hpp>

class Tile
{
private:
        sf::Sprite baseSprite;

public:
        Tile(sf::Image& image);
        ~Tile();

        void Draw(int x, int y, sf::RenderWindow* rw);
};

#endif

15
Graphics / How to fill the window with a texture/sprite
« on: September 20, 2013, 03:42:42 pm »
I'm trying to figure out a quick and simple way of filling the entire window or to a size say like

width of 200 sprites
height of 200 sprites

How would I go about setting the texture/sprite to fill that size? I have tried to use setRepeated, but that wasn't working.

Thanks in Advance

Pages: [1] 2
anything