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

Pages: 1 2 [3] 4 5 6
31
SFML projects / Airport
« on: October 19, 2011, 12:21:38 am »
Quote from: "Naufr4g0"
I also think that the game is very fun and original!


Maybe not as original as you think have you seen this?

Been playing it for a few years now

32
SFML projects / Project Black Sun - commercial game - demo available
« on: October 19, 2011, 12:17:26 am »
Nice trailer. Did anyone else see the Bellsprout at 1:19?

33
SFML projects / Chesster [SFML Puzzle Game]
« on: October 19, 2011, 12:15:08 am »
I agree that there should be gameplay in the trailer video. But as I saw it, it was a new idea and that maybe there isn't enough to show yet. As for being profitable, I don't really care if you make money or not from it, I just wanna play it because I love chess and puzzle games :)

34
Graphics / [SOLVED] Static sf::Image and sf::Sprite?
« on: October 19, 2011, 12:11:57 am »
Quote from: "julen26"
You also should declare the static members outside the class.

Foo.cpp
Code: [Select]
sf::Image Foo::image;
sf::Sprite Foo::sprite;


No, they should be declared inside the class in the interface file Foo.h

Code: [Select]
class Foo {
private:
   static sf::Image image;
   static sf::Sprite sprite;
}


and then defined (and initialised via default ctors) in the implementation file Foo.cpp

Code: [Select]
sf::Image Foo::image;
sf::Sprite Foo::sprite;


Declaration is where the name and type of a something is made known to the compiler.

Definition (for objects) is where memory is set aside for the variable.

35
SFML projects / Yellow Snake - w/Source (Updated 10/21)
« on: October 18, 2011, 11:40:20 pm »
Yeah, entirely possible. Probably get someone who knows a bit more than me to clarify :)

36
General / deleting sf::Texture* - I must be doing it really wrong
« on: October 18, 2011, 11:22:28 pm »
Quote from: "unranked86"
Maybe I am wrong, but your "temp" sf::Texture goes out of scope, doesn't it ? When that happens the sf::Texture* objects in your map are pointing to non-existent objects. And then you iterate through the map and try to delete an invalid pointer.


No, temp is a pointer to sf::Texture which does go out of scope, however, the actual texture it's pointing to is created on the heap and not the stack and so can't go out of scope seeing as it doesn't live in any scope in the first place.

One problem with the original code that might cause a memory leak is this


Code: [Select]
if( temp->LoadFromFile(fileName) == false )
   return false;


If LoadFromFile returns false, then you exit the current function without deleting the memory you allocated with temp. You should change it to

Code: [Select]
if( temp->LoadFromFile(fileName) == false ) {
   delete temp;
   return false;
}


Or just avoid using pointers as Nexus said :)

37
General discussions / SFML 2 for OS X comes true!
« on: October 18, 2011, 11:10:07 pm »
I think if the option has a red background, it means you should press configure again.

38
SFML projects / Chesster [SFML Puzzle Game]
« on: October 18, 2011, 11:30:53 am »
iOS is fine I guess because I have an iPhone/iPad too! Oh yeah, make sure you develop for iPad, much better for games, the phone screen is way too small to do anything funky.(See world of goo :P)

39
SFML projects / ParabolaEngine - 2D Game Framework
« on: October 18, 2011, 11:29:11 am »
Excellent, I was just making a game engine because I couldn't find anything I liked. However, your library looks quite promising and will save me a lot of effort (I'm just a hobbyist and really don't have too much time to spend on developing stuffs :) ). Will you put it on github? downloading archive from mediafire made me a sad panda.

40
SFML projects / Yellow Snake - w/Source (Updated 10/21)
« on: October 18, 2011, 11:26:54 am »
Quote from: "Nexus"
I would even say the best approach is to keep it as local as possible, i.e. inside the loop. Then it is clear where the variable is used, code becomes more readable, and it can not happen that it is accidentally accessed outside the loop.

The construction and destruction of a sf::Event requires no time, as stated above it is a POD type.

...

As already mentioned, you should always declare variables as local and as late as possible, except if there is a good reason not to do so :)


Nexus is right. Consider it like this

Code: [Select]
void SomeFunction () {

some code here

SomeType temporaryObject;

for(int i = 1; i <= n; i++ ) {
    temporaryObject = some value;
    more code
}

some more code here
}



