new screens

Started by
11 comments, last by Radagar 19 years, 1 month ago
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.
Advertisement
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).
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)

//Globalsbool 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);}
WyrmSlayer RPG - In Early Development

This topic is closed to new replies.

Advertisement