• Advertisement
Sign in to follow this  

new screens

This topic is 4735 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this might sound stupid, but i don't know how to do a screen change or whatever. if your going to enter a building or something, how are you supposed to clear the screen and start drawing again?

Share this post


Link to post
Share on other sites
Advertisement
im using opengl right now. and what i mean is, what if your walking around, see a house in the game and open the door and enter. then the screen goes black, and then the new place your in, which is the house or whatever comes up. another example would be going into your statistics screen. how do you have that come up, and when your done, go away and end up back where you were when you entered the stats screen?

Share this post


Link to post
Share on other sites
Well, depends on the effect. If you just want to enter the building with no loading, you have to set up your engine to dynamically load objects on the fly and create good occlusion methods.

If you want to allow loading, simply blast an image to the screen that says loading, destroy the current world, and create the new world. When the world is done, remove the image from the screen and start rendering other objects.

The stats screen is a little different. You wont want to destroy the previous world. However, you just dont render the other objects. Infact, you probably will "pause" all logic in the screen, so you dont get shot up or anything by enemies, etc.

Share this post


Link to post
Share on other sites
I would use a class which represents the users current location. You could maybe have a method of the class that can draw the area by passing a vertex array to the drawing function. I'm just starting with OpenGL so be mindful to get a second opinion, but as I understand it, you should be able to draw by passing the vertices to the draw method in order to draw different areas.

Share this post


Link to post
Share on other sites
thats exactly what i want to do, the second one, but i don't know how to delete or blast the current world.

Share this post


Link to post
Share on other sites
what if i had the stats screen always there, just out of site, and when i want to use it, just bring it into site. do you think that would work, or would it make the program too slow?

Share this post


Link to post
Share on other sites
Well, how do you create your world? If you know how to create it, you should know how to destroy it. And then just create a new world.

Also, the stats screen should not be up all the time. You should only render it when you want it to be shown, and that way you can also change your user input to correspond to the GUI of the stats screen.

Share this post


Link to post
Share on other sites
Somewhere along the line, you're going to have to have some kind of object processor or manager that is responsible for this kind of thing. When you transition, you'll have to flush the list of object's it's working with and reload new ones (for the new area). The tricky part is that there are also objects that you do NOT want deleted like characters and GUI elements etc.

So organizationally, you'll need to have that processor object firmly coded. It may also be responsible for world creation and destruction.

Share this post


Link to post
Share on other sites
I have done this exact thing you're trying to do (only I used SDL), but I think the idea is pretty much the same. The only thing is I used global variables (gasp) which I guess is somehow terrible.
My main area is embedded in a function called Street(x,y).

I check collision with the door, and if I get a hit, I call a function for that door, like House(). Inside House(), which is it's own .cpp file linked through a header, the screen is painted just like it was when street was created. (either by pixels or by loading a .bmp). When you leave the house, it makes a call to Street() and passes it the x,y coordinates so the player shows up right outside of the door.

Share this post


Link to post
Share on other sites
ok, thanks for trying to help, but i guess i might need some code or something. i'll try to explain something easy. what if all i make is a box. and all you can see is the box, everything else is the black background. i know the code to make the box, but i don't know the code or what your supposed to do to erase or delete the box.

Share this post


Link to post
Share on other sites
Quote:
Original post by iedoc
ok, thanks for trying to help, but i guess i might need some code or something. i'll try to explain something easy. what if all i make is a box. and all you can see is the box, everything else is the black background. i know the code to make the box, but i don't know the code or what your supposed to do to erase or delete the box.


For OGL, next time you draw the scene, just don't draw the box.

In general, once you have several boxes, you need to have some kind of data representation for your boxes (a struct or class), and a way of knowing where all your bits of box data are (a container of some sort, typically), and a way of deciding which boxes are currently being drawn (which may or may not involve removing 'boxes' from memory altogether).

Share this post


Link to post
Share on other sites
I'm a relative noob myself, so hopefully this is helpful.

iedoc,

Generally when you do anything graphic related, you are going to be drawing your scene to the screen many times a second. Every time your program updates, it will draw the scene to the screen again. What you need to do is define that scene in your code. For example, you said your scene would be just a simple box. Ok, as your game loops through it's update it draws that box to the screen over and over and over again as fast as it can. If you want to CLEAR the screen, then just don't tell it to draw that box on your next update loop, as Zahlman said.

One way you could do this is to keep track of all the objects you are going to draw on the screen with a list. In that list, you could have the vertexes for your box, and for any other objects you want to draw. You could then add to that list when you wanted to draw new things and remove objects from that list if you didn't want to draw them anymore.

Then, in the function you use to draw the screen, just draw whatever objects are in that list.

Your Code loop could look like this (Pseudocode, using Allegro-like conventions)


//Globals
bool ENDGAME;

int main
{
//Initialize Global Variables
ENDGAME = false;

//Run all your initialization stuff here
Init();

//Start your Game Loop
while (ENDGAME == false) //Check to make sure that ESC hasn't been hit.
{
while (drawing_logic_timer > 0) //Check your logic/drawing timer, if you use one.
{
//Do Your Game Logic Here, like testing for input, etc.
if (key[KEY_ESC])
ENDGAME = true;

//Reduce your logic timer, if you're using one.
drawing_logic_timer--;
}
//Now do your drawing here
RenderScene();
}
//Escape was hit, so exit.
return(0);
}


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement