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

Pages: 1 2 3 [4]
46
General / Re: SFML doesn't want to work...
« on: September 14, 2013, 08:02:09 pm »
El tema es que haciendo lo que te digo yo el error que te da es del Linker (que es un paso posterior al del compilador).

A ver, para crear un ejecutable, hay 2 fases. El Compilador y el Linker.

En la primera fase, el compilador comprueba que no haya errores de sintaxis y genera los archivos objeto (*.o) mediante la compilación de tus archivos fuentes (y sus includes, por lo que deben de estar correctamente referenciados). Aquí es donde te estaba dando el error antes.

En la segunda fase, el Linker coge todos los archivos .o (objeto) y los une en un único archivo ejecutable (.exe en caso de windows) incluyendo adicionalmente las librerías estáticas como es en este caso SFML. Este es el caso de tu segundo error, ya que SFML necesita linkear adicionalmente para funcionar las librerias de STD, las cuales se linkean en el caso de MinGW añadiendo como parámetro ANTES de los otros parámetros de sfml la siguiente cadena:

-lmingw32

Con lo que te quedaría así:

-lmingw32 -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s

Y ya si en un futuro vas a usar OpenGL pues quedaría así:

-lmingw32 -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s -lopengl32 -lglu32

y por último, si vas a ejecutar el binario en un PC que NO tenga MinGW instalado, necesitarás linkear otras librerias adicionales, con lo que finalmente quedaría así:

-lmingw32 -lsfml-graphics-s -lsfml-audio-s -lsfml-window-s -lsfml-system-s -lopengl32 -lglu32 -static-libgcc -static-libstdc++


Saludos

47
General / Re: SFML doesn't want to work...
« on: September 14, 2013, 06:46:38 pm »
Lo que te dije yo era que o bien quitabas el SFML/ de todos los headers o bien indicas al compilador que busque los headers en la carpeta padre (no dentro de SFML). ¿Has intentado lo segundo?

48
General / Re: SFML doesn't want to work...
« on: September 14, 2013, 05:28:49 pm »
I will reply in spanish (If is necesary I can translate it to english but this way is faster for me):

-----------------

Al hacer el #include, creo que has indicado al compilador directamente la carpeta donde se encuentran los headers (en la configuración previa que muestras por video), por lo que no debes de poner "SFML/<header>.hpp", sino tan solo "<header>.hpp". O bien esto o bien haces el include a su carpeta padre (para que la ruta si incluya el SFML).

49
SFML projects / Re: My first non-console Game : Reda's Snake
« on: September 14, 2013, 05:13:49 pm »
A screenshot doesn't hurt  :P



Suggestions:

- Remove unused assets (the background never changes and the .png has more than 1)
- Sometimes the food appear behind the body of the snake, so you can't see it until you pass throught.
- When you die, I expected to reset the game, not close the window and end the game.
- Make it more slow at start and speed up progressively (?)
- SFX? :D

