Ejemplo n.º 1
0
        public cGame(cBiota pbiota)
        {
            _pcollider   = new cCollider();
            _pcontroller = Framework.Keydev;
            _pbiota      = pbiota;
            _pbiota.setGame(this);
            _pfocus         = new cCritter();
            _border         = new cRealBox3();
            _pskybox        = new cSpriteTextureBox();
            _plightingmodel = new cLightingModel();
            _cursorpos      = new cVector3();

            //Deleting the _pbiota killed off your _pplayer, so you need to get a new one.
            if (_pbiota.Size > 0) // use the first member of pbiota if there is one.
            {
                _pplayer = _pbiota.GetAt(0);
            }
            else //otherwise make a dummy.
            {
                _pplayer = new cCritter();
                cCritter pdummyplayer = new cCritter();
                setPlayer(pdummyplayer);
            }
        }
Ejemplo n.º 2
0
        //Constructors

        public cGame()
        {
            _seedcount       = COUNTSTART;
            _gameover        = false;
            _maxscore        = MAXSCORE;
            _scorecorrection = 0;
            _wrapflag        = cCritter.WRAP;
            _bDragging       = false;
            _pfocus          = null;
            _pplayer         = null;
            _border          = new cRealBox3(cGame.WORLDWIDTH, cGame.WORLDHEIGHT); //Default no zsize, computes faster.
            _pskybox         = null;
            _cursorpos       = new cVector3(0.0f, 0.0f);
            _level           = 1;
            _spritetype      = cGame.ST_SPRITETYPENOTUSED;
            _menuflags       = (cGame.MENU_ALL & ~cGame.MENU_AUTOPLAY & ~cGame.MENU_HOPPER);
            _newgame         = true;
            //Fix the static readonlys

            /* Reset the various static readonlys that may have been set to different values by previously
             * running some other game. */
            cCritter.Maxspeed     = cGame.CRITTERMAXSPEED;
            cCritter.MinRadius    = cGame.CRITTERMINRADIUS;
            cCritter.MaxRadius    = cGame.CRITTERMAXRADIUS;
            cCritter.BulletRadius = cGame.BULLETRADIUS;
            //Allocate the pointer variables.
            _pbiota         = new cBiota(this);
            _pcollider      = new cCollider();
            _pcontroller    = Framework.Keydev;
            _plightingmodel = new cLightingModel(true); //Default lighting model enables lights.
            setBorder(cGame.WORLDWIDTH, cGame.WORLDHEIGHT, 0.0f);
            // setBorder initializes _pskybox as well

            //Set the player, we want to make sure a game always has a player
            setPlayer(new cCritterPlayer(this)); //Sets _pplayer AND adds it to _pbiota.
        }
Ejemplo n.º 3
0
        // In this function, I initialize the objects that I declared above, and
        // also initialize the OpenGL settings -- I used the same initial OpenGL
        // settings that are used in the Pop framework, and Rucker's comments are
        // included about these initial settings
        public override void OnLoad(EventArgs e)
        {
            DateTime currentDate = new DateTime();

            currentDate = DateTime.Now;
            savetime    = currentDate.Ticks;
            _mindt      = MIN_DT;
            Keydev      = new cKeyInfo();
            dthistory   = new LinkedList <float>(
                delegate(out float f1, float f2)
            {
                f1 = f2;
            }
                );
            pdoc = new ACDoc();
            view = new ACView();
            GL.ClearColor(Color.SteelBlue);
            GL.Enable(EnableCap.DepthTest);
            GL.ClearDepth(1.0);
            // enable depth testing
            GL.Enable(EnableCap.Normalize);

            /* By default DepthTest is off.  We normally need it so that nearer things cover
             * further things.  Don't need it, though, in the two dimensional case. */
            GL.DepthFunc(DepthFunction.Less);

            /* This is the default depth test, but we make it explicity.  Skips drawing any pixel with
             * a smaller depth than the zbuffer depth value at that spot. */
            //	::glShadeModel(GL_SMOOTH); //The default shading model, instead we prefer GL_FLAT
            GL.ShadeModel(ShadingModel.Flat);

            /* Smooth interpolates from the vertices across a polygon, while
             * Flat picks one vertex (the first of the poly) and uses that color across
             * the polygon. Default is Smooth.  Runs about 75% as fast as Flat, and there's
             * no point to it for polyhedra, as all verts of a polyhedron face have the same
             * normal anyway (Unless you tilt the vert normals to make the polyhedron resemble
             * a curved surface, in which case you do want Smooth and should temporarily
             * turn it on for that object with a glShadeModel call). */
            //	::glEnable(GL_LINE_SMOOTH);
            //Anti-alias lines.  Makes lines a bit more solid looking, but costs a lot of speed.
            //	::glEnable(GL_POLYGON_SMOOTH);

            /* To make the polygon edges smoother. Don't even THINK of using this one, it cuts your speed
             * to almost nothing. */
            //::glEnable(GL_CULL_FACE);

            /* Don't draw back-facing polygons to save speed?  Better not.  First of all, we need to
             * draw them in demo mode, as the teapot seems to have	clockwise polygons. Second of all,
             * the cSpriteIcon doesn't work if we cull faces. */
            //   GL.Enable(EnableCap.Lighting);

            /* Default is lighting ON.  We do in fact
             * always want to use lighting with OpenGL, as, surprisingly, OpenGL is FASTER with lighting
             * turned on!  Do be aware that if have lighting on, you MUST install some lights
             * or everything is black.  So we MUST have a call to installLightingModel here as well.
             * To be safe, we turn the light on with a call to our installLightingModel with
             * a NULL argument to give a default  behavior that turns lighting on and adds some
             * lights. */
            GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); //We're not padding at ends of lines when we write textures.
            GL.PixelStore(PixelStoreParameter.PackAlignment, 1);   //We're not padding at ends of lines when we read textures.
        }