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

Pages: [1] 2
1
Graphics / Completely Eliminating Jittery Movement
« on: October 21, 2013, 09:16:22 pm »
First, before getting started, I'd like to define what I mean by jittery movement — every 500 ticks or so, the sprite being moved might jerk forward a little bit, and then snap back in place, thus appearing to be jittery/stuttering while moving.

The stuttering is a lot more apparent if I force hard vertical synchronization or specify a capped frame rate limit using the SFML API, which I assume is because I've already implemented a fixed timestep and interpolation that might not work well with these limits.

The stuttering is hardly noticeable for me, but it's a lot more apparent for my friends with lower-end hardware, so I think I'm just doing things inefficiently.  Currently, I've turned off everything except for x movement for the player class to make the scope of the problem easier to manage. 

Game Loop:
void Application::initialize()
{
        videoMode.width = 1067;
        videoMode.height = 600;
        videoMode.bitsPerPixel = 32;
       
        dt = 1.0f / 60.0f;
        timeNow = gameClock.getElapsedTime().asSeconds();
        timeFrame = 0.0f;
        timeActual = 0.0f;
        accumulator = 0.0f;
       
        enableVSync = false;
        doForceFPS = false;
        forceFPS = 60;
}

int Application::run(int argc, char **argv)
{      
        ...

        pushWorld(new TownlevelWorld());
       
        while (rwin.isOpen())
        {              
                sf::Event event;
                while (rwin.pollEvent(event))
                {
                        cont_worlds.top()->input(event);
                        ...
                }

                timeNow = gameClock.getElapsedTime().asSeconds();
                timeFrame = timeNow - timeActual;
               
                if (timeFrame > 0.25f)
                        timeFrame = 0.25f;
               
                timeActual = timeNow;
                accumulator += timeFrame;
               
                while (accumulator >= dt)
                {
                        cont_worlds.top()->update(dt);
                        accumulator -= dt;
                }
               
                const float interpolation = accumulator / dt;

                rwin.clear();
                cont_worlds.top()->draw(rwin, interpolation);
                rwin.display();
        }
        release();
        return 0;
}

Player.cpp:
void Player::draw(sf::RenderWindow &rwin, float interp)
{
        rwin.draw(self);

        sf::Vector2f posInterp = pos;
       
        if (pos.x != lastPos.x)
                posInterp.x += interp;
        if (pos.y != lastPos.y)
                posInterp.y += interp;
       
        self.setPosition(posInterp.x, posInterp.y);
        lastPos = pos; 
}

