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 - The Illusionist Mirage

Pages: 1 [2]
16
General / .exe not running on other computers
« on: September 03, 2013, 05:23:11 am »
Hello

I made a game in sfml 2.0 using codeblocks and mingw 4.7.2. It runs fine in my computer but when I run it on other computers, it doesn't run. also, if I debug it on other computers, i get these:

#0 004565B6   sf::SoundBuffer::SoundBuffer(this=0x402b01) (C:\SFML-2.1\src\SFML\Audio\SoundBuffer.cpp:42)
#1 00402BBA   __static_initialization_and_destruction_0(__initialize_p=1, __priority=65535) (D:\CodeBlocks\SFML  2.0\Games\Pong_Final\main.cpp:41)
#2 00402C16   _GLOBAL__sub_I_WINDOW_CAPTION() (D:\CodeBlocks\SFML  2.0\Games\Pong_Final\main.cpp:219)
#3 0046225F   __do_global_ctors() (../mingw/gccmain.c:59)
#4 00401098   __mingw_CRTStartup() (../mingw/crt1.c:236)
#5 00401284   mainCRTStartup() (../mingw/crt1.c:264)


Also I get this message:

Program recieved SIGSEGV, segmentation fault.


Can anyone explain what's the problem?

Thanks

EDIT:

I just realized that if I recompile my code in another computer and then run .exe, it runs correctly. But without recompiling, it doesn't run.

17
Audio / Playing sound
« on: September 01, 2013, 11:57:23 am »
Hello

I have made a custom mouse icon and I am using it through the methods -
Render_window_name.setMouseCursorVisible(false)
and
MouseSprite.setPosition(sf::Vector2f(sf::Mouse::getPosition(Render_window_name)));

I have also added a sound that is played everytime the user clicks the left button. Everything is smooth except that while I click the left button and hold it the sound keeps on playing. I want that it must be played only once when the left button is pressed, no matter for how much time I hold it.

How do I set up a sound using SFML so that it plays only once when the mouse is clicked.

Thanks

18
General / [Solved]Loading tile maps
« on: August 28, 2013, 01:32:24 pm »
Hello

I downloaded a mario clone source from here : http://en.sfml-dev.org/forums/index.php?topic=12232.msg84944#msg84944

But I didn't understand the tile map loading part. Can anyone please explain it to me?

Thanks

19
General / Need help in creating a game state manager class
« on: August 21, 2013, 12:41:37 pm »
Hello

I am creating a pong clone. I have already made it using procedural programming but now I am working on it to make it object oriented. So, in my game code I have a GameStateManager class in which I have member functions which represent each state, like coresponding to the showing menu state, I have a member function called showMenu() which does all the needful upon being called in the main() function through the objects of my GameStateManager class. Things have been pretty well  but when I define a similar function for the state playing vs computer, an unexpected situation arises. Everytime I call the function that is responsible for displaying the players' paddles, the ball and the background, the function is called but the game gets stuck-the reason being everytime it is called it re-initializes everything to the default and even if I press the keys, nothing happens becuase again and again the function is called in the main(). I hope I am clear in explaining my problem

Thanks

20
General / Algorithm for moving the ball in pong game
« on: August 17, 2013, 03:24:03 pm »
Hello

I am working on a pong game and I need some clue on how to make the ball move automatically. Like, when the game starts, the ball is stationary and at the center of the screen and when the player hits space bar, it starts t move towards the player's paddle and after colliding, moves automatically according to the angle of collision.

Thank You

21
Graphics / [Solved]How to stop a color from displaying?
« on: August 16, 2013, 05:15:33 pm »
Hello

I have this png file:



Firstly i load it as a texture(using loadfromFile function) and then create a sprite and decide the part of the texture I want to display(using sf::IntRect).

.
.
.

sf::Texture PlayTexture;

if(!PlayTexture.loadfromFile("Play.png"))
  return EXIT_FAILURE;
sf::Sprite PlayNotSelected;
PlayNotSelected.setTexture(PlayTexture);
PlayNotSelected.setTextureRect(sf::IntRect(1, 1, 80, 30));
.
.
.
 

Now when I draw it in my SFML window, which was previously loaded with another sprite having a magenta background, something like this occurs:



My question is how do I remove the white from the png file display it as if it has no background color? And the way I displayed my window background and play.png, is ther any better way to do so?

Like here:


Details:
I browsed the internet to clarify this and came accross terms like color masking or so but didn't understand them quite well. If this preocess has a particular name, please tell me that also :)

Thanks

22
General / [Solved]Doubt in using getPosition()
« on: August 15, 2013, 05:48:08 pm »
Hello

Whenever we use getPosition() in a sf::RectangleShape object, what coordinates are returned?

For example, suppose we have the following rectangle, called sf::RectangleShape Rect1 and we call Rect1.getPosition(), what is returned?



Thanks

23
General / thor help
« on: August 15, 2013, 04:20:47 pm »
Hello

I was trying to port a C++ SFML 1.6 & Thor 1.1 project to SFML 2.1 & Thor 2.0. But while building I got an error that Thor/Geometry.hpp is missing, and when I checked the include directory of my Thor installation, I saw there is no Geometry.hpp. So, in the current version of Thor, which header contains the declarations and methods of Geometry.hpp?

