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

Pages: 1 [2]
16
Graphics / Create a line segment shape in sfml 2.0?
« on: January 18, 2012, 02:55:57 am »
Just upgraded to sfml 2.0 before I got too far in my project. I was updating my debug draw class for box 2d to match the new API when I noticed there is no line segment shape in 2.0. Should I just use a really skinny rectangle? :)

17
Graphics / Release SF::image resource
« on: October 04, 2011, 04:48:29 am »
PS : I think I may possibly be over engineering this :)

18
Graphics / Release SF::image resource
« on: October 04, 2011, 04:46:42 am »
Is their a way to release an sf::image without deleting it. Also without modifying the sfml source..

I'm trying to put together a resource manager that can cache certain resources depending on the game state and quickly load and release them. but I have my image resource inherit from sf::image and dont really see a public function that would allow that.

the only thing I can think of would be to have a sf::image member in my resource class like so...

Code: [Select]

class myImageResource{
    private:
        sf::image * mySFImage;
        std::string myFileName;
    public:

        myImageResource(std::string theFileName):
            myFileName(theFileName)
            mySFImage(new sf::image)   //<--- not really sure if thats legal but you get the idea...

        void Load(){
             mySFImage->LoadFromFile(mFileName
        }
       
        void Release(){
            delete mySFImage;
        }

};


this is just an example but it already feels hacky and unsafe. I dont want to have to create and delete the sf::image every time ya know? I really want the resource to inherit from sf::image to make things streamlined.

any thoughts, comments?

19
General discussions / Who Are You? (the obligatory interview thread)
« on: September 10, 2011, 03:33:23 am »
Yeah Its not so bad if you plan on making some simple GUI programs.. granted its not great either.  Games though... thats outta the question. Possible but the language kinda fights you the whole way lol... learned the hard way but I still learned from it... here I am right?

20
General discussions / Who Are You? (the obligatory interview thread)
« on: September 09, 2011, 03:22:21 am »
Hey there cool thread.  I'm 24 and live in upstate New York (not many yankies on the thread it seems lol) I've been interested in computers since I was about 10 when my dad brought home an old computer that used the old 8 inch floppy disks to play games. since then i was hooked. Always interested in learning about electronics and programming.

I started programming around 16 when i got a copy of visual basic 4.0. wrote a couple simple games and got my feet wet. Also got real into music, songwriting and guitar around the same time. Didn't do much anything else with programming for a few years. Finished high school and went to a technical school for electronics.

Started working at a company that builds mass spectrometers and gas chromatographs working in the repair department. Was in a rock band for about a year or 2 playing gigs in my area. Made some money had some fun and some crazy parties. Got into music recording with Reaper (a DAW like Pro tools)

Then my daughter was born about a year and a half ago. Didn't have much time for the band so In my spare time when the baby was asleep i figured I'd try my hand at some C++ just for kicks.

Didn't realize I would end up diving in head first and absorbing anything i could. looked at a couple different libraries and SFML caught my eye. It's taught me a TON about C++ and Programming and general. Just looking at Laurents code and implementation has helped me immensly.

Lately I've been working on a little side scroller (think Zombie Smashers with guns) Its been fun for sure (after several complete engine re-writes) although I think I might be a programming addict now lol...

21
General discussions / wxSFMLcanvas with sizers problem
« on: September 09, 2011, 02:58:13 am »
Same guy different user name. Stupidly used my other account that I accidently used my email name for lol. (Damn auto-fill ; no spam please)

Heres a pic of the problem I'm experiencing if its any help.
https://lh3.googleusercontent.com/-coeV0ZFzHoM/TmljFdLUlkI/AAAAAAAAABI/mMBl0OeS08I/wxSFMLCanvas%252520Problem.png

once again I know this is more a wxWidgets problem but I'm sure somebody out there on this forum must have run into this before. At least I hope so cause this is driving me absolutely nuts...

thanks!

22
Graphics / Get rectangle of a sprite or image
« on: April 27, 2011, 05:49:22 am »
Thank you so much. sorry for the delayed response. I did not know about sf::floatrect, that is exactly what i needed. Still not working yet but its something simple in my code that I'm not doing I think. I've got past the hard part. Thanks again Laurent.

P.S
It amazes me how many questions are answered by the Developer of this software. I've learned a ton about C++ and programming in general with SFML. Keep up the great work!

23
Graphics / Get rectangle of a sprite or image
« on: April 25, 2011, 03:37:21 am »
Just wondering if there was a function like sprite.getrect or image.getrect. similar to the method a view has. Well, I know there is no function but I guess is there a simple implementation? I'm trying to set a boundary for my camera by using the limits of a large level background sprite.

Isn't a sprite just a rectangle with an image?

heres what I've been trying to do currently with little success:

Pseudo code:

Here I try to create my own rectangle from the dimensions of a sprite. It will not compile though and says there is no matching function for call to sf::shape::rectangle. I assume its because an sf::shape is not at all an sf::rect.
Code: [Select]
Engine_Class{
    sf::Rect <float> CameraBounds = sf::Shape::Rectangle(0,sprite_width,0,sprite_height);  
    Cam1.SetBounds(CameraBounds);
}



This next part should (theoretically) work if I could just come up with a rectangle lol!
Code: [Select]

Camera_Class{
    sf::Rect <float> myBoundary;
   
    void Camera::SetBounds(sf::Rect <float> CameraBounds){
        myBoundary = CameraBounds;
    }

    bool Camera::Within_Bounds(){

        if (ViewPort.GetRect().Left < myBoundary.Left) return false;
        if (ViewPort.GetRect().Right > myBoundary.Right) return false;
        if (ViewPort.GetRect().Top < myBoundary.Top) return false;
        if (ViewPort.GetRect().Bottom > myBoundary.Bottom) return false;

        return true;
    }

}


any suggestions/thoughts/advice?

24
Graphics / sprite.move makes sprite disappear
« on: April 11, 2011, 01:13:12 am »
Thanks alot for the input guys. I've now set a framerate limit on the window at 60 and am multiplying my movement rate by the frame time and all is working great.

25
Graphics / sprite.move makes sprite disappear
« on: April 09, 2011, 02:22:47 am »
Oh Yeah. Your right; I'm not at all, thats exactly whats happening. I'll have to look into that more and mess around with my  implementation.
(I'm new to c++ and sfml so I've just been playing with some basic stuff)

Thanks alot Wizzard!

26
Graphics / sprite.move makes sprite disappear
« on: April 08, 2011, 02:55:19 am »
So i seem to be missing something with the sprite.move function. whenever i use the move function and then try to draw the sprite... nothing happens. If i use set position and then draw it appears no problem.

There are 2 classes; engine and object. Engine has the renderwindow, Object array element GameObject[0] has the sprite.

assume the sprite has already initially been drawn at its start location.

EVENT HANDLER
Code: [Select]

void Engine::EventHandler(){
    GameWindow.GetEvent(Event);
    if (Event.Type == sf::Event::KeyPressed){
        switch (Event.Key.Code) {

            case sf::Key::Right:
                GameObject[0].Move(6);
                break;
            case sf::Key::Return:
                GameObject[0].Sprite.SetPosition(200,200);
                break;
            case sf::Key::Space:
                GameWindow.Draw(GameObject[0].Sprite);
                GameWindow.Display();
                break;


OBJECT MOVE FUNCTION
Code: [Select]
bool Object::Move(char Direction){
    //direction 6 == right
    if (Direction == 6)    Sprite.Move(10,0);


}

[/b]

27
Graphics / Noob: pass &RenderWindow to constructor. Set as Public v
« on: March 26, 2011, 03:28:04 am »
So basically I'm trying to pass a reference to an sf::renderwindow to the class 'game_object' and then set that as a public referenced object within the class itself.

That way any of Game_objects members can draw to that window without the reference being explicitly passed to the member itself (thats no problem just seems inefficient).

Heres a snippet of what I'm trying to do.

Class Header
Code: [Select]
class Game_Object {
    public:

        // constructor / destructor
        Game_Object(sf::RenderWindow &Window);
        virtual ~Game_Object();
 
        //{ SFML stuff
        sf::RenderWindow Draw_target;
        sf::Sprite Sprite

};


.cpp Constructor

Code: [Select]
Game_Object::Game_Object(sf::RenderWindow &Window){
    Draw_target = &Window;
}


Main
Code: [Select]
int main{
   sf::RenderWindow GameWindow;
   Game::Object Ship(GameWindow);
}



I've tried making 'draw_target' a pointer and using the '->' operator to access the 'draw' member of the render window. But the compiler didn't like that. Didn't seem right to me either. I mean its a pointer TO an object not an object itself right?

So how is this normally done if at all?

Pages: 1 [2]