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

Pages: [1]
1
General / Static Library Linking
« on: April 01, 2010, 10:11:45 pm »
I'm trying to create a Static Library (.a) based on SFML with Code::Blocks.  I've created a simple library to test, but even that isn't working.

Here is the code of the library:
Code: [Select]

// File Test.h
#ifndef TEST_H
#define TEST_H

class Test
{
    public:
        Test( );
        void Function( );
};

#endif

// File Test.cpp
#include <iostream>
#include <SFML/System.hpp>
#include "Test.h"

Test::Test( )
{
    std::cout << "Test::Test( ) " << sf::Randomizer::Random( 0, 10 ) << std::endl;
}

void Test::Function( )
{
    std::cout << "Test::Function( ) " << sf::Randomizer::Random( 50, 100 ) << std::endl;
}


I then add libsfml-system-s.a into the library using ar.
Code: [Select]

ar x libsfml-system-s.a
ar rs libStaticSFMLTest.a *.o

I'm pretty sure it works, since the file size of the library increases, after adding SFML System.

When I try to compile a project using the new library, I get linker errors:
Code: [Select]

C:\Documents and Settings\Eternal Warrior\My Documents\CodeBlocksProjects\StaticSFMLTest\libStaticSFMLTest.a(Test.o):Test.cpp:(.text+0x2f)||undefined reference to `sf::Randomizer::Random(int, int)'|


I'm sure I'm doing something wrong, but I can't figure out what.  Any help is appreciated.

2
General / Delta Time and Jumping
« on: March 28, 2010, 05:34:49 am »
Hello.  I'm currently working on a platform game, and I'm using Delta timing for synchronization.  The problem is that my computer is rather slow, and lags often so every time a lag spike occurs, the player jumps higher than normal (Delta time compensation).  Is there any way I can prevent this, or is it just an inherent flaw of using Delta time?  Thanks.

Edit: Here's my code for reference

Main game loop:
Code: [Select]

player.Input( window.GetInput( ) );

deltaTime = window.GetFrameTime( ) * 60.0f; // Synchronize to 60 FPS
player.Update( deltaTime );


Player definition:
Code: [Select]

void Player::Input( const sf::Input& input )
{
    if( input.IsKeyDown( sf::Key::W ) )
    {
        if( y >= 448.0f )
        {
            verticalSpeed = -6.0f;
        }
    }
}

void Player::Update( float deltaTime )
{
    y += verticalSpeed * deltaTime;

    if( y >= 448.0f )
    {
        verticalSpeed = 0.0f;
        y = 448.0f;
    }

    if( y < 448.0f ) verticalSpeed += 0.1f;

    sprite.SetPosition( x, y );
}

3
Graphics / Load Font from Memory
« on: December 12, 2009, 04:40:51 am »
Hi, I'm trying to load a font from memory, because I plan to use a custom font file type in the future already used in my engine.

Right now, though, I'm just trying to load a file into a std::string, and then use font.LoadFromFile( ) to get the font.

This is the code I'm using:
Code: [Select]

std::string& OpenFile( std::string filename )
{
    int length;
    char* buffer;
    std::string* encrypted;

    std::ifstream file;
    file.open( filename.c_str( ), std::ios::binary | std::ios::ate );

    file.seekg( 0, std::ios::end );
    length = file.tellg( );
    file.seekg( 0, std::ios::beg );

    buffer = new char[ length ];

    file.read( buffer, length );
    file.close( );

    *encrypted = buffer;

    delete( buffer );

    return( *encrypted );
}


And this is the code I use to load the font:
Code: [Select]

sf::Font font;

std::string file = OpenFile( "Arial.ttf" );
font.LoadFromMemory( file.c_str( ), file.length( ) );


The file is valid, and the error I get from SFML is an invalid stream operation.

Any help is appreciated.

Pages: [1]
anything