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
1
Hello Programmers!

I just wrote a simple clone of the famous Conway's Game of Life as a programming practice. You can find the source here. To compile the code for the SFML version, add the preprocessor RENDERER_SFML. Or else the program will compile the terminal version.

Below are a few screenshots:







I'd be grateful if you provide some critics/comments on the code.
Thanks!

2
SFML projects / BEAT$ATION MU$IX Mp3 Player - A SFML based Mp3 player
« on: November 21, 2013, 07:00:14 pm »
Hello!

I've been developing a Mp3 player for the last couple of days. Here's what I've come up with : BEATSATION MUSIX Mp3 Player

The project is still very primitive and has many bugs to be fixed but I'll be working on it ;). Also, a seek bar, volume bar, song time, album info options are not yet present.

The instructions to use can be found either in README.md or INSTRUCTIONS.txt.

Screenshots:








A quick video:




Please run it and tell me what you think about it.

Thanks
The Illusionist Mirage

P.S. SFML doesn't support the mp3 format. So, I used irrKlang for playing mp3 files.

EDIT:
Added video link

3
General / Playback of Mp3 files using SFML
« on: November 17, 2013, 05:08:38 am »
Hello

I just came accross this source for a Mp3 player using SFML here:
https://github.com/SFML/SFML/wiki/Source%3A-MP3-Player

This source uses mpg123 and I just wanted to know if mpg123 is installed in the same way as SFML?

Thanks

4
General / [SOLVED]Displaying Music info
« on: November 16, 2013, 02:34:39 pm »
Hello

Suppose I want to create a simple audio player using SFML, is it possible to display audio info like artist, album, year, etc. as with Windows Media player or others?

Thanks

EDIT:
Are Mp3 files also supported in SFML? And can you please tell all the formats supported?

5
General / [SOLVED]Sprite not moving
« on: October 17, 2013, 08:21:00 pm »
Hello

I have a player class which contains a member function called Update() to get the key the user is pressing(if any) and then move the sprite accordingly using the move(offsetX, offsetY) function. But that's not working in my case. Here's how I move my sprite:

void Player::Update(float DELTA_TIME)
{
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
        {
                m_playerSource.y = PlayerDirection::UP;
                m_isKeyPressed = true;
                m_currentKeyState = KeyState::UP_PRESSED;
                m_playerSprite.move(0, - m_PlayerSpeed.y * DELTA_TIME);
                std::cout << "Up" << std::endl;
        }

        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
        {
                m_playerSource.y = PlayerDirection::DOWN;
                m_isKeyPressed = true;
                m_currentKeyState = KeyState::DOWN_PRESSED;
                m_playerSprite.move(0, m_PlayerSpeed.y * DELTA_TIME);
                std::cout << "Down" << std::endl;
        }

        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
                m_playerSource.y = PlayerDirection::LEFT;
                m_isKeyPressed = true;
                m_currentKeyState = KeyState::LEFT_PRESSED;
                m_playerSprite.move(- m_PlayerSpeed.x * DELTA_TIME, 0);
                std::cout << "Left" << std::endl;
        }

        else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
                m_playerSource.y = PlayerDirection::RIGHT;
                m_isKeyPressed = true;
                m_currentKeyState = KeyState::RIGHT_PRESSED;
                m_playerSprite.move(m_PlayerSpeed.x * DELTA_TIME, 0);
                std::cout << "Right" << std::endl;
        }

        else
        {
                m_isKeyPressed = false;
                m_currentKeyState = KeyState::NONE_PRESSED;
        }

        m_frameCounter += m_frameSpeed * m_frameTimer.restart().asSeconds();

        if(m_frameCounter >= m_switchFrame)
        {
                m_frameCounter = 0.0f;

                if(m_isKeyPressed)
                {
                        m_playerSource.x++;
                }

                if(m_playerSource.x * 32 >= m_playerTexture.getSize().x)
                {
                        m_playerSource.x = 0;
                }
        }

        m_playerSprite.setTextureRect(sf::IntRect(m_playerSource.x * 32, m_playerSource.y * 32, 32, 32));
}
 

Even the cout statement gets printed if I press a key but the sprite's not moving. This function is called directly in the main game loop as follows:
while(myWindow.isOpen())
{
    t_f = m_timer.getElapsedTime().asSeconds();
    dt = t_f - t_i;
    t_i = t_f;

    sf::Event m_gameEvent;
    while(myWindow.pollEvent(m_gameEvent))
    {
         if(m_gameEvent.type == sf::Event::Closed
                || m_gameEvent.key.code == sf::Keyboard::Escape)
        {
                m_gameWindow.close();
        }
    }

    m_player.Update(dt);      
}
 

Where am I going wrong?

Thanks

