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

Pages: 1 ... 17 18 [19]
271
SFML projects / Re: Space Invaders Clone
« on: August 21, 2015, 02:41:02 pm »
Looks pretty well done. Good job.  :P

thanks @Verra really i appreciate. i have made little changes differ than example in Book. it supports mouse in GUI when user navigate buttons , i dont know why in the book says it's difficult to implement mouse functionality. it's appeared easy to do it. it only needs to iterate throughout all components to see whether or not the mouse position contains in buttons boundaries. of course, the annoying part in mouse implementation is when it has sound and continuously beeps when it is hovering throughout buttons. now, in the game, sound only beep once when the mouse hover the buttons.

however, the game runs only in release mode. it doesn't work fine in debug mode, the frame rate drop to zero especially when i implemented the collision detection. i tried to use QuadTree as many people suggest but no avail, maybe i implemented the QuadTree wrongly i'm not sure.

once again thanks for your kind words :)   

272
SFML projects / Space Invaders Clone - Game finished
« on: August 20, 2015, 11:23:36 pm »
Game finished

hello everybody i just finished reading the SFML Development Book. it really a great book many thanks to all authors. i have made a simple space invaders based on what i have learned from the Book.

here a new video with latest update where the player can spawn



source code is available hère:
https://github.com/MORTAL2000/Space-Invaders-Clone

NOTE: it tested on VS 2015.

273
omg .. you just remind me of myself a year ago. the "stdafx.h"  was my companion for couple of months until i realized that's it useless when i had my first project with multiple files. if you are using VC10 or VC08 throw it away believe me it doesn't worth it. i just installed VC14 with C++14 supported. i'm now toying with std::bind and lambda.  8)

274
General / My First openGL Program by using SFML
« on: August 03, 2015, 03:27:43 pm »
hello
i'm recently learning opengl and shader language and SFML. i have create my first GLSL program that draw colored rectangle on screen.

i'm looking for best practice in both SFML and openGL in this code

#include <GL/glew.h>
#include <SFML/Window.hpp>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <stdexcept>
#include <cassert>

#define GLSL(src) "#version 400 core\n" #src
#define GETERROR() getError(__FILE__,__LINE__)

namespace
{
        const unsigned CurrentWidth = 800;
        const unsigned CurrentHeight = 600;
}

void getError(const char *file, int line)
{
        GLenum error(glGetError());

        while (error != GL_NO_ERROR)
        {
                std::string errorString;

                switch (error)
                {
                case GL_INVALID_OPERATION:      errorString = "INVALID_OPERATION";      break;
                case GL_INVALID_ENUM:           errorString = "INVALID_ENUM";           break;
                case GL_INVALID_VALUE:          errorString = "INVALID_VALUE";          break;
                case GL_OUT_OF_MEMORY:          errorString = "OUT_OF_MEMORY";          break;
                case GL_INVALID_FRAMEBUFFER_OPERATION:  errorString = "INVALID_FRAMEBUFFER_OPERATION";  break;
                }

                throw std::runtime_error("GL_" + errorString + " - " + std::string(file) + ":" + std::to_string(line));
                error = glGetError();
        }
}

class Tutorial
{
public:
        Tutorial();
        ~Tutorial();
        void run();


private:
        void processEvent();
        void render();

        void createVBO();
        void destroyVBO();
        void createShaders();
        void destroyShaders();


private:
        sf::Window mWindow;

        GLuint mVertexShaderID;
        GLuint mFragmentShaderID;
        GLuint mProgramID;
        GLuint mVAOID;
        GLuint mVBOID;
        GLuint mColorBufferID;

        const std::vector<GLchar*> mVertexShader =
        {
                {
                        GLSL(
                                layout(location = 0) in vec4 in_Position;
                                layout(location = 1) in vec4 in_Color;

                                out vec4 ex_Color;

                                void main(void)
                                {
                                        gl_Position = in_Position;
                                        ex_Color = in_Color;
                                }
                        )
                }
        };
        const std::vector<GLchar*> mFragmentShader =
        {
                {
                        GLSL(
                                in vec4 ex_Color;
                                out vec4 out_Color;

                                void main(void)
                                {
                                        out_Color = ex_Color;
                                }
                        )
                }
        };

};