50
Window / Re: Window does not activate if you click inside it
« on: September 14, 2013, 12:17:44 am »
Same here (I'm using v2.1 too)

I'll wait for the 2.2 release then ^^

51
SFML projects / Re: [SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games
« on: September 13, 2013, 10:41:35 pm »
Pong
Is it just me or can the AI move its paddle faster than the player can?

Maybe, I never cared the quality of this game. The main reason of the game was to "warmup" for the others and setup all the IDE and compiler/linker to work for the next ones xD

Snake
Key input seems to be handle oddly, at least it's impossible to do two direction changes very quickly one after the other, which kind of kills the whole Snake game play. Also the sound for moving gets totally annoying and  the movement speed could be faster.

Except for the fact you can turn your direction to the back of the head (so you instant lose because it collides with the body) I think the control is just I wanted... mmm

Speed faster... next time  :P

Arkanoid
Interesting that you didn't choose "Breakout" as name, since Arkanoid was based on the Atari Breakout and I believe it was more popular.
For playing it seems like the paddle should be able to move faster.

Oh, that's interesting. Here in Spain (english is NOT my native language, sorry if I misspell a phrase or word...) this game is know as "Arkanoid" rather than Breakout. I didn't know this game was based on it.

And yes, paddle faster... but I wanted to test well the collisions of the ball with it so I made it slower (sorry for the slooow gameplay then xD)

Tetris
A more standard binding of the keys would be:
Arrow Left to move left
Arrow Right to move right
Arrow Up to rotate the pieces
Arrow Down to move the pieces down
Space to set the piece fully down.

I especially missed the option to directly place a block.
There also seems to be a bug. Even though I've filled 4 lines at once, it only removed 2 lines.

Honestly, all these games are done from my memory so like this case, it's very normal to fail my approach to "clone" the original game exactly. I didn't know the original binding of the keys so I just keep with the same of the previous games (snake and pong).

I played a bit before "release" it and didn't find that bug.... I'm very surprised.

Pacman
It seems like the ghosts get somehow a bit stuck in the spawning location. Also looking at some original game play of Pacman it seems like all the ghost on the screen turn when eating the bigger coin, even the ones that are still in the spawning area.

You can make changes to the map and define the ghost's "houses" in any point of the map (they can spawn in any place, they don't need to be closed by a "ghost door" or something. You can put only 1 ghost too (up to 4). The requisites of the map is 1 ghost minimum, a pacman spawn location and one ball (the type doesn't matter).

Like I said before, I only copied pacman in the map, the gameplay was from my memory too so again, it's possible it doesn't fit exactly to the original xD

As for the code, I've really only taken a glimpse and saw some manual memory management. With modern C++ in mind and some C++11 features at hand, it's really not needed to manually manage the memory, as you can see in recent talk (jump to minute 20) of the creator of C++ Bjarne Stroustrup.
If you watch the linked video above you'll can also take away the points of passing around data. I've seen the use of some raw pointers, which most likely is not justified or stuff like const int& which doesn't make sense and should rather be passed as an actual integer itself.
Other than that on the surface, which is what I've looked at, the code seems a lot better than many code examples I've seen in the past here on the forum. ;)

Yes, the code is C++11 but don't everything (more like some things only xD). I need to switch my pointers to use smart pointers. I know how to use them so no problem with that, but sometimes it's more easy and quick for me to use classical pointers. The code inside "Engine/" folder it's very old and it's mainly a bunch of chuncks of code from older (some VERY old) projects of mine and from other opensource projects "glued" together. I need to rewrite some things, add others and delete more to polish this code...

About the talk, I'll see it tomorrow ^^  Thanks

I've added it to the huge list of new topics for the next SFML News.

Ok!  ;D



PS: All the changes suggested are a good start point for other people who wants to download the source and make changes so they can "learn" from a game already programmed... I just want to skip to the next one

52
SFML projects / [SFML2.1] Pong, Snake, Arkanoid, Tetris and Pacman games
« on: September 12, 2013, 10:55:42 pm »
First off, I made these games with objetive of learn how to make games (because I never finished one, I'm always reading docs and things but I never convinced to finish a project, so I decided to make a serie of games from the very basics to others more complicated. These games were done in a few hours each one (except Pacman, because it's more complicated) with the simplicity idea in mind (remember, the purpose was to finish them, not make it cool or perfect but functional and bugfree).

All of these games are built with SFML 2.1 + GCC (MinGW for windows). The base code is the same for all games (its the reason all games are located in "Game/" folder and all code base is in "Engine/". The engine was very bad designed and lacks of everything. This is because I made it before the games (Guys, DON'T make a "engine" if you don't know which will be your game requisites exactly, in other words, don't make it if you didn't finished a few games before so you will know exactly what you'll need).

So let's begin:

---------------------------------------------------------------------------------------

Pong



Download (Win x86): http://www.mediafire.com/download/aidxwov5tnirz39/Pong.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • Escape: Exit game


Snake



Download (Win x86): http://www.mediafire.com/download/yawhlmagt29nvab/Snake.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • Escape: Exit game


Arkanoid



Download (Win x86): http://www.mediafire.com/download/vb44w8bu4o8g7nw/Arkanoid.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • F2: Mute/Unmute SFX
  • Escape: Exit game


Tetris



Download (Win x86): http://www.mediafire.com/download/1nbp31bbkatzie2/Tetris.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • Space: Rotation
  • F1: Reset
  • F2: Mute/Unmute SFX
  • F3: Switch Modes (Normal / Hard)
  • Escape: Exit game
Note: Hard mode it's the same as Normal but sometimes will appear some pieces with crazy shapes (they will difficult your way to make lines)


Pacman:



Download (Win x86): http://www.mediafire.com/download/tu227yts56au21j/Pacman_1.0.1.rar
Source: https://github.com/JuDelCo/SFML2-Game

Controls:
  • Arrows: Movement
  • F1: Reset
  • F2: Mute/Unmute SFX
  • Escape: Exit game

The map editor in HTML/JS (yes, you can change or make your own maps) was made by Elendow

Bonus! (Wallpaper 1920x1080): Download / Open in Web Navigator

---------------------------------------------------------------------------------------


I don't know which kind of game do now... maybe a shoot'em up or simple platform game... but first i need to change a lot of things in the """engine"""... (it's more like a messy chunk of code lol xD)

Feedback will be always welcome  ^_^

Happy Coding!  :P


---
JuDelCo

53
Graphics / Re: [2.0] Sprites and Text transparency renders as black
« on: November 06, 2012, 11:15:25 pm »
Read the last section of this tutorial:
http://www.sfml-dev.org/tutorials/2.0/window-opengl.php

Oh! Okay, I forgot to push/pop SFML opengl states!  ::)

window.popGLStates();

        glEnable(GL_DEPTH_TEST);
        glClear(GL_DEPTH_BUFFER_BIT);
        glOrtho(0, 640, 480, 0, -1000.0, 1000.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

window.pushGLStates();
 

One thing more, i detect that i need now to draw all sprites backwards (first the backgrounds, entities and finally hud)

// Now IS this way:
window.draw(background);
window.draw(player);
window.draw(text);

// NOT this:
window.draw(text);
window.draw(player);
window.draw(background); // because background fills entire screen on top of all

Edit: Screenshot with the problem solved ^^



Thanks Laurent !  ;)

54
Graphics / Re: [2.0] Sprites and Text transparency renders as black
« on: November 06, 2012, 10:59:27 pm »
Could you please show a complete and minimal code that reproduces the problem, so that we can test it?

Sorry for the delay, i was making the Minimal Code (Complete code its a lot of source code / classes / files / blah)

Minimal Code (Timer Class its only a wrapper of sf::Clock):

This code makes the same render problem than the screenshot of the first post (but without the mini-view test)

#include <timer.h>
#include <SFML/OpenGL.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>


int main(int argc, char *args[])
{
        sf::RenderWindow window;

        //---------------------------------

        window.create(sf::VideoMode(640, 480), "Demo");
        window.setFramerateLimit(60);

        //---------------------------------

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

        glClearColor(0, 0, 0, 0);

        glMatrixMode(GL_TEXTURE);
        glLoadIdentity();
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();

        window.clear();

        //---------------------------------

        sf::Sprite player;
        sf::Texture playerTexture;

        playerTexture.loadFromFile("resources/player.png");
        player.setTexture(playerTexture);
        player.setTextureRect(sf::IntRect(0, 0, (player.getTexture()->getSize().x / 5), player.getTexture()->getSize().y));
        player.setPosition(200, 300);

        sf::Sprite background;
        sf::Texture backgroundTexture;
        backgroundTexture.loadFromFile("resources/back.png");
        background.setTexture(backgroundTexture);

        sf::Font fuente;
        fuente.loadFromFile("resources/arial.ttf");

        //---------------------------------

        bool run = true;
        int msLastFrame = 0;
        Timer fps;
        Timer update;

        while (run)
        {
                msLastFrame = fps.getTicks();
                fps.start();

                sf::Event event;

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

                //---------------------------------
               
                window.clear();

                glEnable(GL_DEPTH_TEST);
                glClear(GL_DEPTH_BUFFER_BIT);
                glDisable(GL_CULL_FACE);
                glMatrixMode(GL_PROJECTION);
                glLoadIdentity();
                glOrtho(0, 640, 480, 0, -1000.0, 1000.0);
                glMatrixMode(GL_MODELVIEW);
                glLoadIdentity();

                sf::Text text("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
                text.setFont(fuente);
                text.setCharacterSize(30);
                text.setStyle(sf::Text::Regular);
                text.setColor(sf::Color::Red);

                window.draw(text);
                window.draw(player);
                window.draw(background);

                window.display();

                //---------------------------------

                if (update.getTicks() >= 1000)
                {
                        update.start();
                }

                if (fps.getTicks() < 17) //59fps
                {
                        sleep(sf::milliseconds(17 - fps.getTicks()));
                }
        }

        //---------------------------------

        return 0;
}

 


55
Graphics / [2.0] Sprites and Text transparency renders as black (Solved)
« on: November 06, 2012, 10:22:18 pm »
Hi,

I'm trying to render a sprite, text and a big sprite as background PNG (for testing purposes)

The problem is the transparent color (the ship sprite is a PNG with a transparent alpha color) renders as black in both sprite and text



Simple code i use for text:
sf::Font fuente;
fuente.loadFromFile("resources/Arial.ttf");
sf::Text text("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
text.setFont(fuente);
text.setCharacterSize(30);
text.setStyle(sf::Text::Regular);
text.setColor(sf::Color::Red);
VIDEO.window.draw(text);

/* Sprite and background rendering */
 

Simple code i use for Sprite (in a sprite class):
sf::Image image;
image.loadFromFile("resources/ship.png");
this->setTexture(image);

/* ... later ... */

VIDEO.window.draw(*this);
 

PS: I use "setTextureRect" before draw the sprite because its a spritesheet

Pages: 1 2 3 [4]