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.


Topics - supdawg

Pages: [1]
1
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.

2
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

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

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


5
General / [SOLVED] Help getting started on a specific type of menuscreen
« on: December 02, 2012, 06:51:30 am »
I want to create a menu screen with the same animations in this video



can anyone help me get started and give me some hints on how to do the black rectangle animation?

and also, i want there to be rain falling in my menuscreen. i was thinking of creating rain with the help of box2D and sfml graphics. someone please kindly direct me or give me some hints as i really have no idea how to get started on this.

6
General / Pressing Enter causes two screen switches instead of 1!
« on: November 28, 2012, 06:26:59 am »
This is my event loop.
while(Window.isOpen()){
    while(Window.pollEvent(ScreenManager::getInstance().event)){
        if(ScreenManager::getInstance().event.type == sf::Event::Closed || ScreenManager::getInstance().event.key.code == sf::Keyboard::Escape){
          Window.close();
        }//end of if Event::Closed

        ScreenManager::getInstance().update(ScreenManager::getInstance().event);
    }//end of while/if Poll event

    Window.clear(sf::Color(0, 0, 0));
    ScreenManager::getInstance().draw(Window);
    Window.display();
  }//end of while isOpen

This changes from SplashScreen to TitleScreen
void SplashScreen::update(const sf::Event event){
  if(input->keyPressed(sf::Keyboard::T))
    ScreenManager::getInstance().addScreen(new TitleScreen()); //input*/

}//end of update()

This changes from TitleScreen to SplashScreen
void TitleScreen::update(const sf::Event event){
  if(input->keyPressed(sf::Keyboard::S))
    ScreenManager::getInstance().addScreen(new SplashScreen());//end of if enter is pressed*/
}//end of update()

If i have separate keys (S to change to SplashScreen and T to change to TitleScreen) it works fine. It changes screens nicely.
However, once i made both the keys the RETURN key, (i.e. press enter to change to SplashScreen and press Enter again to change to TitleScreen) it doesnt work. What it does is if i press enter once, it changes screens and changes back quickly. Note that i dont hold the enter key, i just press it once. I was thinking maybe the event stack has two return keys on it even though i pressed enter once? I have no idea how to fix it

Im on Mac OSX Mountain Lion
I use sublime text 2 with clang++

7
General / HELP!! Function prototype doesnt match any in class
« on: November 11, 2012, 12:58:04 am »
ive been stuck for 2 days and i cant figure it out

  ~                                                                                                  
 NORMAL  GameScreen.cpp                                          unix │ utf-8 │ cpp   70%  LN  19:20
"GameScreen.cpp" 27L, 408C written
    1 #include "GameScreen.h"
    2
    3   GameScreen::GameScreen(){
    4     //ctor
    5   }
    6
    7   GameScreen::~GameScreen(){
    8     //dtor
    9   }
   10
   11   void GameScreen::loadContent(){
   12
   13   }//end of loadContent()
   14
   15   void GameScreen::unloadContent(){
   16
   17   }//end of unloadContent()
   18 ..
>> 19   void GameScreen::update(sf::Event event){
   20
   21   }//end of update()
   22
   23   void GameScreen::draw(sf::RenderWindow &window){
   24
   25   }//end of draw(sf::RenderWindow &window)

  ~                                                                                                  
 NORMAL  GameScreen.cpp                                          unix │ utf-8 │ cpp   70%  LN  19:20
"GameScreen.cpp" 27L, 408C written
    1 #include "GameScreen.h"
    2
    3   GameScreen::GameScreen(){
    4     //ctor
    5   }
    6
    7   GameScreen::~GameScreen(){
    8     //dtor
    9   }
   10
   11   void GameScreen::loadContent(){
   12
   13   }//end of loadContent()
   14
   15   void GameScreen::unloadContent(){
   16
   17   }//end of unloadContent()
   18 ..
>> 19   void GameScreen::update(sf::Event event){
   20
   21   }//end of update()
   22
   23   void GameScreen::draw(sf::RenderWindow &window){
   24
   25   }//end of draw(sf::RenderWindow &window)

error prototype for void GameScreen::update(sf::Event) doesnt match any in class GameScreen. candidate is virtual void update()

Pages: [1]
anything