void Player::update(float dt)
{      
        if (right == true && left == false)
        {
                xs += speed;
        }
       
        if (right == false && left == true)
        {
                xs -= speed;
        }

        if (!sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && !sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
        {
                right = false;
                left = false;

        }
       
        pos.x += clamp(xs, -6, 6);
        xs /= fric;
}
 

I'd appreciate any help to see if I'm doing things inefficiently, or what else might be causing the occasional stuttering.

2
Graphics / Failed to create texture, its internal size is too high
« on: February 08, 2013, 12:13:44 pm »
I decided to test my game on older hardware, and this issue was returned:

Code: [Select]
Failed to create texture, its internal size is too high
I noticed the documentation suggests using 512px wide textures for supporting older hardware.  I've started breaking up my giant textures into smaller, more manageable 512px wide textures, which is fine, but how could I make them seamlessly connect with each other?

Currently I have an std::map object that contains each "chunk" of the texture, and draws them side by side, which works just fine, except whenever I try to move them (there's a small gap in between each texture for a split second before they move).  I can fix this by offsetting each chunk by -1px, but then they don't tile properly.  Here's what my update method looks like:

Code: [Select]
for (int i = 0; i < spr_objs.size(); i++)
{
spr_objs[i].move(-(dt * 0.3f), 0);
}

Thanks for any help!

3
General / Compiling SFML 2.0 with Windows XP (Unsupported Compiler)
« on: December 22, 2012, 10:14:33 pm »
I'm using a Windows XP guest with VirtualBox on Arch Linux, but I don't think that's relevant because I got it working just fine on the same setup on my desktop.

Here's how I'm trying to compile:
Code: [Select]
cmake -G "MinGW Makefiles" .
Here's the output:
Code: [Select]
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of void*
-- Check size of void* - done
CMake Error at cmake/Config.make:62 (message):
 Unsupported compiler
Call Stack (most recent call first):
  CMakeLists.txt:20 (include)


-- Configuring incomplete, errors occurred!

How could I troubleshoot this?  C:\MinGW\bin exists in my $PATH variable, and typing this returns the expected result:
Code: [Select]
> g++
g++: fatal error: no input files
compilation terminated

Thanks for any help!

4
General / Fixed time step (now that GetFrameTime() has been removed)
« on: January 31, 2012, 11:12:44 am »
Currently I'm trying something like this:

Code: [Select]

const int gameTime = 10;
sf::Clock gameClock;

...

while (gameClock.GetElapsedTime().AsMilliseconds() > gameTime)
{
     gameClock.Restart();
     //update game
}


This doesn't quite work the same way as it did previously with GetFrameTime() in replace of the sf::Clock.  I'm having quite a bit of difficulty syncing up everything again after I updated to the newest SFML 2 build.

Would there be a better method for handling a fixed time step?

Thanks for any help!

5
General / Problems with building SFML 2.0 on Debian Sid
« on: January 02, 2012, 11:00:03 am »
I'm trying to build SFML 2.0 on Debian Sid.

Here are the errors that I'm getting:

Code: [Select]

tim@debian:~/Downloads/LaurentGomila-SFML-8868350$ make
[ 14%] Built target sfml-system
make[2]: *** No rule to make target `/usr/lib/x86_64-linux-gnu/libGL.so', needed by `lib/libsfml-window.so.2.0'.  Stop.
make[1]: *** [src/SFML/Window/CMakeFiles/sfml-window.dir/all] Error 2
make: *** [all] Error 2


Obviously I assume it has something to do with libGL, but I'm not entirely sure how I could go about resolving this issue.

What could any potential issues be?

6
SFML projects / Divided - My LD22 Entry
« on: December 22, 2011, 06:05:35 am »
Divided is a short puzzle platformer that was created in 3 days for the Ludum Dare 22 game jam.  

Download
Windows
Windows - Minimal
Linux
Source

Controls
Right and Left: Move
Up: Enter Doors
Space: Jump
Enter: Select
R: Reset Level

The game also supports gamepads!

If anyone does take the time to look at the source, I'm sure there are several poor practices, but I'd appreciate any pointers and critiques on what I could have done better.

Some of the game logic was also "hacked together," or implemented quickly without thinking about re-usability so that we could reach the deadline.

If the game crashes for you, try the "Minimal" version.

Here are some screenshots:


7
General / Optimizations?
« on: November 14, 2011, 08:38:13 am »
I'm curious about any steps I could take to to increase the efficiency and speed of my game.

Currently I have a vector for each set of objects I'd like to draw on the screen.  For example, coins, enemies, blocks, etc.  Here's an example for how I have things setup:
Code: [Select]

void WorldLevel::draw()
{
for (int bi = 0; bi < blocks.size(); bi++)
{
if (InCameraView(blocks[bi]))
{
App.Draw(blocks[bi]);
}
}
for (int ei = 0; ei < enemies.size(); ei++)
{
if (InCameraView(enemies[ei]))
{
enemies[ei].draw();
}
}
}

void WorldLevel::update()
{
for (int bi = 0; bi < blocks.size(); bi++)
{
if (InCameraView(blocks[bi]))
{
player.TouchGround(blocks[bi]);
for (int ei = 0; ei < enemies.size(); ei++)
{
enemies[ei].update();
enemies[ei].TouchGround(blocks[bi]);
}
}
}
}


I think the biggest sacrifice is looping through the blocks vector, because it's usually pretty large.  I also understand that it's probably bad practice to use nested for loops, but I'm not exactly sure how else to achieve what I'm trying to do.

I was thinking about making a second vector that contains all of the blocks that are on screen (blocks_drawable), and loop through that vector anytime I need the objects to interact with the blocks.  However, I assume I would still need to loop through the blocks to determine the blocks on screen, so I'm not too sure if there would be a noticeable difference in performance.

What could I do to make things run better?  The game feels very smooth whenever the blocks vector isn't too large, but things start to slow down whenever the vector becomes larger.
Thanks for any help!

8
Graphics / Inconsistent movement?
« on: November 05, 2011, 04:29:12 am »
Currently I reference the App.GetFrameTime() anytime I move a sprite around on the screen.  
App is an sf::RenderWindow object.

For moving on the x axis, I have a float that I append to x depending on the direction that the sprite is supposed to go.  It looks something like:
Code: [Select]

offset = App.GetFrameTime() * 0.25f;


And this works fine!  It seems to be consistent for all of the test cases.  However, currently for jumping I'm trying:

Code: [Select]

grav -= ((App.GetFrameTime() * 1.5f) + 0.5f) / factor;


Also, every iteration I add grav to y if you're not touching the ground.

This isn't very consistent, occasionally the character jumps very high as the App.GetFrameTime() is constantly changing.  Initially I was trying:
Code: [Select]

grav -= ((jMax * 3) + 0.5f) / factor;
//jMax = 1.3f;


Which worked fine for myself, but for other test cases the jump is very tiny.

I cap the FPS around 400 frames per second.  The game runs very smooth for me, but for some of my friends it runs around 100 FPS and the jumping is very tiny.  The x axis movement with the offset variable defined above seems to be fine though.

What could I do to possibly make it consistent for everyone?  Thanks for any help!

9
Graphics / HUD Concept? [Solved]
« on: October 29, 2011, 12:36:08 am »
If anyone is interested in a solution, I setup something like:

Code: [Select]

sf::View Camera;
sf::View HUD;
...

App.SetView(Camera);
App.Draw(...objects impacted by the camera);
...
App.SetView(HUD);
App.Draw(...objects not impacted by the camera);


------------------------------
Original Post:
------------------------------
Currently I'm caping the framerate with:

Code: [Select]

App.SetFramerateLimit(200);


I was really trying not to impose a limit, but it was proving much work to make everything consistent for everyone, even when using
Code: [Select]

float offset;
...
offset = App.GetFrameTime() * 0.05f;


Anyways, whenever I didn't have a framerate limit, it seems that the HUD stayed in place better.  Currently with the framerate limit, the HUD moves a little bit to the right or left whenever the character moves, or slightly up and down whenever the character jumps.  Here's what I'm currently using to keep it in position (just an example):

Code: [Select]

hud.SetPosition(Camera.GetCenter().x - 445, Camera.GetCenter().y - 295);


I also tried experimenting with setting the hud's position after the App.SetView(Camera); method, but the result is the same.

How do you guys like to ensure that your HUD doesn't move around?

Thanks for any help!

10
Graphics / Sprite collection implementation?
« on: October 27, 2011, 10:01:50 pm »
Currently I have a vector that contains all of Blocks to render on the screen, and another vector that contains all of the FloatRects for collision detection.  

I loop through each sprite in the block vector:

Code: [Select]

App.Draw(Blocks[i]);


And for collision, I loop through the FloatRects vector and check my collision logic against each part.

I don't plan on updating the ground or FloatRect vector after everything is generated, so I'm wondering if it's possible to make them into a collection so that I only need to draw one and check against one.  Essentially create a large image to draw, and create an obscure shape with the FloatRect.  

I'm not too sure about the FloatRect, because I assume the rectangle must be a rectangle.

I'm only interested in implementing this because occasionally my friends will fall through the ground, or the performance will get very slow occasionally.  I haven't encountered falling through the ground, but I assume it's because it hasn't reached that point in iteration just yet.

I was also thinking about looping through Blocks that are only in the view, but I'm not sure how to exclude blocks that aren't in the view.  I know how I can check to see if objects are viewable the player, but I'm not sure about removing them from the vector or excluding them from the loop.

Thanks for any help!

11
Graphics / sf::Texture.LoadFromMemory?
« on: October 26, 2011, 09:10:40 am »
Currently I'm using Bin2C to generate a (*.c) file containing all of the information that makes up my image.  

Here's what the generated file looks like:
Code: [Select]

static unsigned char test_png[] = {
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20,
0x08, 0x02, 0x00, 0x00, 0x00, 0xfc, 0x18, 0xed, 0xa3, 0x00, 0x00, 0x00,
0x01, 0x73, 0x52, 0x47, 0x42, 0x00, 0xae, 0xce, 0x1c, 0xe9, 0x00, 0x00,
0x00, 0x09, 0x70, 0x48, 0x59, 0x73, 0x00, 0x00, 0x0b, 0x13, 0x00, 0x00,
0x0b, 0x13, 0x01, 0x00, 0x9a, 0x9c, 0x18, 0x00, 0x00, 0x00, 0x07, 0x74,
0x49, 0x4d, 0x45, 0x07, 0xdb, 0x0a, 0x1a, 0x06, 0x2d, 0x30, 0xc3, 0x47,
0xff, 0xe7, 0x00, 0x00, 0x00, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f,
0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x00, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57,
0x81, 0x0e, 0x17, 0x00, 0x00, 0x02, 0x9f, 0x49, 0x44, 0x41, 0x54, 0x48,
0xc7, 0x8d, 0x56, 0x49, 0x72, 0xe4, 0x30, 0x0c, 0x03, 0xaa, 0xf4, 0xff,
0x4f, 0xe4, 0x3e, 0x2f, 0x24, 0x83, 0x39, 0x70, 0x11, 0xe5, 0xa5, 0x3b,
0x3e, 0x74, 0x62, 0x49, 0xe6, 0x02, 0x90, 0xa0, 0xf8, 0xef, 0xe7, 0x47,
0x02, 0x20, 0x90, 0x14, 0x04, 0x11, 0x14, 0x84, 0x78, 0x08, 0x8a, 0xa2,
0x20, 0x02, 0x22, 0x00, 0x42, 0x22, 0x08, 0x42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b, 0xdd, 0x46, 0x6f, 0x32, 0x4a, 0x76, 0xdf, 0x0d, 0x93, 0xed, 0x3d,
0x73, 0xd8, 0xd5, 0x9a, 0x92, 0x4d, 0x49, 0xe4, 0xa5, 0x67, 0xfa, 0x02,
0xc6, 0x90, 0xeb, 0xaf, 0x37, 0x21, 0xde, 0x68, 0xfe, 0x6b, 0x86, 0xcb,
0x5f, 0x3a, 0x59, 0xd7, 0x31, 0x5c, 0x99, 0xdd, 0xe7, 0xe2, 0x50, 0x6a,
0xed, 0x5b, 0x68, 0xee, 0xff, 0x07, 0xb7, 0x18, 0x41, 0x46, 0x68, 0x12,
0xa4, 0x87, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42,
0x60, 0x82,
};


I have a header file that contains:
Code: [Select]

static unsigned char *test_png;


Inside of my source file, I'm attempting with:
Code: [Select]

if (img_test.LoadFromMemory(&test_png, sizeof(test_png)))
{
     //oh no!
}


I'm compiling with:
Code: [Select]

g++ -o Testing test.c main.cpp -lsfml-graphics -lsfml-window


However, this message is returned:
Code: [Select]

Failed to load image from memory. Reason : Image not of any known type, or corrupt


I'm essentially trying to package the asset inside of my compiled binary.  I'm sure that I'm most likely using the methods or language conventions improperly.  I assume that the data I'm sending is not in a correct format for the LoadFromMemory method to understand, but I'm not exactly sure what I'm doing wrong.

Thanks for any help!

12
System / Callback a method inside of a class with sf::Thread?
« on: October 16, 2011, 01:30:13 am »
I've tried many different scenarios, but I can't seem to figure out.  Here's a basic example if what I'd like to do:

Code: [Select]

class Test
{
private:
ThreadHandle();
//
public:
Test();
void setup();
//
};


void Test::setup()
{
sf::Thread TestThread(&ThreadHandle);
TestThread.Launch();
}


I've also tried setting up the "TestThread" object in the header file, but it alerts me that "ThreadHandle" is not a data type.

Thanks for any help!

13
Audio / Music only plays if directly preceded by a loop? (SFML2)
« on: September 16, 2011, 09:32:30 pm »
I have this bit here:

Code: [Select]

sf::Music test;

if (!test.OpenFromFile("test.ogg"))
{
std::cout << "Oh No!" << std::endl;
}
elsae
{
test.Play();
}


Which doesn't play the audio!  However, if I append this right after "test.Play();"

Code: [Select]

for (;;);


The Music plays as expected.  I've also tried adding test.Play(); in the ::update(); method that's called every frame.

What could the issue be?  Thanks for any help!

14
General / SFML2 installation on Linux?
« on: September 16, 2011, 05:34:28 am »
I've moved the SFML directory inside of the "include" folder to /usr/include/c++/4.4, as well as all of the .a lib files into /usr/lib/gcc/i486-linux-gnu.  Are these locations the appropriate place for the files to reside?

Here's the bit that I'm testing:
Code: [Select]

#include "SFML/Graphics.hpp"

const int SCREEN_WIDTH = 550;
const int SCREEN_HEIGHT = 400;
const int SCREEN_BPP = 32;

sf::RenderWindow App;

int main(int argc, char** argv)
{
App.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP), "Testing!");

while (App.IsOpened())
{
sf::Event event;
while (App.PollEvent(event))
{
switch (event.Type)
{
case sf::Event::Closed:
App.Close();
break;
}
}
}
return EXIT_SUCCESS;
}


