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

Pages: 1 [2] 3 4
16
General / Problems with building SFML 2.0 on Debian Sid
« on: January 02, 2012, 11:17:19 am »
Quote from: "Laurent"
Clear your CMake cache and retry.


Thanks for your reply!

However, I cleared the cache earlier, but the outcome was the same.  I just tried again, but I'm still experiencing the same problem.

17
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?

18
SFML projects / Divided - My LD22 Entry
« on: December 22, 2011, 08:48:11 am »
Quote from: "Richy19"
trying to build it as runnning it doesnt work.
I get this on the final build:

Any chance we could get a makefile for linux, or even better codeblocks project :D


Whoops, I forgot to mention that the Linux binary is 64bit (I assume that's the issue, or maybe I forgot to package a shared object!)

This Makfile should work.
Code: [Select]

CXX := g++

Divided: TinyXML AnimateSprite.o helper.o Assets
$(CXX) -o Divided main.cpp tinystr.o tinyxml.o tinyxmlerror.o tinyxmlparser.o AnimateSprite.o helper.o sfx_jump_ogg.o Door.cpp Player.cpp PlayerW.cpp SplashScreenWorld.cpp SettingsPanel.cpp MainMenuWorld.cpp LevelWorld.cpp EndingWorld.cpp CreditsWorld.cpp TextOverlay.cpp Spike.cpp Lever.cpp Block.cpp MovingBlock.cpp FallingBlock.cpp -lsfml-window -lsfml-graphics -lsfml-audio -lsfml-system

TinyXML: obj/xml/tinystr.cpp obj/xml/tinyxml.cpp obj/xml/tinyxmlerror.cpp obj/xml/tinyxmlparser.cpp
$(CXX) -o tinystr.o -c obj/xml/tinystr.cpp
$(CXX) -o tinyxml.o -c obj/xml/tinyxml.cpp
$(CXX) -o tinyxmlerror.o -c obj/xml/tinyxmlerror.cpp
$(CXX) -o tinyxmlparser.o -c obj/xml/tinyxmlparser.cpp

AnimateSprite.o: AnimateSprite.cpp
$(CXX) -o AnimateSprite.o -c AnimateSprite.cpp

helper.o: helper.cpp
$(CXX) -o helper.o -c helper.cpp

Assets: obj/sfx_jump_ogg.cpp
$(CXX) -o sfx_jump_ogg.o -c obj/sfx_jump_ogg.cpp


Quote from: "mentaman10"
Did you do fps-lock?
the game is about 50-70 precent CPU!!


Cool game.


Thanks!

I didn't implement an FPS lock, I'm not entirely sure of a reasonable famerate to cap to.  I assume 60 is good, but I'm not entirely sure.

What do you guys like to limit your framerate to?

19
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:


20
SFML projects / FlexWorld
« on: December 08, 2011, 09:29:19 am »
Wow, looks very interesting.  Good luck in getting adequate funds!

21
General / Optimizations?
« on: November 16, 2011, 08:02:17 am »
Quote from: "Tex Killer"
You are using pixel positions as matrix indexes...
Try it like this:


Thank you!  That's exactly what I was looking for, and it seems to be working well.  However, the framerate is significantly lower than it was before, but the newer method feels smoother than the previous method most of the time.

Should I go about my collision checking the same as I was before?  As in,

Code: [Select]

for (int bx1 = left; bx1 <= right; bx1++)
{
for (int by1 = top; by1 <= bottom; by1++)
{
player.TouchGround(blocks[bx1][by1]);
for (int ei = 0; ei < enemies.size(); ei++)
{
if (InCameraView(enemies[ei]))
{
enemies[ei].update();
enemies[ei].TouchGround(blocks[bx1][by1]);
}
}
}
}


It feels quite strange to be using two nested for loops.

22
General / Optimizations?
« on: November 16, 2011, 04:15:46 am »
Quote from: "Tex Killer"
In case of tile based sprites printed from a matrix, if you have fixed size tiles, you can know exactly where to begin and where to end printing.
Take the left border X position of your camera and divide by the tile size to get the X index of the first tile to print on the matrix. Divide the X position of your right border by the tile size and add 1 to make sure it goes past the screen, and you have the last X index you are going to print.

Same goes for Y.

Then you have just to iterate on these positions and print them.


Thanks for the reply!  I organized my blocks into testBlocks
  • [y] now, and I assumed that this loop would iterate through them:
Code: [Select]

std::map<int, std::map<int, sf::Sprite> > testBlocks;
...
for (int bx = CameraView.Left; bx < CameraView.Width; bx += 32)
{
for (int by = CameraView.Top; by < CameraView.Height; by += 36)
{
App.Draw(testBlocks[bx][by]);
}
}


The actual tile size is 16x18, however they're both scaled by a ratio of 2.  I've also tried

bx++;
by++;

As well as
bx += 16;
by += 18;

Initially I assumed the application would crash if I attempted to access a nonexistent index, but that doesn't seem to the the case.

I assume that I'm referring to nonexistent indexes in my std::map, but I'm not sure what I could do to refer to the appropriate ones.

23
General / Optimizations?
« on: November 15, 2011, 06:36:55 am »
Quote from: "Laurent"
You could use a higher-level structure to sort your blocks, like a quad-tree (Google it!).

It will allow you to quickly find blocks of interest (for drawing or collision tests) without iterating on all of them.


Quote from: "Groogy"
I wrote a little just about spatial partitioning here: http://www.sfml-dev.org/forum/viewtopic.php?p=35285#35285

(Where Quad-tree is an algorithm/data structure in)

Also found where I've discussed grid's which is a simpler and maybe more beginner friendly than Quadtrees. http://www.sfml-dev.org/forum/viewtopic.php?p=32767#32767


I've been searching for QuadTree techniques, trying to create my own implementation.  It certainly feels foreign not needing to loop through each individual object, so I'm sure that everything I've tried so far isn't an actual implementation.

Quote from: "slotdev"
I use a display list - simply, a list of things which I want displayed. Drawing my main game screen, which only has maybe 15 or 20 items at any one time, takes next to no time.


How do you decide what to include and exclude from the display list?

24
General / Sprite movement
« on: November 14, 2011, 09:32:44 am »
Instead of updating the sprite's position in your event logic, you could toggle a boolean and update the position of your sprite based on the boolean's value.  Here's an example:

Code: [Select]

bool right, left;
float x, y;


Handling input:
Code: [Select]

switch (event.Type)
{
case sf::Event::KeyPressed:
if (event.Key.Code == sf::Keyboard::Right)
{
right = true;
}
if (event.Key.Code == sf::Keyboard::Left)
{
left = true;
}
break;
case sf::Event::KeyReleased:
if (event.Key.Code == sf::Keyboard::Right)
{
right = false;
}
if (event.Key.Code == sf::Keyboard::Left)
{
left = false;
}
break;
}

Update loop:
Code: [Select]

sprite.SetPosition(x, y);
if (right == true && left == false)
{
x += offset;
}

if (right == false && left == true)
{
x -= offset;
}

25
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!

26
Graphics / Inconsistent movement?
« on: November 08, 2011, 07:10:05 pm »
Quote from: "P@u1"
You should use a fixed timestep.

I do it something like this:

Code: [Select]

const float UPDATE_INTERVAL = 10f; //10ms -> 100 ticks per second

float restTime = 0f;

while(app.IsOpened())
{
    restTime += app.GetFrameTime();
    while(restTime >= UPDATE_INTERVAL)
    {
         restTime -= UPDATE_INTERVAL;
         Update(UPDATE_INTERVAL); //here you calculate the offset and gravity and so on with a fixed timestep.
    }
    Draw();
}


The problem might be if you have functions which are proportional to time^2 and not to time then the interval matters and depending on the pc the interval can change. So you just need to set the update interval to a fixed time step (I usually do 100 ticks per second, you can adjust it to your needs).


Thank you!  That's exactly what I was looking for, it seems to work well for each machine that I've tested.

27
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!

28
Graphics / HUD Concept? [Solved]
« on: October 29, 2011, 01:14:03 am »
Quote from: "G."
I don't know what's the purpose of your "offset", neither why the framerate limit would matter when drawing the HUD.

Draw your HUD on another view, which you will never move.


Thanks for the response!
I just mentioned that it seemed for the hud object to move around a little bit whenever the framerate limit was specified.

Currently I use App.SetView for my Camera view, so I assume that I wouldn't be able to call App.SetView for a separate view as well.  How could I setup the second HUD view?

In my mind it feels that the view will be outside of the the camera view, so it won't be visible.

29
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!

30
Graphics / Sprite collection implementation?
« on: October 29, 2011, 12:30:26 am »
Quote from: "julen26"
You could create a new custom class containing a SFML sprite and one rectangle. And update both of them at the same time, even better, you can update the rectangle using sprite class methods for getting coords.

For checking to exclude some blocks from the vector, you could calculate the distance to your player, or check if they are inside the view. But, anyway you have to check ALL blocks.

But if you do a collision check against every block in your world, you'll get a slow program. So you need to priorize and partition the world space. Use an orthogonal 2D grid or BSP trees. (http://en.wikipedia.org/wiki/Binary_space_partitioning)

Now I haven't time, but maybe I'll do a little example later.

Let your imagination fly..


Yup, that's actually what I used to do.  I check if there are objects outside of my CameraView rectangle, and if they are, don't draw them.  I think I've noticed a slight performance increase, I suppose it doesn't take long to loop through the for loop, only drawing and updating the objects requires more time.

Thanks!

Pages: 1 [2] 3 4