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

Pages: [1] 2 3
1
General / Re: the coordinate system in SFML - Help needed!!
« on: February 11, 2013, 05:05:44 pm »
ok so normally what i do is set the origin to the center of the object and i usually use getLocalBounds() because i havent yet applied any transformations. is that the correct approach?

so what your saying is that if my sprite is rotated, then getGlobalBounds() will return a rotated rectangle of some sort?

and what are the different coordinate systems. that bit was confusing me too.

2
General / the coordinate system in SFML - Help needed!!
« on: February 06, 2013, 10:57:04 pm »
ok so i have a general question about the coordinate system in SFML 2.

i understand the basics (such as the inverted y-axis).

i have read the documentation.

so i have randomly used getLocalBounds() and getGlobalBounds() mainly for setting the origin of a Sprite at its center. Sometimes i experience weird behaviour and so i really want to know what exactly the two aforementioned functions do, and how they relate to the coordinate system.

i understand there are different types of coordinates (global and world coordinates i believe?). can someone briefly describe what exactly they are because i cant seem to understand how sprite position works in terms of coordinates and pixels and screen height/width.

if someone could clarify these few things i would feel much more at ease working with a window and positioning things.

3
General / Re: Having issues with animation speed.
« on: December 16, 2012, 02:12:48 pm »
ok yes. then i will use your first mentioned method for sure. this makes a lot more sense now.

thanks so much :P

4
General / Re: Having issues with animation speed.
« on: December 16, 2012, 07:11:17 am »
ok that makes a lot more sense and its much clearer now. the handleEvent function seems like a great idea. and one thing i was wondering. the handleEvent sets the flag to true (e.g. setting isFading to true) so would it be appropriate to say that the FadeAnimation class sets isFading to false? or should handleEvent do that? what i have right now is my FadeAnimation class will fade in and out and then set the "active" boolean to false. is that alrite? and now ill just create a handleEvent that just handles flags.

also in your second recommendation where i keep the single update function. i didnt quite understand what you meant. if i keep my one update function and pass it something like an isEvent parameter, should i keep the update function located in the while(pollEvent) loop? and should i change my loop to while(pollEvent || advancing time)? i didnt quite understand the 2nd approach but for now i will try the handleEvent function.

5
General / Re: Having issues with animation speed.
« on: December 12, 2012, 01:33:51 am »
yes i am using the time elapsed per frame to change my alpha so thats fine. but if i only update outside my event loop, then say when a bunch of keys are pressed, my program will enter the
while(Window.pollEvent)
loop and it will keep looping until all those events are popped from the event stack. so if i dont have update inside my event loop, (and my update takes an event and sees whether anything needs to be done), then wont the events that are popped be lost? or am i misunderstanding? and ofcourse the reason i need my update outside is obvious. if its only inside the event loop then if no events are happening it will never update.

6
General / [SOLVED]Having issues with animation speed.
« on: December 11, 2012, 04:59:34 am »
I have a fade animation and some shape movement on the screen. the enter key causes the screen to fade out and in. i noticed that if i press the enter key while moving my mouse in the window, the fade animation happens faster.

here is my main loop:

while(Window.isOpen()){
    while(Window.pollEvent(ScreenManager::getInstance().event)){
      if(ScreenManager::getInstance().event.type == sf::Event::Closed)
        Window.close();
      if(ScreenManager::getInstance().event.key.code == sf::Keyboard::Escape)
        Window.close();
      else
        ScreenManager::getInstance().update(ScreenManager::getInstance().event, Window);
    }//end of while Poll event
   
    Window.clear(sf::Color(0, 0, 0));
    ScreenManager::getInstance().update(ScreenManager::getInstance().event, Window);
    ScreenManager::getInstance().draw(Window);
    Window.display();
    ScreenManager::getInstance().timeBetwFrame = clock.restart(); //records time between frame
  }//end of while isOpen

as you probably saw, i call my update function twice, once in the event loop and again in the while(Window is open) loop. the reason for this is this: if the user presses enter and then does nothing after that, i want the window to do the fade animation. however if i have update only in the event loop, then it wont call update since after pressing enter, there are no more events to pop so it wont even be in the event loop. and if update is only outside the event loop, then if an event happens, i wont call update until all events are popped and im outside the event loop. so i have a call to update twice. now you may say that in my event loop, i should say
if(sf::Event::isKeyPressed) //call update function
however this still isnt that great of a solution.

my update function does everything for me: input handling, window switching, animation, etc etc. but after one event (say pressing enter) to actually completely do the whole animation, update has to be called a few times since every frame, i change the alpha value by a bit (for fade animation). so i think the two calls to the update function makes the fade animation speed up if i move my mouse when pressing enter since many events are happening so its calling udpate once in the event loop and once in the while(isOpen) loop.

i cant think of any solution to this problem that works with the way i have set up my program. can anyone help me out with this issue please? thanks :D

7
Graphics / Re: can sf::Text have words that each have a different color?
« on: December 08, 2012, 11:01:53 pm »
i see. thats an interesting way of doing things. thanks for all the help

8
Graphics / Re: sf::Text Help with alignment!!
« on: December 08, 2012, 10:59:36 pm »
holy 50 classes!? right now i only have about 7 but i absolutely understand why its important to split tasks. it does make it a lot easier in the long run. but one more question. how exactly do you manage editing many classes? and i assume you have a makefile that you use to compile everything right? i tried creating a makefile and it works, but not like its supposed to. a makefile is supposed to compile only the recently changed files but my makefile compiles all files all the time no matter what.

but i did split everything up. i have a few directories such as Headers, Source, Images, Fonts

9
Graphics / Re: sf::Text Help with alignment!!
« on: December 08, 2012, 06:08:47 am »
and for animations (such as choosing menu options with arrow keys and doing some animations when pressing arrow keys) should i just keep creating classes that inherit from my Animation class, or should i incorporate it into another class (e.g. coding the animation of choosing a menu option in the MenuScreen class)? some advice would be great :)

10
Graphics / Re: sf::Text Help with alignment!!
« on: December 08, 2012, 05:42:21 am »
like for example, for the MenuItem object, i would need to create another class and etc. etc. im finding it hard to decide whether to split a task up into a different thing or just do it in the same cpp file.

11
Graphics / Re: sf::Text Help with alignment!!
« on: December 08, 2012, 05:41:17 am »
hmm. i see thats a cool approach. but im being over whelmed with all the classes and headers. for a simple project, how many headers/source files should there be on average? i already have 9. ScreenManager, InputManager, TitleScreen, SplashScreen, Animation, FadeAnimation, GameScreen, MenuScreen and main. am i on the right track in terms of splitting up code into files?

12
Graphics / Re: can sf::Text have words that each have a different color?
« on: December 08, 2012, 05:13:13 am »
oh i see. so wrapping sf::Text is the best option. well i guess itll be a bit of work but i only have a few words that have different colors so far so ill just create multiple sf::Texts each with a different color.

13
the subject says the question. like for example, can i have the words "New Game" but New is red and Game is blue? or do i need to make two different sf::Texts?

14
Graphics / sf::Text Help with alignment!!
« on: December 04, 2012, 08:43:40 pm »
i want to create an sf::Text which has a few words of text in the middle of the screen and right below that more words of text.

e.g.
           New Game
           Exit

something like that. do i need 2 sf::Texts? or is there a way to do it with one sf::Text?


15
General / Re: Help getting started on a specific type of menuscreen
« on: December 03, 2012, 05:05:26 am »
alrite thanks i will try and ask Ve for some tips

Pages: [1] 2 3