I'm compiling with:
Code: [Select]

g++ -o test test.cpp -lsfml-graphics -lsfml-window


This is what is returned:
Code: [Select]

/tmp/ccrxrxoF.o: In function `main':
test.cpp:(.text+0x87): undefined reference to `sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int)'
test.cpp:(.text+0xc3): undefined reference to `sf::Window::Create(sf::VideoMode, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, sf::ContextSettings const&)'
test.cpp:(.text+0x125): undefined reference to `sf::Window::Close()'
test.cpp:(.text+0x139): undefined reference to `sf::Window::PollEvent(sf::Event&)'
test.cpp:(.text+0x149): undefined reference to `sf::Window::IsOpened() const'
/tmp/ccrxrxoF.o: In function `__static_initialization_and_destruction_0(int, int)':
test.cpp:(.text+0x17c): undefined reference to `sf::RenderWindow::RenderWindow()'
test.cpp:(.text+0x181): undefined reference to `sf::RenderWindow::~RenderWindow()'
collect2: ld returned 1 exit status


What could the issue be?  Thanks for any help!

15
Graphics / Additional Windows?
« on: September 04, 2011, 03:40:13 am »
I have this bit here in a separate source file:
Code: [Select]

#include "SFML/Graphics.hpp"
#include "WindowTest.h"

const int SCREEN_WIDTH = 550;
const int SCREEN_HEIGHT = 400;
const int SCREEN_BPP = 32;

sf::RenderWindow Window;

int WindowTest()
{
Window.Create(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP), "LOL", !sf::Style::Resize | sf::Style::Close);

while (Window.IsOpened())
{
sf::Event event;
while (Window.PollEvent(event))
{
switch (event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
}
}
}

return EXIT_SUCCESS;
}


I include it's header file, and I call "WindowTest();" whenever I'd like to open it.  However, currently this doesn't work too well.  The window does open, but it's occasionally a little shaky whenever I move it around.  I also can't close the first window until I close this window, and the first window's "Close" button blinks a little bit too.

Should I handle the second window's logical in a separate thread?  Or is there a better method to have multiple windows?

Thanks for any help!

Pages: [1] 2