Tutorial::Tutorial()
        : mWindow(sf::VideoMode(CurrentWidth, CurrentHeight), "Example 00")
{
        glewExperimental = true; // Needed in core profile

        if (glewInit() != GLEW_OK)
        {
                throw std::runtime_error("Failed to initialize GLEW\n");
        }

        glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

        createShaders();
        createVBO();
}

void Tutorial::run()
{
        while (mWindow.isOpen())
        {
                processEvent();
                render();
        }
}

void Tutorial::processEvent()
{
        sf::Event event;
        while (mWindow.pollEvent(event))
        {
                if (event.type == sf::Event::Closed)
                        mWindow.close();
                if (event.type == sf::Event::Resized)
                        glViewport(0, 0, mWindow.getSize().x, mWindow.getSize().y);
        }
}
void Tutorial::render()
{
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glDrawArrays(GL_TRIANGLES, 0, 3);
        mWindow.display();
}

Tutorial::~Tutorial()
{
        destroyShaders();
        destroyVBO();
}

void Tutorial::createVBO()
{
        GLfloat Vertices[] =
        {
                -0.8f, -0.8f, 0.0f, 1.0f,
                 0.0f,  0.8f, 0.0f, 1.0f,
                 0.8f, -0.8f, 0.0f, 1.0f
        };

        GLfloat Colors[] =
        {
                1.0f, 0.0f, 0.0f, 1.0f,
                0.0f, 1.0f, 0.0f, 1.0f,
                0.0f, 0.0f, 1.0f, 1.0f
        };

        glGenVertexArrays(1, &mVAOID);
        glBindVertexArray(mVAOID);

        glGenBuffers(1, &mVBOID);
        glBindBuffer(GL_ARRAY_BUFFER, mVBOID);
        glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
        glEnableVertexAttribArray(0);

        glGenBuffers(1, &mColorBufferID);
        glBindBuffer(GL_ARRAY_BUFFER, mColorBufferID);
        glBufferData(GL_ARRAY_BUFFER, sizeof(Colors), Colors, GL_STATIC_DRAW);
        glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, 0, 0);
        glEnableVertexAttribArray(1);

        GETERROR();
}

void Tutorial::destroyVBO()
{
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(0);

        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glDeleteBuffers(1, &mColorBufferID);
        glDeleteBuffers(1, &mVBOID);

        glBindVertexArray(0);
        glDeleteVertexArrays(1, &mVAOID);

        GETERROR();
}

void Tutorial::createShaders()
{
        mVertexShaderID = glCreateShader(GL_VERTEX_SHADER);
        glShaderSource(mVertexShaderID, 1, &mVertexShader[0], NULL);
        glCompileShader(mVertexShaderID);

        mFragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);
        glShaderSource(mFragmentShaderID, 1, &mFragmentShader[0], NULL);
        glCompileShader(mFragmentShaderID);

        mProgramID = glCreateProgram();
        glAttachShader(mProgramID, mVertexShaderID);
        glAttachShader(mProgramID, mFragmentShaderID);
        glLinkProgram(mProgramID);
        glUseProgram(mProgramID);

        GETERROR();
}

void Tutorial::destroyShaders()
{
        glUseProgram(0);

        glDetachShader(mProgramID, mVertexShaderID);
        glDetachShader(mProgramID, mFragmentShaderID);

        glDeleteShader(mFragmentShaderID);
        glDeleteShader(mVertexShaderID);

        glDeleteProgram(mProgramID);

        GETERROR();
}

int main()
{
        try
        {
                Tutorial tut;
                tut.run();
        }
        catch (std::runtime_error& e)
        {
                std::cout << "\nException: " << e.what() << std::endl;
                return 1;
        }
}

275
General / help with aurora library
« on: July 31, 2015, 06:40:30 pm »
i tried to use aurora lib just to understand it. however when i compiled the example in its official site i got errors. i don't know why this happened.

the code in official site:
#include <Aurora/Dispatch.hpp>
#include <iostream>

struct Object { virtual ~Object() {} };
struct Asteroid : Object {};
struct Ship : Object {};

void collisionAA(Asteroid*, Asteroid*) { std::cout << "Asteroid-Asteroid\n"; }
void collisionAS(Asteroid*, Ship*)     { std::cout << "Asteroid-Ship\n"; }
void collisionSS(Ship*, Ship*)     { std::cout << "Ship-Ship\n"; }


