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

Pages: [1]
1
SFML wiki / Need HOWTO tutorial for setup SMFL with eclipse CDT
« on: September 16, 2011, 09:05:32 am »
thx for the tutorial, helped me a lot.

however i have 3 questions:
1) when i start the exe from eclipse, it doesn't really do anything. when i start it from the windows folder it works like a charm. can i change something to run it correctly from eclipse?

2) i hadn't to download mysy. i just downloaded the newest mingw and had to change 2 things in the bin folder of mingw. a) rename mingw32-make (or sthg like that) to just make and b) create a rm.bat file (or was is rn.bat?) with the following code: del all $* (or sthg like that. sorry cant remember the code exactly because i'm not at home right now to open the file).

3) when i create a sourcefolder and switch the "main.cpp" into it, i have to delete this autogenerated Default folder, where the binaries and exe file are in, and also i have to readd the library search folder and the libraries (sfml-system-d....). why is that?


regards
simon

2
Graphics / Black Screen for a short moment
« on: October 03, 2010, 01:10:02 pm »
Quote
in the last method (runmenu) inside the if( selectedindex != last ) is the important code. i am confused why i only get this black screen the first time a press an arrow key in fullscreen mode. i then can't reconstruct this problem no matter how fast i press the keys.



Code: [Select]

// check if the user pressed an arrow key
      if( SelectedIndex != last )
      {
         // if so -> redraw the menu and set the new selected item
         Clear();
         last = SelectedIndex;
         DrawBackground( Boundary );

         curY = y;
         for( unsigned int i=0; i<Entries.size(); ++i )
         {
            int mode = DISABLED;
            if( IsEnabled( i ) )
            {
               if( i == SelectedIndex )
                  mode = SELECTED;
               else
                  mode = ENABLED;
            }
            DrawItem( Boundary, *Entries[i], 0, curY, (int)Boundary.GetWidth(), delta, mode );
            curY += delta;
         }
         Show();
      }



i already posted that in the first post. it's that part that causes the problem but only when it runs the code for the first time. when i then repeat pressing arrow keys, there is no black screen.

clear is a simple application->Clear() statement and Show is application->Display() statement.

the drawmethods make a call to application->Display( Sprite )/application->Display( String ) to render the sprites/strings.

since the resources are already loaded, before entering the runmenu method, it cant be a cause of preloading images or sthg like that.

3
Graphics / Sprite hit area, how to?
« on: October 02, 2010, 07:56:34 pm »
there are different approaches to this problem:

an easy way would be to make your own "collision rectangles" for each frame of your sprite and then check for all that rectangles, if they collide with any of the other sprite's collision rectangles.

in your graphic f.e. you can make one big rect for the whole right side of the yellow sprite, one medium rect for the left "halfisle" and another small rect for the tiny little halfisle on the left bottom corner.



another way would be to check the non-transparent pixels of the sprites and if there are overlapping pixels, there is a collision. to optimize this second approach you can save the indizes of the transparent pixels to avoid checking pixel per pixel.

if you have f.e. a 8x8 pixel sprite and pixel 1 to 27 are transparent, you store this information in your spriteclass or whatever. if you now check for a pixelcollision you start at pixel 1. you now know that the next 26 pixels are transparent so you can directly jump to pixel 28, etc..



but to keep it simple i would recommend the first approach.

4
Graphics / Black Screen for a short moment
« on: October 01, 2010, 07:42:45 pm »
start the application in fullscreen and press the arrow up or down button. the window is then blacked out for a short moment.

or what kind of example do you mean?

5
Graphics / Trying to change cursor
« on: September 28, 2010, 08:50:59 pm »
imo use a .png format for the spritegraphic and make the background transparent. should be better (including performance) then hardcode this in your sourcecode.

