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

Pages: 1 [2]
16
SFML projects / The best SFML games
« on: July 13, 2013, 06:59:00 pm »
Hi all, just wondering if anyone can point me to a few of the best of the best SFML games out there. It'd be cool to see what is possible with the library. Unfortunately, it's hard to know what games are made with what tools. So what do you think are a few of the best games made with SFML?

17
SFML projects / Re: 2D platformer using SFML 2.0 and Box2D 2.2.1
« on: July 12, 2013, 11:33:40 pm »
Since you're new to C++, did you avoid using classes/object orientation? How did you handle collision detection? This is pretty impressive for a first timer, how long did it take you?

18
General / Re: General C++ question: Defining a struct within a class
« on: July 11, 2013, 10:49:50 am »
Hah, you're right...actually it works if I move the function below the private: declarations...unbelievable.

19
General / Re: General C++ question: Defining a struct within a class
« on: July 11, 2013, 10:43:01 am »
I would think there's a way to keep it a private member. I'm getting confused now as to what's the type definition and where's the variable definition...I will read up on the basics of defining structs I guess. They have always confused me as I've seen them declared with typedef and sometimes they are not. Now with the extra layer of being within a class I'm extra confused.

Anyways I think I'm getting closer:

Camera.h
class Camera
{
public:
        Camera();
        ~Camera();

        void setProperties(Camera::TCameraProperties* cameraProperties); // Still complains saying Camera has no member TCameraProperties
       

private:

        struct TCameraProperties;
        TCameraProperties* m_CameraProperties;

        sf::View m_View;

};

 

Moving the struct defs to public doesn't make a difference.

20
General / Re: General C++ question: Defining a struct within a class
« on: July 11, 2013, 09:52:12 am »

I think I figured out how to define it:

I have it defined as private in the Camera headerfile like so:
Code: [Select]
struct m_CameraProperties;
Then in the .cpp file I can define it like so:
Code: [Select]
struct Camera::m_CameraProperties{

bool IsYLocked;
bool IsXLocked;
float YMinimum;
float XMinimum;
float YMaximum;
float YMinimum;

};
Still trying to figure out how to declare it as a parameter in a Camera member function...


21
Graphics / Re: View wont move.
« on: July 11, 2013, 09:36:12 am »
Heh, sorry. I was just looking at the API documentation for sf::View, not the tutorial. Guess I should look there more often.

In any case, SFML is the easiest library I've ever used. The tutorials and documentation are super easy to read.

22
General / General C++ question: Defining a struct within a class
« on: July 11, 2013, 09:00:54 am »
Hi all, this is a general question about C++. I'm trying to make a Camera class which will contain 2 private member values: an sf::View and a struct containing various camera properties. So basically my idea is, outside this class, you will be able to call Camera.setProperties(<STRUCT CONTAINING DESIRED PROPERTIES>) and that will effectively set up the entire Camera class. So in Camera.h I have my private struct m_CameraProperties. In Camera.cpp I have the definition of that struct - struct Camera::m_CameraProperties{<stuff>};

But when I try to declare my setProperties(<camera properties struct>) it's not letting me use the struct in here. Any ideas? I know I could just ditch a struct and use several variables but I'd like to be able to pass a neat little structure instead of a bunch of random variables. Thanks for any help.

23
Graphics / Re: View wont move.
« on: July 11, 2013, 07:51:14 am »
I figured out that you have to call setView on your window (EACH TIME YOU CHANGE THE VIEW LOCATION) after calling setCenter on the view. After reading the documentation I was under the impression you just had to set the view to your window and any subsequent changes to it would automatically be binded to the window. In any case, this is what you have to do each frame:

m_View.setCenter(<vector location>)
mWindow.setView(m_View)

Let me know if that works for you.

24
Graphics / Re: View wont move.
« on: July 10, 2013, 11:50:29 pm »
I was actually working on the same problem with my code, planned to get back at it tonight. I'll let you know if I figure anything out. I've never had a working view before though, this is my first shot at it. It just seemed like setCenter wasn't doing anything for me.

25
Graphics / Re: sf::view is incredibly slow?
« on: July 10, 2013, 11:43:08 am »
Yes I do, I take it that's the issue? Accessing something from the Video Card?

26
Graphics / Re: sf::view is incredibly slow?
« on: July 10, 2013, 10:55:19 am »
Sorry, I'm a bit impatient most of the time. I've found that for some reason the line where I call setCenter:

m_View.setCenter(mWorld.getCharacter().getCenter());

Is very very slow because of the mWorld.getCharacter() call. This member function I made returns an object of class Character. If I replace it with a simple sf::Vector2f it goes back to being very fast. I guess I'm not quite smart enough to know why calling getCharacter().getCenter() is so slow but I think it's because it has to copy a large object anonymously here. Anyways, now the camera still does not track the player but I think that's something I can figure out. Thanks for the help!

27
Graphics / Re: sf::view is incredibly slow?
« on: July 10, 2013, 10:17:01 am »
Sure, it is very simple:

In the constructor for my App class:

   // Initialize the view
   m_View.reset(sf::FloatRect(0,0,WINDOW_WIDTH,WINDOW_HEIGHT));
   m_View.setViewport(sf::FloatRect(0,0,1,1)); // Not sure if this is necessary
        mWindow.setView(m_View);

In the App.run() function (which updates at a 60Hz rate):

//
//Update world object positions before this...
//

m_View.setCenter(mWorld.getCharacter().getCenter());

//As you can imagine, this sets the view center to the player center.

I have found that the setCenter function is causing all the slowdown. But I'm not sure why. Maybe it's because I'm running in windowed mode? I've lowered the resolution but its still slow as can be. Maybe the setCenter function is just slow and not meant or able to be updated at a 60Hz rate? I'll keep playing with it...

Also, it doesn't seem to be centering the camera on the player. Maybe I'm missing something with the way this view is set up.

28
Graphics / sf::view is incredibly slow?
« on: July 10, 2013, 06:54:25 am »
Hi all, I am working on the next big thing and everything was running pretty smoothly with no lag until I decided to attach an sf::view to the renderwindow. Basically the goal is to make the camera stay on the player (2d side scroller style). So the view center is updated with the player center every frame. Unfortunately this is unbelievably horribly slow. I went from my standard 60fps to probably around 1...no idea how something like this could happen. Is there something about the View class that I didn't catch? Do I need to go about moving the camera in another way - using my own class? Thanks for any help!

Pages: 1 [2]
anything