int main()
{
        // Register "overloaded" functions
        using aurora::Type;
        aurora::DoubleDispatcher<Object*> disp;
        disp.bind(Type<Asteroid>(), Type<Asteroid>(), &collisionAA);
        disp.bind(Type<Asteroid>(), Type<Ship>(), &collisionAS);
        disp.bind(Type<Ship>(), Type<Ship>(), &collisionSS);

        // Call function, given only base class pointers
        Asteroid a;  
        Object* pa = &a;
        Ship s;      
        Object* ps = &s;
        disp.call(pa, ps); // Output: Asteroid-Ship
        std::cin.ignore();
}

errors appear like this:
1>------ Build started: Project: junk_input, Configuration: Debug Win32 ------
1>  Source1.cpp
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C2027: use of undefined type 'aurora::detail::FunctionSignature<Signature>'
1>          with
1>          [
1>              Signature=Object *
1>          ]
1>          c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\dispatch\doubledispatcher.hpp(126) : see reference to class template instantiation 'aurora::FunctionResult<Signature>' being compiled
1>          with
1>          [
1>              Signature=Object *
1>          ]
1>          c:\users\mohammed\documents\sfml-working\junk_input\junk_input\source1.cpp(17) : see reference to class template instantiation 'aurora::DoubleDispatcher<Object *,aurora::RttiDispatchTraits<Signature,2>>' being compiled
1>          with
1>          [
1>              Signature=Object *
1>          ]
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C2146: syntax error : missing ';' before identifier 'Type'
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): error C2208: 'aurora::Type' : no members defined using this type
1>c:\program files (x86)\microsoft visual studio 12.0\vc\include\aurora\meta\templates.hpp(141): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

i'm using VS 2013. how to solve those errors?

276
General discussions / Re: SFML Game Development - Chapter - 4
« on: July 31, 2015, 06:30:15 pm »
hello @eXpl0it3r
it is from github. i could not know why sf::Time argument there really it confuses me. i hope it is there just for later used in proceeding chapters. i haven't finished the book yet

277
General discussions / SFML Game Development - Chapter - 4
« on: July 31, 2015, 02:32:15 pm »
first i want thanks everybody who contributed in the book, however, i'm reading chapter 4, i found  in std::fonctional expression in Command class
std::function<void(SceneNode&, sf::Time)>       action;
and functor in AircraftMover class
void operator() (Aircraft& aircraft, sf::Time) const
{
        aircraft.accelerate(velocity);
}
take two arguments. the second argument is sf::Time type which is never computed throughout all classes. My question why is it there while it never be considered?

278
SFML projects / Re: Tic Tac Toe
« on: July 28, 2015, 05:33:41 am »
i added shader lights to it

source code: https://gist.github.com/MORTAL2000/2ba8479330e554b4f08e

279
SFML projects / Re: Screenshot Thread
« on: July 28, 2015, 05:10:03 am »
here, Tic Tac Toe with some lights  :P

280
SFML projects / Re: Tic Tac Toe
« on: July 25, 2015, 03:41:44 am »
at last i fixed all known bugs. i updated the code at gist. i hope this code will work fine by now

281
SFML projects / Re: Tic Tac Toe
« on: July 24, 2015, 09:04:57 pm »
thanks Mario
i edited my post. it much better now

282
SFML projects / Re: Tic Tac Toe
« on: July 23, 2015, 11:02:30 pm »
for sake of improve this game. i made a few changes to it. it not that much but it makes the game a little bit nicer

code here at gist (https://gist.github.com/MORTAL2000/c5beb7b5f65a25400434)


283
SFML projects / Re: Tic Tac Toe
« on: July 21, 2015, 07:47:45 am »
thanks really appreciated. i have done those change except making it harder, i want to solve some known bugs first. also added title and made the board at center of screen.


284
SFML projects / Tic Tac Toe
« on: July 21, 2015, 01:18:17 am »
i have made Tic Tac Toe game by using SFML. It seems to work fine. I'm actually new to SFML and making GUIs. If anyone is familiar with SFML, I'd appreciate some pointers on how to improve it.

code here at (https://gist.github.com/MORTAL2000/c5beb7b5f65a25400434)

Pages: 1 ... 17 18 [19]
anything