6
Graphics / Black Screen for a short moment
« on: September 28, 2010, 08:48:58 pm »
no1 got any idea ? :(

i can attach the source code of an older version of the program. in the iqchallenge.cpp just set the windowmode to fullscreen and you should get the same error.

Source Code

7
Graphics / Trying to change cursor
« on: September 26, 2010, 03:03:33 pm »
don't know what language you are using exactly but as far as i can tell:

first of all you are hiding the mousecursor in the mainloop which is a waste of "performance" since you only need to disable it once.

second:
instead of checking for the mousemoveevent you can use the following
Code: [Select]

while( app.isopened() )
{
 // your event handling stuff

 // after the event handling
 CursorSpr.SetPosition( App.GetInput().GetMouseX(), App.GetInput().GetMouseY() );
}


third: use the setposition method of the sprite and not the move method. i think move is sthg else.

8
Graphics / Black Screen for a short moment
« on: September 26, 2010, 07:52:14 am »
Hi,

i got a weird problem with my gamemenu class. when the game starts, the menu is loaded and displayed and as long, as the user doesn't press an arrow key, nothing happens.
when he presses an arrow key, another menuitem gets selected and the menu gets redrawn.

my problem now is, that when i start the game in fullscreen and when i press an arrow key the _FIRST_ time, i get a black screen for less than a second before the menu gets redrawn. in windowmode i haven't this problem or maybe it's just to fast to recognize it.

i don't see any problems with the code so maybe it's an sfml internal mechanic that i am using wrong or sthg.

here is the main function, but i think the problem isn't there:

Code: [Select]
#include <time.h>
#include <iostream>
#include "iqchallenge.h"
#include "title.h"
#include "game.h"
#include "information.h"
#include "KeySelection.h"
#include <fstream>

sf::RenderWindow* APPLICATION = NULL;



void FatalError( const char* text )
{
    printf( "%s\n", text );
    std::cin.ignore();
    exit( EXIT_FAILURE );
}    // end FatalError



// initializes the random generator and sfml
void Init()
{
    // initialize random generator
    srand((unsigned int)(time(NULL)));

    // read config.txt
    // it contains the videmode settings
    sf::VideoMode VMode = sf::VideoMode( 640, 480, 32 );
    std::ifstream File( "media/config.txt" );
    if( !File.is_open() )
        FatalError( "Couldn't load file \"config.txt\"" );

    std::map<std::string,std::string> values;
    while( File && !File.eof() )
    {
        std::string line;
        getline( File, line );
        if( line.length() > 1 )
        {
            int index = line.find( '=' );
            if( index != std::string::npos )
            {
                std::string key( line, 0, index );
                std::string v( line, index+1, line.length() );
                values.insert( std::make_pair( key, v ) );
            }
        }
    }
    File.close();

    // init sfml
    VMode.Width = atoi( values["width"].c_str() );
    VMode.Height = atoi( values["height"].c_str() );
    VMode.BitsPerPixel = atoi( values["color"].c_str() );
    if( !VMode.IsValid() )
        FatalError( "Couldn't initialize VideoMode" );
    if( atoi( values["fullscreen"].c_str() ) == 0 )
        APPLICATION = new sf::RenderWindow( VMode, "IQ Challenge" );
    else
        APPLICATION = new sf::RenderWindow( VMode, "IQ Challenge", sf::Style::Fullscreen );
    APPLICATION->SetFramerateLimit( 60 );
    APPLICATION->UseVerticalSync( atoi( values["vsync"].c_str() ) == 1 );
    APPLICATION->ShowMouseCursor( false );
}    // end Init



// shuts down the application by releasing the resources
// allocated in Init()
void CleanUp()
{
    delete APPLICATION;
    APPLICATION = NULL;
}    // end CleanUp



void Clear()
{
    APPLICATION->Clear();
}
void Show()
{
    APPLICATION->Display();
}    // end Clear and Show



// entry point of the application
int main()
{
    Init();

    while( APPLICATION->IsOpened() )
    {
        // handle "close application" events
        sf::Event Event;
        while( APPLICATION->GetEvent( Event ) )
        {
            if( Event.Type == sf::Event::Closed ||
                (Event.KeyPressed && Event.Key.Code == sf::Key::Escape) )
            {
                APPLICATION->Close();
            }
        }

        switch( Title() )
        {
        case( 0 ): Game(); break;
        case( 1 ): KeySelection(); break;
        case( 2 ): Information(); break;
        case( -1 ):
        case( 3 ): APPLICATION->Close(); break;
        }
    }

    CleanUp();
    return EXIT_SUCCESS;
}    // end main



and here is the menuclass:
Code: [Select]

#include "SimpleMenu.h"
#include "iqchallenge.h"


SimpleMenu::SimpleMenu() : BackGround( NULL )
{
FontSelected = NULL;
FontNormal = NULL;
for( int i=0; i<COUNT_MODES; ++i )
Color[i].r = Color[i].g = Color[i].b = 255;
} // end Konstructor



// this method automatically scales the background image to the boundaries
// given by the RunMenu Method and finally draws it
void SimpleMenu::DrawBackground( const sf::Rect<int>& Boundary )
{
if( BackGround )
{
sf::Sprite Sprite( *BackGround );
Sprite.SetScale( (float)Boundary.GetWidth() / Sprite.GetSubRect().GetWidth(), (float)Boundary.GetHeight() / Sprite.GetSubRect().GetHeight() );
Sprite.SetPosition( (float)Boundary.Left, (float)Boundary.Top );
APPLICATION->Draw( Sprite );
}
} // end DrawBackground



// sets a background image for the menu
void SimpleMenu::SetBackground( sf::Image& Image )
{
BackGround = &Image;
} // end SetBackground



// sets the fontcolor that will be used for a given mode
void SimpleMenu::SetColor( int mode, sf::Color& color )
{
if( mode >= 0 && mode <= COUNT_MODES )
Color[mode] = color;
} // end SetColor



// sets the font for a normal and selected item
void SimpleMenu::SetFonts( sf::Font& Normal, sf::Font& Selected )
{
FontNormal = &Normal;
FontSelected = &Selected;
} // end SetFonts



// draws an item at the middle of the boundary's width
// boundary is the boundary for the menu given by the runmenu method
// text is the text of the item
// x and y is the calculated offset for the item, that was calculated in the runmeenu method
// w is the width of the boundary
// h is the heightoffset between two items
// mode is the mode of the item (enabled,disabeld,selected)
void SimpleMenu::DrawItem( const sf::Rect<int>& Boundary, const std::string& Text, int x, int y, int w, int h, int mode )
{
sf::Font Font;
if( mode != SELECTED )
Font = ( FontNormal != NULL ? *FontNormal : sf::Font::GetDefaultFont() );
else
Font = ( FontSelected != NULL ? *FontSelected : sf::Font::GetDefaultFont() );

std::string Temp;
if( mode == SELECTED && ItemEyeCandy != 0 )
{
Temp = ItemEyeCandy;
Temp += "  ";
Temp += Text;
Temp += "  ";
Temp += ItemEyeCandy;
}
else
Temp = Text;


const int fontsize = Font.GetCharacterSize();
sf::String String;
String.SetText( Temp );
String.SetFont( Font );
String.SetColor( Color[mode] );
String.SetSize( (float)fontsize );
String.SetPosition( (Boundary.Left+Boundary.Right)/2.0f - String.GetRect().GetWidth()/2.0f + ItemOffsetX, Boundary.Top+y + ItemOffsetY - fontsize/2.0f );
APPLICATION->Draw( String );
} // end DrawItem



// this method controls the input of the user and draws all items
// the boundary parameter tells us the boundaryrect of the menu
// the menu is controlled via the arrow keys of the keyboard
// escape or window closed events return -1
int SimpleMenu::RunMenu( const sf::Rect<int>& Boundary )
{
bool IsDone = false;
int last = -1;
int y = 0;
int curY = 0;
// delta is the offset between two items
unsigned int delta = 0;
delta = ( FontNormal ? FontNormal->GetCharacterSize() : sf::Font::GetDefaultFont().GetCharacterSize() );
delta = std::max( delta, FontSelected ? FontSelected->GetCharacterSize() : sf::Font::GetDefaultFont().GetCharacterSize() );
y = (int)(( Boundary.GetHeight() - ( delta * Entries.size() ) ) / 2);

while( !IsDone )
{
// handle all events
sf::Event Event;
while( APPLICATION->GetEvent( Event ) )
{
switch( Event.Type )
{
case( sf::Event::Closed ): return -1;
case( sf::Event::KeyPressed ):
{
if( Event.Key.Code == sf::Key::Escape )
return -1;
else if( APPLICATION->GetInput().IsKeyDown( sf::Key::Up ) )
SelectedIndex = MoveSelection( -1 );
else if( APPLICATION->GetInput().IsKeyDown( sf::Key::Down ) )
SelectedIndex = MoveSelection( 1 );
else if( APPLICATION->GetInput().IsKeyDown( sf::Key::Return ) )
IsDone = true;
} break;
}
}

// check if the user pressed an arrow key
if( SelectedIndex != last )
{
// if so -> redraw the menu and set the new selected item
Clear();
last = SelectedIndex;
DrawBackground( Boundary );

curY = y;
for( unsigned int i=0; i<Entries.size(); ++i )
{
int mode = DISABLED;
if( IsEnabled( i ) )
{
if( i == SelectedIndex )
mode = SELECTED;
else
mode = ENABLED;
}
DrawItem( Boundary, *Entries[i], 0, curY, (int)Boundary.GetWidth(), delta, mode );
curY += delta;
}
Show();
}
}
return SelectedIndex;
} // end RunMenu



in the last method (runmenu) inside the if( selectedindex != last ) is the important code. i am confused why i only get this black screen the first time a press an arrow key in fullscreen mode. i then can't reconstruct this problem no matter how fast i press the keys.


hoping for help ;)


