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
16
General / Re: Help getting started on a specific type of menuscreen
« on: December 02, 2012, 09:01:49 pm »
well the picture i posted above has rain in it. but its just a still picture. i want there to be pretty realistic rain that looks like the rain in the picture and i want the rain to kind of interact with the picture. as in when the rain reaches the ground in the picture it sort of "hits" the ground. and yes, if its not too hard, i want to have collisons, repelling, and fluid dynamics. i mean, the direction of the rain has to be randomized and not just straight down all the time. and the drops have to look like the one in the picture so the picture and the rain can blend together.

will this be too hard?

and regarding the menu screen, i understand that ill need a Rectangle and a change of text Color, but in the video, as the rectangle covers the text, the text goes from black to white as the rectangle moves to cover it. i cant seem to understand how i would code this. so could you help me understand how exactly i should code this?

so far this is what i think. i will make a
sf::RectangleShape
and i will use
text.getLocalBounds()
and use the height of the
text.getLocalBounds()
to measure how much my rectangle needs to move up/down to cover the text completely. Now how exactly i should move the rectangle is confusing me because the rectangle seems to "accelerate" and slow down to cover the text. it doesnt seem like a simple up or down motion (unless im imagining things). and ofcouse, the color changing of the text seems confusing to me too. like changing the color of the text as the rectangle covers it. because, if i just change the color of the text normally, then the text will just become white immediately before the rectangle manages to cover the whole text. so i need a little more guidance if possible :S

sorry for the essay post. im not that experienced with graphics.

17
General / Re: Help getting started on a specific type of menuscreen
« on: December 02, 2012, 06:59:49 am »
also i have an image that im displaying on the menuscreen and there is rain in the image. i want to make the rain on my menuscreen similar to that such that it looks like its actually raining.


18
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.

19
DotNet / Re: Quick Question - Text.GetRect
« on: December 02, 2012, 02:50:06 am »
what is the difference between getGlobalBound and getLocalBound?

20
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: December 02, 2012, 02:29:18 am »
alrite i get it.

i searched places and couldnt find the difference between global coordinates, screen coordinates and local coordinates. whats the difference between them?

is global your whole monitor and screen just your window?

21
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: December 02, 2012, 12:50:41 am »
Well as I said, the framerate is limited to 60fps thus I can rely on the fact the update function is getting called 60 times every second and thus reducing the alpha value by 1 every iteration will need ~4.25 seconds to go from 255 to 0. I'm drawing a rectangle over the whole screen and simply reduce it's alpha channel until it's fully transparent.
But you're right I don't do anything with keys, it just happens when you start that state until it reaches 0.

So youre update does get called every frame then. Ah i see. If i do that then my fade works. Before i display i call update everytime even if the user doesnt press any keys. The thing i was worried about is, if there is no event happening, what exactly happens? like say theres no event happening, what does event contain? i couldnt find this in the documentation for events. if the event stack is empty then what happens when u try to access an sf::Event member?

22
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: December 01, 2012, 08:36:16 pm »
Thanks so much expl0it3r. I got my fade to work by calling the update function of my ScreenManager and Animation classes which update the alpha values and screens. But i still have questions because some things still seem a bit strange.

First heres my main loop right now.

bool enableKeyRepeat = false;
  sf::RenderWindow Window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32),"Hulq", sf::Style::None);
  Window.clear(sf::Color(0, 0, 0));
  Window.setFramerateLimit(60);
  Window.setKeyRepeatEnabled(enableKeyRepeat);

  ScreenManager::getInstance().initialize();
  ScreenManager::getInstance().loadContent();

  sf::Clock clock;
