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

Pages: 1 ... 11 12 [13]
Window / emptying sf::Window from events?
« on: September 07, 2013, 10:57:23 pm »
hello everybody
i made a simple intro screen, where it fades in a image, waits for the user to press anything in the keyboard, and then fades out the image.

the problem is that if the user press any button before the image is completely showing in the screen,  it fades in and out directly (instead of fading in and only then accepting user inputs)

this is the code (game_sys_p is an object that holds the sf::Window; and intro1_spr is a sf::Sprite)

sf::Event intro_events;
    int fade_factor = 1;
    for (int i=0; i>=0; i+=5*fade_factor){
        game_sys_p.getGameWindow().clear(sf::Color(0, 0, 0, i));
        intro1_spr.setColor(sf::Color(255, 255, 255, i));
        if (i>=255){
                while (intro_events.type != sf::Event::KeyPressed){

i believe this happens because sf::Event is queueing the events (and i think it is expected). is there any way to prevent that?
or any change i could do to the code to fix it? any suggestion is welcome :)

thanks in advance!

General / Re: Small RPG design layout.
« on: April 23, 2013, 10:07:54 pm »
oh, got it. too bad i'm on Lubuntu + Code::Blocks...  :o

General / Re: Small RPG design layout.
« on: April 23, 2013, 09:25:21 pm »
well, i wouldn't change much about it, although i'm too newbie to say if it's good or not :P
how did you created this layout? in which program?
i'm curious to see others opinions too...

General discussions / Re: SFML v SDL?
« on: August 31, 2012, 01:23:34 am »
as i'm new to programming in general, i've tried some engines like SDL and SFML, to see wich one is the best.
honestly, both seems to be good. but SFML has many functions that i didn't found in SDL. and is a little easier, too. so...

Audio / Re: sf::music causes a crash?
« on: August 31, 2012, 01:03:13 am »
oops, sorry, i searched only this forum.  :-\

i'll wait, then. thanks.

Audio / sf::music causes a crash?
« on: August 31, 2012, 12:23:31 am »
i'm having a strange issue when i try to create a music object.
the program runs fine, but at the finish, windows give a error message "test.exe stopped working"

all i have to do is write sf::Music test! a minimal example that reproduces the problem:

#include "SFML/Audio.hpp"
int main(){
    sf::Music test;
    return 0;

in a complete example, the music DOES play, and the program runs fine. for some reason, it occurs after the 'return 0' from main().

in the console output:
process returned 255 (0xFF)

is this normal? the program runs fine, so i don't know...
i'm running on windows 7 SP1, SFML 2.0rc, Code::Blocks 10.05

thanks in advance!

Graphics / Re: Member function sprite call
« on: August 30, 2012, 07:40:49 am »
this question bothered for a long time, too. it's a C++ question, not SFML.
for this, you should use the reference and dereference operators.
you need a function inside your class that gets the variable from main(). like this:

int classFunction (sf::Renderwindow* window){
    window->draw(sprite); //here you use -> instead of a dot.
    return 0;

and in the main(), when you call the classFunction:


hope that it helps :)

Graphics / Re: SFML2 blinking screen
« on: August 28, 2012, 01:10:41 am »
GEE! i figured out what i was doing wrong!
in the "mapa.desMapa" function, everytime i draw a tile, i also use window->display(). without clearing the screen nor anything. and then, in the main loop, everything is drawn again!

like this, there's no way anyone could ever help me :P sorry for that, my fault. i did not wanted to post too much code at once...

just took that line off, and now everything is working like a charm.

the 'for' loop, as the 'system("pause") and the header are there just for tests. i'm not making any real game yet, just learning.
but thanks for the hints, anyway :)

EDIT: i forgot, thanks to everyone who tried to help me too   :D

Graphics / Re: SFML2 blinking screen
« on: August 27, 2012, 04:58:45 pm »
no worries. i'm still learning too :) i'm newbie to both SFML and C++ (and anything beyond RPG Maker).

well, that's a good thinking. but i what i understand is that the "sleep" function halts the whole program, to reduce RAM usage. and the  "limit framerate" only limits the screen refresh.
anyway, it still doesn't work if i take ou the "limit framerate" line, nor if i take out the "sleep" line  :-\

maybe i should make a double buffer? doesn't SFML do that by default?
also, i think its very strange that window.display() makes the screen black...

Graphics / Re: SFML2 blinking screen
« on: August 27, 2012, 04:24:31 pm »
thanks for the answers

but if i put the line
after the window.display(), or before the window.clear(), the screen blinks even worse.
the only way it doesn't blink is if i take out the window.clear().

also, there's no real render loop. i'm just testing if the tilemap works...

Graphics / SFML2 blinking screen
« on: August 27, 2012, 03:54:27 pm »
hello everybody!
first, i'd like to thank the creator and contributors of this library. it's really easy to understand, and is helping me a lot in learning on how to make a game.

then, i have a question that i believe it's simple.
i have loaded a texture and then created a sprite. this sprite is a tile, so i draw it a lot of times in the screen. then i update the screen, and draw all over again.
the problem is that the screen blinks every time it draws the tiles. (it blinks all tiles at once, and not one at time)
i don't know what could be wrong.

this is how i made it:

#include "head.h"
int main(){
    sf::RenderWindow window(sf::VideoMode (480, 480), "Jogo2");
    Mapa mapa;
    for (int i = 0; i<100; i++){
        mapa.desMapa(&window); //[b]see note below for this[/b]
    return 0;

note: the line mapa.desMapa(&window) draws the tiles on the screen. it does the following:
    window->draw(sChaoPedr); //draw the sprite
    sChaoPedr.setPosition(mapX*48, mapY*48); //set the sprite position
for each tile.

for some reason, it seems that window.display() clears the screen! after this comand, the screen turns black. i don't know why.

do i have to create one sprite for each tile?
if anyone thinks the error is somewhere else, please let me know, so i'll put the whole code.

i'm working on windows 7 SP1, SFML 2.0rc, Code::Blocks 10.05 (and the default mingw and gcc shipped with it).

thanks in advance :)

Pages: 1 ... 11 12 [13]