Details:
I am using SFML 2.1 and Thor 2.0 in C::B 12.11.

Thanks

24
Graphics / Loading tile maps
« on: August 11, 2013, 06:08:17 pm »
Hello

Here's my code which I've been following from the CodingmadeEasy tutorials series on SFML 2.0:


#include<SFML/Graphics.hpp>
#include<fstream>
#include<iostream>
#include<cctype>
using namespace std;
 
int main()
{
    std::ifstream openfile("Map.txt");
 
    sf::Vector2i map[100][100];
    sf::Vector2i loadCounter(0, 0);
    sf::Vector2i mapSize;
    sf::Texture tileTexture;
    sf::Sprite tiles;
 
    if(openfile.is_open())
    {
        std::string tileLocation;
        openfile >> tileLocation;
        std::cout << tileLocation << std::endl;
        tileTexture.loadFromFile(tileLocation);
        tiles.setTexture(tileTexture);
        while(!openfile.eof())
        {
            std::string tile;
            openfile >> tile;
            char x = tile[0], y = tile[2];
            //std::cout << "x: " << x << "y: " << y << std::endl;
            if(!isdigit(x) || !isdigit(y))
                map[loadCounter.x][loadCounter.y] = sf::Vector2i(-1, -1);
            else
                map[loadCounter.x][loadCounter.y] = sf::Vector2i(x - '0', y - '0');
 
            std::cout << map[loadCounter.x][loadCounter.y].x << "," << map[loadCounter.x][loadCounter.y].y << " ";
             
            if(openfile.peek() == '\n')
            {
                loadCounter.x = 0;
                loadCounter.y++;
                std::cout << std::endl;
            }
            else
                loadCounter.x++;
        }
        mapSize = loadCounter;
        mapSize.y++;
    }
 
    sf::RenderWindow Window(sf::VideoMode(640, 480, 32), "Loading Tile Maps[Easy]");
 
    while(Window.isOpen())
    {
        sf::Event Event;
        while(Window.pollEvent(Event))
        {
            switch (Event.type)
            {
            case sf::Event::Closed:
                Window.close();
                break;
            }
        }
 
        Window.clear();
 
        for(int i = 0; i < mapSize.x; i++)
        {
            for(int j = 0; j < mapSize.y; j++)
            {
                if(map[i][j].x != -1 && map[i][j].y != -1)
                {
                    tiles.setPosition(i * 32, j * 32);
                    tiles.setTextureRect(sf::IntRect(map[i][j].x * 32, map[i][j].y * 32, 32, 32));
                    Window.draw(tiles);
                }
            }
        }
 
        Window.display();
    }
 
    return 0;
}
 

His output is:



But my output is this:



I've made sure that Map.txt is the project directory and so is Map.png.

Here are they:

Map.txt
---------------------------------------------------------------------------------------------------------------------------------------
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
x,x x,x x,x x,x 0,1 1,0 1,1 x,x x,x x,x
x,x x,x x,x x,x x,x x,x x,x x,x x,x x,x
0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0
---------------------------------------------------------------------------------------------------------------------------------------

Map.png



It would be helpful if I am told the error I am commiting.

Thanks

25
General / [Solved]Game window not working
« on: August 08, 2013, 05:51:46 pm »
Hello

I installed SFML 2.0 after a lot of struggle in Code::Blocks with the MinGW 4.7.2 compiler. When I compile the follwoing code, it compiles and runs flawlessly:

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

const int WINDOW_WIDTH = 800;
const int WINDOW_HEIGHT = 600;
const int WINDOW_BPP = 32;
const char *WINDOW_CAPTION = "MY_SFML";

int main()
{
    sf::RenderWindow Window;
    Window.create(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_BPP),
                  WINDOW_CAPTION, sf::Style::Close);

    while(Window.isOpen())
    {
        sf::Event Event;

        while(Window.pollEvent(Event))
        {
            switch(Event.type)
            {
                case sf::Event::Closed:
                    {
                        Window.close();
                    } break;
                case sf::Event::KeyPressed:
                    {
                        if(Event.key.code == sf::Keyboard::Escape)
                        {
                            Window.close();
                        }
                    } break;
            }
        }

        Window.display();
    }
}
 
But if i am trying to display a circle or rectangle(as in the following code), then the code doesn't compile:

#include <SFML/Graphics.hpp>

const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
const char *WINDOW_CAPTION = "MY_SFML";

const float CIRCLE_RADIUS = 100.0f;

int main()
{
        system("cls");

        sf::RenderWindow GameWindow(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT),
                WINDOW_CAPTION, sf::Style::Close);

        sf::CircleShape Circle(CIRCLE_RADIUS);
        Circle.setFillColor(sf::Color::Yellow);

        while(GameWindow.isOpen())
        {
                sf::Event GameEvent;

                if(GameWindow.pollEvent(GameEvent))
                {
                        if(GameEvent.type == sf::Event::Closed)
                        {
                                GameWindow.close();
                        }

                        GameWindow.clear();
                        GameWindow.draw(Circle);
                        GameWindow.display();
                }
        }

        return 0;
}

So where's the problem?

Thanks

Pages: 1 [2]