6
General / [Solved]Loading from this tileset
« on: October 10, 2013, 05:17:20 pm »
Hello

I was following this tutorial on the SFML site and learnt how to load a tilemap fomr a tileset. But I have one problem - how to access tile from the tileset whose y-coordinate is not zero, ie, 1, 2, etc.

Example, if this is the tileset:


and I want to load the tiles of mario, how do I I do that?

Thanks

P.S.
I followed the tutorial and could understand how the tile class works. But is this tile class universally applicable for animated tiles and all?

7
General / Doubt in Thor Library - Animator class
« on: October 01, 2013, 09:13:45 pm »
Hello

The following statement produces an error:
thor::Animator animator;

Error:
D:\CodeBlocks\SFML 2.1\DP\svn\trunk\Entity.h|53|error: invalid use of template-name 'thor::Animator' without an argument list|

What's wrong?

I'm using Thor 2.0 with SFML 2.1.

Thanks

8
General discussions / Anyone interested in collaboration
« on: September 29, 2013, 07:14:29 pm »
Hello

I am an intermediate C++ user(still have to learn pointers, stacks, queues, some parts of arrays and the STL) but I am interested in making a game as a project in school. So I was wondering If anyone wants to collaborate with me and if we make a game, we'll share it equally(credits, code work, etc). I've already made a Pong clone before and I am NOT a very bad programmer.

So, if anyone wants to develop a project for their school or anywhere, please P.M. me or e-mail me(lostsoulofthegeek[at-the-rate]gmail[dot]com)and we'll discuss it further.

CHEERS! :D  8)


9
General discussions / [Solved]Suggestions regarding using SFML
« on: September 23, 2013, 04:38:34 pm »
Hello

What I basically see on the internet is that a wide range of games have been developed using SFML. But SFML is a multimedia layer rather than a game engine. So, I was toying with the idea of making a simple calculator using SFML just to hone my skills. What do you think-should I proceed with that sort of stuff or just practice basic games?

Thanks

10
General / [Solved]Good gameplay recorder
« on: September 21, 2013, 06:12:25 pm »
Hello

I was trying to record a gameplay using Camtasia when I discovered that the game is not recording correctly(it is slow). So, which software is the best for recording games, especially the ones using SFML .

Thanks

11
General / Can't figure out how to enable click and move
« on: September 18, 2013, 12:05:47 pm »
Hello

I am trying to move a sf::RectangleShape only when the user clicks the mouse over it and then moves it until the mouse is pressed. I am having some problem with this.

Here's my code
#include <SFML/Graphics.hpp>
#include <iostream>

int main()
{
    sf::RenderWindow window(sf::VideoMode(640, 480, 32), "TEST");

    sf::RectangleShape shape(sf::Vector2f(30.0f, 30.0f));
    shape.setFillColor(sf::Color::Red);
    shape.setPosition(sf::Vector2f(100.0f, 200.0f));

    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;
            }
        }

        sf::Vector2f mousePos = (sf::Vector2f)sf::Mouse::getPosition(window);
        sf::Vector2f shapePos = shape.getPosition();

        std::cout << mousePos.x << ", "<< mousePos.y << std::endl;

        if(mousePos.x >= shapePos.x && mousePos.x <= shapePos.x + shape.getGlobalBounds().width
           && mousePos.y >= shapePos.y && mousePos.y <= shapePos.y + shape.getGlobalBounds().height)
            if(sf::Mouse::isButtonPressed(sf::Mouse::Left))
                shape.setPosition(mousePos.x, mousePos.y);

        window.clear();

        window.draw(shape);

        window.display();
    }

    return 0;
}
 

How do I rectify my code to make it work correctly?

Thanks

12
General / Unable to compile SFML program in Ubuntu 12.10
« on: September 15, 2013, 03:38:51 pm »
Hello

I can't compile the following code in Code::Blocks in Ubuntu 12.10:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 

When sing Code::Blocks, I've mentioned in the search directories where the includes and libs are under the compiler and debugger settings. I've also done the necessary steps in the project build options too. But still getting an error.

I've compiled SFML sources and have  built the libs from from make files at the path /home/user404/Libraries/SFML_2_1

Also, whenever I build my program in debug version, this error pops up:
libGLEW.so.1.7 needed by /home/user404/Libraries/SFML_2_1/lib/libsfml-graphics.so, not found

And when I try to install libGLEW.so.1.7 as sudo apt-get install libglew1.7-dev, this happens in the terminal:

Reading package lists... Done
uilding state information... Done
E: Unable to locate package libglew1.7-dev
E: Couldn't find any package by regex 'libglew1.7-dev'


Any suggestions where's the problem?

Thanks