edit:
is there a better tag for code? only green without highlighting is hard to read imo.

9
SFML projects / Tilemap Editor (working title)
« on: June 18, 2010, 05:38:27 pm »
is there a reason, why you use -1 for "unused" tiles instead of zero? -1 is harder to "parse" than a zero imo.

also your xml file has a lot of unnecessary whitespaces, which again, makes it harder to parse/read.

would be nice, if you can optimize that a little bit? :)

10
General discussions / Game Maker flooding the market with crap?
« on: June 17, 2010, 03:13:25 pm »
Quote
No, it isn't. you could have took two weeks more to learn C++ and make the game all on your own, and made it eat a lot less resources. There's just no excuse for half-assing a game with Game Maker or RPG Maker.


are you serious?

show me ONE person that used rpk maker, then studied c++ for two weeks and created a game better than the rpk maker game.

a good 2d game engine with tools to create your tilemaps,events,etc. like rpg maker does, is a LOT of work. for one person alone it will take much more than two weeks to work in an acceptable way ;)


yes, those tools are limited, but like others already said, they are perfect for beginners or advantaged programmes to create "easy" games fast.



show me one of your "game creator" tools :)

11
Graphics / Problem with the RenderWindow Tutorial?
« on: June 08, 2010, 02:30:50 pm »
Hi,

i am new to sfml and encountered a problem with the tutorials for the 1.6 sdk. the normal window tutorial caused a corrupted memory failure for the sf::window variable after the application exited.

the next tutorial with the sf::renderwindow crashed my application with the renderwindow.clear() method.


i read through the forum and saw that some people had the same problems but got no solutionanswers yet.

for those i want to present my solution, how i fixed that.


i downloaded the normal sdk (not the full one) and linked everything like it was said in the first tutorial. the clock example worked without errors but the next tutorials had the problems, described at the beginning of my post. i tried different things:
- static link
- dynamic link
- different "linkorders" of the libraries

nothing worked.


so i downloaded the full sdk, started the vs08 project and build my own debug, debug-dll, release and release-dll builds. i then relinked my tutorial project's library to my new created library folder (it's inside the lib folder (vs08 folder)), disabled the sfml_dynamic_link option in the preprocessor and finally linked the linker additional dependencies to my new created static libs.

both worked now the window tutorial and the renderwindow tutorial.


my system:
window 7 64bit prof
visual studio 2010
nvidia gtx295
intel core i7





hopefully this is useful for others ;)

Pages: [1]
anything