In this snippet, temporaryObject is constructed outside the loop and reused. This results in

1 construction
1 desctruction
n assignments

Furthermore, temporaryObject exists in the bit of code "some more code here". This is what Nexus meant by
Quote
Then it is clear where the variable is used, code becomes more readable, and it can not happen that it is accidentally accessed outside the loop.


Compare to this

Code: [Select]
void SomeFunction () {

some code here



for(int i = 1; i <= n; i++ ) {
    SomeType temporaryObject(some value);
    more code
}

some more code here
}


In this snippet, temporaryObject exists only in the scope each iterate of the loop. This results in

n constructions
n destructions.

So it's really a toss up between which takes longer, construction/destruction, or assignments. Seeing as sf::Event is a POD type, it'll be faster to use the second option, and again it makes your code a lot cleaner, and easier to read.

41
SFML projects / ParabolaEngine - 2D Game Framework
« on: October 18, 2011, 02:22:27 am »
Why not open source? Can you compile for mac?

42
SFML projects / Chesster [SFML Puzzle Game]
« on: October 18, 2011, 02:19:30 am »
Hey, I just watched the teaser. Very nice graphics and immersive music. Any chance it will be cross platform? I use OS X :)

43
General discussions / SFML 2 for OS X comes true!
« on: October 18, 2011, 01:50:34 am »
Quote from: "Hiura"
Quote
I am using the Xcode 4 templates.
Which one ? Not the SFML-ones I assume. At least your project doesn't look like you use them.


Yeah, does not look like he's using the ones you made. Looks like he forgot to install the debug libraries as he has the static ones there alright.

44
General discussions / FPS calculations with SFML2.0
« on: October 18, 2011, 01:48:05 am »
Quote from: "Groogy"
Yeah? Because a frame took pretty much time. If we reset it to 0 then we will start skipping seconds. Meaning that if we have 20 FPS and it took 1200 ms( So the last frame was pretty heavy ) and we reset it to zero, we will have somehow magically gained 1/5th performance from nowhere and get 20 FPS again next "second" when we should have only had 16 FPS!

Trust me, removing a second instead of resetting is the accurate way.

EDIT: Why that last frame was "extra" heavy can be anything from windows thread scheduling screwing you over or special case being handled like a trigger being activated. And since this is handled with a >= operator it will work even if that happens every second( that we reach over 1000 ) because it will be invoked some frames earlier each second iteration.


Groogy is right. Although your code might be a bit hard to understand for the OP considering he was struggling so badly with his own attempt.

@OP, to see why your code outputs only 0 or 1, just step through it line by line.

Quote
Code: [Select]

Code:
1inline unsigned int GetFrameRate(void)
2   {
3      static unsigned int frameCounter = 0, fps = 0;
4      static float nextSecond = 0.0f, prevSecond = 0.0f;
5      frameCounter++;
6      nextSecond += window.GetFrameTime() * .001f;
7      std::cout << nextSecond << std::endl;
8
9      if(nextSecond - prevSecond > 1.0f)
10      {
11         prevSecond = nextSecond;
12         fps = frameCounter;
13         frameCounter = 0;
14      }
15      return fps;
16   }


I numbered your lines so I can refer to them. Here is what happens in your code.

Line 3 - fps = 0, frameCounter = 0
Line 5 - fps = 0, frameCounter =1
Line 12 - fps = 0 or 1, frameCounter = 1
Line 15 - return fps (which is 0 or 1)

Also, did you actually make any changes between your two posts? I can't see any.

I think the main problem is that you're reassigning frameCounter to 0 each time you call the function

45
Window / What's wrong with frame time in SFML 2?
« on: October 16, 2011, 11:13:53 pm »
I'll just add to the FPS thing. GetFrameTime returns time in milliseconds as an integer so converting it to a float isn't going to do anything

Code: [Select]
printf("FPS: %f FRAMETIME: %f\n", (float)(1.f / window.GetFrameTime()), (float)(window.GetFrameTime()));

that's why it's printing out with .0000000.

With 60 FPS, we expect 16.6666666... milliseconds per frame so that is consistent with your output values 16/17 :)

Pages: 1 2 [3] 4 5 6