EDIT:
Also, when I am trying to generate makefiles using cmake cmake -G "Unix Makefiles" -D CMAKE_BUILD_TYPE=Debug -D BUILD_SHARED_LIBS=FALSE, an error pops up :

CMake Error : The source directory "/home/user404/Downloads/SFML_2_1/BUILD_SHARED_LIBS=TRUE" does not exist.

But the part BUILD_SHARED_LIBS=TRUE has nothing to with the search directory

13
General / Unexpected semantic error
« on: September 14, 2013, 07:38:48 am »
Hello

I was trying out the code given in The SFML Game Dev book in the first chapter:

Here are main.cpp, Game.h and Game.cpp

Game.h
#ifndef GAME_H
#define GAME_H


#include <SFML/Graphics.hpp>

class Game : private sf::NonCopyable
{
    public:
        Game();
        void run();
        ~Game();

    private:
        void processEvents();
        void update();
        void handlePlayerInput(sf::Keyboard::Key key, bool isPressed);
        void render();

    private:
        sf::RenderWindow mWindow;
        sf::CircleShape mPlayer;

        bool mIsMovingUp;
        bool mIsMovingDown;
        bool mIsMovingLeft;
        bool mIsMovingRight;
};

#endif // GAME_H
 

Game.cpp
#include "Game.h"


Game::Game() : mWindow(sf::VideoMode(640, 480), "SFML Application")
{
    mPlayer.setRadius(40.0f);
    mPlayer.setPosition(100.f, 100.f);
    mPlayer.setFillColor(sf::Color::Cyan);
}

void Game::run()
{
    while(mWindow.isOpen())
    {
        processEvents();
        update();
        render();
    }
}

void Game::processEvents()
{
    sf::Event event;
    while(mWindow.pollEvent((event)))
    {
        switch(event.type)
        {
            case sf::Event::KeyPressed:
                handlePlayerInput(event.key.code, true);
                break;
            case sf::Event::KeyReleased:
                handlePlayerInput(event.key.code, false);
                break;
            case sf::Event::Closed:
                mWindow.close();
                break;
        }
    }
}

void Game::handlePlayerInput(sf::Keyboard::Key key, bool isPressed)
{
    if(key == sf::Keyboard::W)
        mIsMovingUp = isPressed;
    else if(key == sf::Keyboard::S)
        mIsMovingDown = isPressed;
    else if(key == sf::Keyboard::A)
        mIsMovingLeft = isPressed;
    else if(key == sf::Keyboard::D)
        mIsMovingRight = isPressed;

}

void Game::update()
{
    sf::Vector2f movement(0.f, 0.f);

    if(mIsMovingUp)
       movement.y -= 1.f;
    if(mIsMovingDown)
        movement.y += 1.f;
    if(mIsMovingLeft)
        movement.x -= 1.f;
    if(mIsMovingRight)
        movement.x += 1.f;

    mPlayer.move(movement);

}

void Game::render()
{
    mWindow.clear();
    mWindow.draw(mPlayer);
    mWindow.display();
}

Game::~Game()
{
    //dtor

 

main.cpp
#include "Game.h"

int main()
{
    Game game;
    game.run();
}
 

But whenever I am running my code, the circle starts moving upwards automatically and if I press the W key it stops moving and then everything works normal and as expected.

If I change Game.cpp as follows, everything is normal:
.
.
.
Game::Game() : mWindow(sf::VideoMode(640, 480), "SFML Application"), mIsMovingUp(false)
{
.
.
.
 

So what's exactly the problem in the code in the first case and why is the variable mIsMovingUp only initialized during runtime?

Thanks

14
General / [Solved]What does .inl stand for?
« on: September 12, 2013, 06:15:51 pm »
Hello friends

I stumbled upon the source for the SFML Game Dev book here. I downloaded it and then tried to run the very first program it contains(01_Intro). But when I tried to run it, an unexpected error pops up:

D:\CodeBlocks\SFML  2.0\Projects\sf-GameDev\Ch-1-Intro\main.cpp|5|fatal error: Book/StringHelpers.h: No such file or directory

What is that supposed to mean?

Thanks

(I've set up everything correctly and linked SFML statically, it's working for other projects if I change the code)

15
SFML projects / A very nice Pong clone using SFML - 2.1
« on: September 06, 2013, 08:14:36 pm »
Hello friends!

I just finished creating my first complete game using SFML 2.1 on windows using Code::Blocks 12.11(but game is cross platform, runs on mac and linux too). I am uploading it. Please do run it and tell me what you think of it .
I don't claim that my game is very exciting or anything like that. Hope you like it. :)
If it's not working, please let me know.

CHEERS!

Link to download (Windows only)

Here are a few screenshots:







A gameplay video:

Pages: [1] 2