while(Window.isOpen()){
    while(Window.pollEvent(ScreenManager::getInstance().event)){
      switch (ScreenManager::getInstance().event.type){
        case sf::Event::Closed:
          Window.close();
          break;

        case sf::Event::KeyPressed:
          if(ScreenManager::getInstance().event.key.code == sf::Keyboard::Escape) {
            Window.close();
          }//if escape is pressed close window and skip everything in loop
          else
            ScreenManager::getInstance().update(ScreenManager::getInstance().event, Window);
          break;

        default:
          ScreenManager::getInstance().update(ScreenManager::getInstance().event, Window);
      }//end of switch(event.type)*/


    }//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

The fade in and out only works if i put the line with /****/ in. if i take that line out it doesnt work. basically if i take that line out, i have to continuously press the return key (which switches screens) in order to fade in and out. if i put the line in, then i can press the return key once and it will fade out, switch screens, and fade the new screen in. I have read the events tutorial. From what i deduced, if no event is happening it wont even go inside the while(pollEvent()) and it will just keep looping the while(isOpen()) loop. And my update() function is called inside the while(pollEvent()). So i made a call to update outside (the /****/ line). is this a good way to do things?

Let me try to give u the jist of what im doing. my update function updates everything. screen and alpha too. once the Return key is pressed itll start the fade animation. A bool value called "inTransition" will become true and while thats true it will keep doing the fade animation as long as update() is called. basically to keep changing the alpha value (make it go from 0 to 255 and back to 0 to effectively fade out and then fade in) update() must be called which checks the bool inTransition to see if its true and if true, it proceeds to change the alpha value. now, if i press Return and then dont press anything else, update() wont be called unless i bring it outside to the while(isOpen()) loop. however it makes more sense to keep it only inside the while(pollEvent()) loop because you update() based on whether there are events or not. and yes i did take your advice, and my update function draws various things to the window but i only call Window.display() once. i looked at your SmallGameEngine and it seems your using a stack to push and pop states. it seems kind of advanced and i dont quite understand how you fade in your IntroState. You reduce the alpha value everytime it loops irrespective of keypresses. Its really clean code but i havent really used stacks. How exactly do you use stacks in a game? Doesnt while(pollEvent()) push and pop events for you? And does C++ only support .hpp headers? i used .h headers for my headers.



also sorry i keep bombarding with questions. for my titlescreen i just draw sf::Text to the screen. is there any easy way to center the text in the center of the window? right now im doing this.

    text.setPosition(SCREEN_WIDTH/2 - ( (stringLength/3) * text.getCharacterSize()), SCREEN_HEIGHT/2 - text.getCharacterSize());
 

as you can see, its completely random guessing with numbers. i understand i could load an image with a sprite, but i think id run into the same problem centering a sprite.

btw how do you change a thread to [SOLVED]?

i apologize for the huge essay post.

23
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: December 01, 2012, 01:53:55 am »
i thought i understood what a frame was but it seems not. in the for loop i call Window.display()... what i initially thought was every time you call Window.display()  it displays your contents to the Window and that is a one "frame". what exactly is a frame? if calling Window.display() doesnt mark the end of one frame and the beginning of the next frame then how exactly does it work?

24
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: December 01, 2012, 12:42:23 am »
Ohh i get it now. That analogy makes it easier to understand.

And sorry to keep bothering but i am trying to achieve a fading animation during screen switches. i looked on the forum and people tried using a for loop to fade in and out and i tried something like this but it doesnt work. (what actually happens is i press enter, instead of fading away the screen just freezes for 2 seconds without dimming and then switches to the next screen) this is the code:

void SplashScreen::update(const sf::Event event, sf::RenderWindow &Window){
  if(input->keyPressed(sf::Keyboard::Return)){
    for(int i = opacity; i >= 0; i -= 5){ //opacity = 255
      Window.clear(sf::Color(0, 0, 0));
      text.setColor(sf::Color(255, 255, 255, i));
      Window.display();
    }
    ScreenManager::getInstance().addScreen(new TitleScreen()); //input*/
  }
}//end of update()

i was wondering how i can fade in and out. ive seen some people use the delta time between frames to fade in and out but why doesnt the above code work?

25
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: November 30, 2012, 11:12:43 pm »
Double switch structure? whats that? I know that using a switch structure in the main while(isOpen) loop will allow you to detect cases .

In my main function, i will eventually have a switch case that detects what time of event it is (keypressed, closed etc etc) but then when i want to specifically check which key has been pressed, i use the inputManager functions which returns true or false based on which key has been pressed.

also sorry for asking multiple questions, but, in your opinions, if i have ScreenManager, GameScreen, SplashScreen, TitleScreen, InputManager, and Animation classes, which class should keep info about the time between frames?

I was thinking the ScreenManager should have a sf::Time member which holds the time between each frame. I want to keep track of the time between each frame such that if i want to control movement/ fading animations, i can change alpha values.

oh and yea my inputManager had S and T keys that change between screens but i changed it to the Return key.

and expl0it3r. so you're saying i should first check if the key is pressed by doing
sf::Keyboard::isKeypressed
and then i should check the actual key pressed by doing
event.key.code == key

and the reason to do this is because the event may be delayed so there might be a time difference?

26
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: November 29, 2012, 04:31:26 am »
ok so i changed it to this and it works.
bool InputManager::keyPressed(sf::Keyboard::Key key){
  if(ScreenManager::getInstance().event.type == sf::Event::KeyPressed && ScreenManager::getInstance().event.key.code == key) return true;
  return false;
}//end of keyPressed

and i have one more question. i have seen some people use vectors of sf::Keyboard::Key to check input. can someone tell me what is is the benefit of using a vector of keys rather just checking individual keys like i did above?

27
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: November 29, 2012, 03:04:56 am »
im still confused about why event.key.code can have something random. does it not have the code of the key pressed?

and ok so i tried checking for event.KeyPressed like this:

bool InputManager::keyPressed(sf::Keyboard::Key key){
  if(ScreenManager::getInstance().event.KeyPressed && ScreenManager::getInstance().event.key.code == key) return true;
  return false;
}//end of keyPressed

but the problem doesnt go away. if i press enter it switches from splashscreen to titlescreen and back.

im sorry im so noob :(. im kind of new to graphics and windows.

28
General / Re: Pressing Enter causes two screen switches instead of 1!
« on: November 28, 2012, 08:53:51 am »
Oh sorry i forgot to post my InputManager code. I do check the event here in another class

bool InputManager::keyPressed(sf::Keyboard::Key key){
  if(ScreenManager::getInstance().event.key.code == key) return true;
  return false;
}//end of keyPressed(int)

Basically, my inputManager class handles input by checking if the event.key.code matches with the given key in the parameter. the event here is the same event that i got from pollEvent in main.

29
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++

30
General / Re: HELP!! Function prototype doesnt match any in class
« on: November 11, 2012, 01:38:42 am »
sorry about not following the forum rules.

and what exactly do u mean by compiling an "old file"?

im on Mac OSX Mountain Lion using iterm2 with vim.
compiler is g++

my GameScreen class is a base class for other classes. and yea i dont know whats going on. i doubt im compiling another file or an old file because GameScreen.h and GameScreen.cpp are the only files with those names in my directory.

Pages: 1 [2] 3
anything