Пример #1
0
        public void drawBkgEntity(Entity e)
        {
            //Pull out all required components
            PositionComponent posComp  = ( PositionComponent )e.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
            DrawComponent     drawComp = ( DrawComponent )e.getComponent(GlobalVars.DRAW_COMPONENT_NAME);

            if (isInView(posComp))
            {
                if (g != null)
                {
                    Image img = drawComp.getImage();

                    //Get center instead of upper left
                    PointF drawPoint = posComp.getLocAsPoint();
                    drawPoint.X -= (posComp.width / 2.0f);
                    drawPoint.Y -= (posComp.height / 2.0f);

                    drawPoint.X -= this.x;
                    drawPoint.Y -= this.y;

                    drawPoint.X *= wRatio;
                    drawPoint.Y *= hRatio;


                    lock ( img ) {
                        //g.DrawImage(img, new RectangleF(0, 0, width, height), new RectangleF(x, y, width, height), GraphicsUnit.Pixel);
                        g.DrawImage(img, new RectangleF(x, y, width, height), new RectangleF(x, y, width, height), GraphicsUnit.Pixel);
                    }
                }
            }
        }
Пример #2
0
        public void updatePlayerLoc()
        {
            Player player = level.getPlayer();

            if (player == null)
            {
                Console.WriteLine("Error: Setting checkpoint with no player");
                return;
            }
            PositionComponent posComp = ( PositionComponent )player.getComponent(GlobalVars.POSITION_COMPONENT_NAME);

            if (posComp == null)
            {
                Console.WriteLine("Error: Trying to set checkpoint, but player has no position component");
                return;
            }

            playerLoc = new PointF(posComp.getLocAsPoint().X, posComp.getLocAsPoint().Y);
        }
Пример #3
0
        //Picks either the upper, lower, left, or right sides for the grapple to attach to.
        public PointF getGrappleAttachPoint(Entity attachEnt, GrappleComponent grapComp)
        {
            PositionComponent attachPosComp = ( PositionComponent )attachEnt.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
            PointF            attachPos     = attachPosComp.getLocAsPoint();
            PointF            attachSize    = attachPosComp.getSizeAsPoint();

            if (attachEnt.hasComponent(GlobalVars.COLLIDER_COMPONENT_NAME))
            {
                ColliderComponent colComp = ( ColliderComponent )attachEnt.getComponent(GlobalVars.COLLIDER_COMPONENT_NAME);
                attachPos  = colComp.getLocationAsPoint(attachPosComp);
                attachSize = colComp.getSizeAsPoint();
            }

            PointF grapPos = grapComp.getLastPoint();
            PointF left    = new PointF(attachPos.X - attachSize.X / 2, attachPos.Y);
            PointF right   = new PointF(attachPos.X + attachSize.X / 2, attachPos.Y);
            PointF up      = new PointF(attachPos.X, attachPos.Y - attachSize.Y / 2);
            PointF down    = new PointF(attachPos.X, attachPos.Y + attachSize.Y / 2);

            double distLeft  = getDist(grapPos, left);
            double distRight = getDist(grapPos, right);
            double distUp    = getDist(grapPos, up);
            double distDown  = getDist(grapPos, down);

            double minA = Math.Min(distLeft, distRight);
            double minB = Math.Min(distUp, distDown);
            double min  = Math.Min(minA, minB);

            if (min == distLeft)
            {
                return(left);
            }
            else if (min == distRight)
            {
                return(right);
            }
            else if (min == distUp)
            {
                return(up);
            }
            else if (min == distDown)
            {
                return(down);
            }
            else
            {
                Console.WriteLine("Error picking point for grapple attachment!");
                return(attachPos);
            }
        }
Пример #4
0
        //You must have an Update.
        //Always read in deltaTime, and only deltaTime (it's the time that's passed since the last frame)
        //Use deltaTime for things like changing velocity or changing position from velocity
        //This is where you do anything that you want to happen every frame.
        //There is a chance that your system won't need to do anything in update. Still have it.
        public override void Update(float deltaTime)
        {
            foreach (Entity e in getApplicableEntities())
            {
                SignComponent signComp = (SignComponent)e.getComponent(GlobalVars.SIGN_COMPONENT_NAME);

                if (!signComp.isActive)
                {
                    continue;
                }
                else //checks to see if player is still colliding with the sign
                {
                    PositionComponent posComp = ( PositionComponent )e.getComponent(GlobalVars.POSITION_COMPONENT_NAME);

                    System.Drawing.PointF position = posComp.getLocAsPoint();
                    float xPos = position.X;
                    float yPos = position.Y;
                    System.Drawing.PointF startPoint = new System.Drawing.PointF(xPos - posComp.width / 2, yPos);
                    System.Drawing.PointF endPoint   = new System.Drawing.PointF(xPos + posComp.width / 2, yPos);

                    List <Entity> list = level.getCollisionSystem().findObjectsBetweenPoints(startPoint, endPoint); //find all the objects between (hopefully) the ends of the sign

                    bool playerExists = false;
                    foreach (Entity ent in list)
                    {
                        if (ent is Entities.Player)
                        {
                            playerExists = true;
                            break;
                        }
                    }
                    if (playerExists)
                    {
                        signComp.isActive = true;
                        level.sysManager.drawSystem.beginConstText(signComp.text, level.sysManager.signSystem.signCol);
                    }
                    else
                    {
                        signComp.isActive = false;
                        level.sysManager.drawSystem.endConstText(signComp.text, signCol, 0.5f);
                    }
                }
            }
        }
Пример #5
0
        //You must have an Update.
        public override void Update(float deltaTime)
        {
            bool loopWasEntered = false;

            foreach (Entity e in getApplicableEntities())   //There should only ever be 0 or 1
            {
                loopWasEntered = true;
                GrappleComponent grapComp = ( GrappleComponent )e.getComponent(GlobalVars.GRAPPLE_COMPONENT_NAME);

                //Growing
                if (grapComp.state == 0 && level.getPlayer() != null)
                {
                    float newX = grapComp.getLastPoint().X;
                    float newY = grapComp.getLastPoint().Y;

                    //Check if the player has moved. If so move the start point of the grapple.
                    PositionComponent playerPos = ( PositionComponent )level.getPlayer().getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                    if (playerPos.getLocAsPoint() != grapComp.getFirstPoint())
                    {
                        //Move start point
                        grapComp.setFirstPoint(playerPos.getLocAsPoint());

                        //Check to see if it's intersecting anything now
                        Entity mrIntersection = checkForStopsBetweenPoints(grapComp.getFirstPoint(), grapComp.getLastPoint(), grapComp);
                        if (mrIntersection != null)
                        {
                            //If it DID intersect something, destroy the grapple.
                            //finishGrapple(e, false);

                            //AKSHUALLY connect the grapple to the new thing
                            PositionComponent pos    = ( PositionComponent )mrIntersection.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                            PointF            setPos = getGrappleAttachPoint(mrIntersection, grapComp);
                            //grapComp.setEndPoint( pos.getLocAsPoint() );
                            grapComp.setEndPoint(setPos);
                            grapComp.state = 1;
                            return;
                        }
                    }

                    // If no collision - progress forwards!

                    //h = speed*time
                    //x = h*cos(theta)
                    //y = h*sin(theta)

                    float h = growSpeed * deltaTime;

                    newX += h * ( float )Math.Cos(grapComp.direction);
                    newY += h * ( float )Math.Sin(grapComp.direction);


                    System.Drawing.PointF p = new System.Drawing.PointF(newX, newY);

                    //Don't allow it to go off the sides of the screen
                    if (newX < -h || newY < -h || newX > level.levelWidth + h || newY > level.levelHeight + h)
                    {
                        grapComp.state = 2;
                        return;
                    }

                    //check if it's past the max grapple distance
                    if (getDist(grapComp.getFirstPoint(), grapComp.getLastPoint()) > GlobalVars.MAX_GRAPPLE_DISTANCE)
                    {
                        grapComp.state = 2; //Retreat!
                        return;
                    }



                    PointF p1 = new PointF(newX, newY);

                    //Check if it's done grappling
                    //colEnt is the entity which the grapple latches onto


                    Entity colEnt = checkForStopsBetweenPoints(grapComp.getLastPoint(), p1, grapComp);


                    if (colEnt != null)
                    {
                        PositionComponent pos    = ( PositionComponent )colEnt.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                        PointF            setPos = getGrappleAttachPoint(colEnt, grapComp);
                        //grapComp.setEndPoint( pos.getLocAsPoint() );
                        grapComp.setEndPoint(setPos);
                        grapComp.myLink = colEnt;
                        grapComp.state  = 1;
                        if (removeGravity == 2)
                        {
                            level.getPlayer().removeComponent(GlobalVars.GRAVITY_COMPONENT_NAME);
                        }
                        return;
                    }

                    //Not colliding with anything, set the end point to the calculated point.
                    grapComp.setEndPoint(p);
                }
                //Following
                else if (grapComp.state == 1 && level.getPlayer() != null)
                {
                    if (level.getPlayer() == null)
                    {
                        level.removeEntity(e);
                        return; //No player, nothing to do!
                    }

                    //Get player's position component
                    PositionComponent playerPos = ( PositionComponent )level.getPlayer().getComponent(GlobalVars.POSITION_COMPONENT_NAME);

                    /*
                     * //Check to see if it's intersecting anything mid-way
                     * Entity mrIntersection = null;
                     * if ( checkForStopsBetweenPointsExclude( grapComp.getFirstPoint(), grapComp.getLastPoint(), grapComp.myLink, ref mrIntersection ) ) {
                     *  //If it DID intersect something, destroy the grapple.
                     *  //finishGrapple(e, false);
                     *  //return;
                     *  PositionComponent pos = ( PositionComponent )mrIntersection.getComponent( GlobalVars.POSITION_COMPONENT_NAME );
                     *  grapComp.setEndPoint( pos.getLocAsPoint() );
                     * }
                     *
                     *
                     * //Check if, for whatever reason, the player wasn't able to move.
                     * float buff = 0.5f;
                     * buff = GlobalVars.MIN_TILE_SIZE;
                     * if ( Math.Abs( playerPos.x - grapComp.getFirstPoint().X ) > buff || Math.Abs( playerPos.y - grapComp.getFirstPoint().Y ) > buff ) {
                     *  Console.WriteLine( "Finish 1" );
                     *  //finishGrapple( e, true );
                     *  grapComp.state = 2;
                     *  stopPlayer = true;
                     *  return;
                     * }
                     */

                    double distBefore = getDist(playerPos.getLocAsPoint(), grapComp.getLastPoint());

                    //Move first point in grapple up
                    float newX = grapComp.getFirstPoint().X;
                    float newY = grapComp.getFirstPoint().Y;

                    float h = followSpeed * deltaTime;

                    newX += h * ( float )Math.Cos(grapComp.direction);
                    newY += h * ( float )Math.Sin(grapComp.direction);

                    System.Drawing.PointF p = new System.Drawing.PointF(newX, newY);


                    //This checks if the next point is near final point in the grapple.
                    //If so, remove the grapple and break.
                    ColliderComponent playerCol = ( ColliderComponent )level.getPlayer().getComponent(GlobalVars.COLLIDER_COMPONENT_NAME);
                    float             buffer    = GlobalVars.MIN_TILE_SIZE;
                    if (playerCol != null)
                    {
                        buffer += playerCol.width / 1.5f;
                    }
                    else
                    {
                        buffer += playerPos.width / 1.5f;
                    }
                    if (Math.Abs(newX - grapComp.getLastPoint().X) <= buffer && Math.Abs(newY - grapComp.getLastPoint().Y) <= buffer)
                    {
                        //Console.WriteLine( "Finish 3!" );
                        //finishGrapple( e, true );
                        grapComp.state = 2;
                        stopPlayer     = true;
                        return;
                    }


                    //Move player
                    level.getMovementSystem().changePosition(playerPos, p.X, playerPos.y, false, false);
                    level.getMovementSystem().changePosition(playerPos, playerPos.x, p.Y, false, false);

                    grapComp.setFirstPoint(playerPos.getLocAsPoint());

                    //Check to make sure the player isn't getting further away. If he is, sthap!
                    double nowDist = getDist(grapComp.getFirstPoint(), grapComp.getLastPoint());
                    if (nowDist >= distBefore)
                    {
                        //Console.WriteLine( "Finish 2!" );
                        //finishGrapple( e, true );
                        grapComp.state = 2;
                        stopPlayer     = true;
                        return;
                    }
                }
                //Retreating
                else if (grapComp.state == 2 && level.getPlayer() != null)
                {
                    PositionComponent playerPos = ( PositionComponent )level.getPlayer().getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                    grapComp.setFirstPoint(playerPos.getLocAsPoint());

                    double distBefore = getDist(grapComp.getFirstPoint(), grapComp.getLastPoint());

                    float newX = grapComp.getLastPoint().X;
                    float newY = grapComp.getLastPoint().Y;

                    float h = retreatSpeed * deltaTime;

                    if (h > distBefore)
                    {
                        h = ( float )distBefore;
                    }

                    //Calculate the direction
                    double dir = Math.Atan((grapComp.getFirstPoint().Y - newY) / (grapComp.getFirstPoint().X - newX));

                    if (grapComp.getFirstPoint().X < newX)
                    {
                        dir += Math.PI;
                    }

                    newX += h * ( float )Math.Cos(dir);
                    newY += h * ( float )Math.Sin(dir);

                    System.Drawing.PointF p = new System.Drawing.PointF(newX, newY);

                    //Make sure it isn't getting longer
                    if (getDist(p, grapComp.getFirstPoint()) > distBefore)
                    {
                        finishGrapple(e);
                        return;
                    }


                    //Check if it's fully retreated - if so, delete the grapple!
                    float buffer = GlobalVars.MIN_TILE_SIZE;
                    if (Math.Abs(newX - grapComp.getFirstPoint().X) <= buffer && Math.Abs(newY - grapComp.getFirstPoint().Y) <= buffer)
                    {
                        finishGrapple(e);
                        return;
                    }


                    grapComp.setEndPoint(p);
                }
            }
            isGrappling = loopWasEntered;
        }
Пример #6
0
        public void drawEntity(Entity e)
        {
            //Pull out all required components
            PositionComponent posComp  = ( PositionComponent )e.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
            DrawComponent     drawComp = ( DrawComponent )e.getComponent(GlobalVars.DRAW_COMPONENT_NAME);

            if (e is ShooterBullet)
            {
                //Console.WriteLine( "In Draw ShooterBullet - Redraw: " + drawComp.needRedraw + ", In View: " + isInView( posComp ) );
            }

            if (drawComp.needRedraw)
            {
                if (isInView(posComp))
                {
                    if (g != null)
                    {
                        Image img = null;
                        //If size is locked, don't resize the image.
                        if (drawComp.sizeLocked && wRatio == 1 && hRatio == 1)
                        {
                            img = drawComp.getImage();
                        }
                        else
                        {
                            Size imageSize = new Size(( int )(posComp.width * wRatio), ( int )(posComp.height * hRatio));
                            img = new Bitmap(drawComp.getImage(), imageSize);
                        }

                        PointF drawPoint = posComp.getLocAsPoint();
                        drawPoint.X -= (posComp.width / 2.0f);
                        drawPoint.Y -= (posComp.height / 2.0f);

                        lock ( img ) {
                            g.DrawImageUnscaled(img, new Point(( int )drawPoint.X, ( int )drawPoint.Y));     //Draw the image to the view
                        }
                        //Health bar if need be
                        if (e.hasComponent(GlobalVars.HEALTH_COMPONENT_NAME))
                        {
                            HealthComponent healthComp = ( HealthComponent )e.getComponent(GlobalVars.HEALTH_COMPONENT_NAME);
                            if (healthComp.healthBar && (healthComp.showBarOnFull || !healthComp.hasFullHealth()))
                            {
                                int barHeight = 4;
                                int ySpace    = 3;
                                int xSpace    = 0;

                                int xLoc      = (( int )Math.Round(posComp.x - posComp.width / 2) + xSpace);
                                int yLoc      = (( int )Math.Round(posComp.y - posComp.height / 2) - barHeight - ySpace);
                                int fullWidth = (( int )Math.Round(posComp.width) - 2 * xSpace);

                                Rectangle backRect = new Rectangle(xLoc, yLoc, fullWidth, barHeight);
                                Rectangle foreRect = new Rectangle(xLoc, yLoc, ( int )Math.Round(fullWidth * healthComp.getHealthPercentage()), barHeight);

                                g.FillRectangle(healthComp.backHealthBarBrush, backRect);
                                g.FillRectangle(healthComp.foreHealthBarBrush, foreRect);
                                g.DrawRectangle(Pens.Black, backRect);   //Border
                            }
                        }

                        if (e is BasicGround & bkgEnt != null)
                        {
                            DrawComponent bkgDraw = ( DrawComponent )bkgEnt.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
                            Graphics      graph   = Graphics.FromImage(bkgDraw.getImage());
                            lock ( img ) {
                                graph.DrawImageUnscaled(img, new Point(( int )drawPoint.X, ( int )drawPoint.Y));     //Draw the image to the view
                            }
                            drawComp.needRedraw = false;
                        }
                    }
                }
                if (GlobalVars.debugBoxes)
                {
                    g.DrawRectangle(Pens.Blue, posComp.x - posComp.width / 2, posComp.y - posComp.height / 2, posComp.width, posComp.height);

                    if (e.hasComponent(GlobalVars.COLLIDER_COMPONENT_NAME))
                    {
                        ColliderComponent colComp = (ColliderComponent)e.getComponent(GlobalVars.COLLIDER_COMPONENT_NAME);
                        g.DrawRectangle(Pens.Red, colComp.getX(posComp) - colComp.width / 2, colComp.getY(posComp) - colComp.height / 2, colComp.width, colComp.height);
                    }
                }
            }
        }
Пример #7
0
        public void Draw(Graphics mainG, List <Entity> entities)
        {
            //g.FillRectangle(bkgBrush, new Rectangle(0, 0, (int)width, (int)height)); //Clear

            if (!(level is RunningGame.Level_Editor.CreationLevel))
            {
                if (!hasDecreasedQuality)
                {
                    g.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; // or NearestNeighbour
                    g.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.None;
                    g.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
                    g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                    g.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;

                    mainG.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor; // or NearestNeighbour
                    mainG.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.None;
                    mainG.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
                    mainG.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
                    mainG.TextRenderingHint  = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;

                    hasDecreasedQuality = true;
                }

                //Find background Entity first if need be
                if (bkgEnt == null)
                {
                    foreach (Entity e in entities)
                    {
                        if (e is BackgroundEntity)
                        {
                            bkgEnt = ( BackgroundEntity )e; //Find background entity
                        }
                    }
                }

                if (staticObjImg == null /*|| redrawStatics*/)
                {
                    if (seperateStaticObjImage)
                    {
                        staticObjImg = new Bitmap(( int )Math.Ceiling(level.levelWidth), ( int )Math.Ceiling(level.levelHeight));
                    }
                    else
                    {
                        foreach (Entity e in entities)
                        {
                            if (e is BackgroundEntity)
                            {
                                if (bkgEnt == null)
                                {
                                    bkgEnt = ( BackgroundEntity )e; //Find background entity
                                }
                                DrawComponent bkgDraw = ( DrawComponent )bkgEnt.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
                                staticObjImg = ( Bitmap )bkgDraw.getImage();
                            }
                        }
                    }

                    //Draw static entities onto background
                    if (!GlobalVars.fullForegroundImage)
                    {
                        foreach (Entity ent in GlobalVars.groundEntities.Values)
                        {
                            DrawComponent grnDraw = ( DrawComponent )ent.getComponent(GlobalVars.DRAW_COMPONENT_NAME);

                            /*DrawComponent bkgDraw = (DrawComponent)bkgEnt.getComponent(GlobalVars.DRAW_COMPONENT_NAME);
                             *
                             * PositionComponent posComp = (PositionComponent)ent.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                             * PointF drawPoint = posComp.getPointF();
                             * drawPoint.X -= (posComp.width / 2.0f);
                             * drawPoint.Y -= (posComp.height / 2.0f);
                             *
                             * Graphics graph = Graphics.FromImage(bkgDraw.getImage());*/


                            PositionComponent posComp   = ( PositionComponent )ent.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
                            PointF            drawPoint = posComp.getLocAsPoint();
                            drawPoint.X -= (posComp.width / 2.0f);
                            drawPoint.Y -= (posComp.height / 2.0f);

                            Graphics graph = Graphics.FromImage(staticObjImg);
                            lock (grnDraw.getImage()) {
                                graph.DrawImageUnscaled(grnDraw.getImage(), new Point(( int )drawPoint.X, ( int )drawPoint.Y));     //Draw the image to the view
                            }
                            grnDraw.needRedraw = false;
                            //redrawStatics = false;
                        }
                    }
                }

                //First, if there's a background entity, draw that!
                if (bkgEnt != null)
                {
                    drawBkgEntity(bkgEnt);
                }
                if (seperateStaticObjImage)
                {
                    drawStaticObjImage();
                }


                //If there's a grapple, draw it
                if (level.sysManager != null && level.sysManager.grapSystem.isGrappling)
                {
                    foreach (Entity e in GlobalVars.nonGroundEntities.Values)
                    {
                        if (e is GrappleEntity)
                        {
                            GrappleComponent grapComp = ( GrappleComponent )e.getComponent(GlobalVars.GRAPPLE_COMPONENT_NAME);

                            PointF start = grapComp.getFirstPoint();
                            PointF end   = grapComp.getLastPoint();

                            /*
                             * // Calc the pos relative to the view
                             * start.X -= this.x;
                             * start.Y -= this.y;
                             * end.X -= this.x;
                             * end.Y -= this.y;
                             *
                             * start.X *= wRatio;
                             * start.Y *= hRatio;
                             * end.X *= wRatio;
                             * end.Y *= hRatio;
                             */
                            g.DrawLine(GrapplePen, start, end);
                            break; //Should only be one - this'll save some time.
                        }
                    }
                }


                //For all applicable entities (Entities with required components)
                foreach (Entity e in entities)
                {
                    if (!(e is BackgroundEntity))
                    {
                        drawEntity(e);
                    }
                }

                if (level.sysManager.drawSystem.drawDebugStuff)
                {
                    for (int i = 0; i < level.sysManager.drawSystem.debugLines.Count - 1; i += 2)
                    {
                        g.DrawLine(new Pen(Color.Blue, 3), level.sysManager.drawSystem.debugLines[i], level.sysManager.drawSystem.debugLines[i + 1]);
                    }
                    level.sysManager.drawSystem.debugLines.Clear();
                    int circWidth = 4;
                    for (int i = 0; i < level.sysManager.drawSystem.debugPoints.Count; i++)
                    {
                        g.FillEllipse(Brushes.Green, ( int )Math.Round(level.sysManager.drawSystem.debugPoints[i].X - circWidth / 2), ( int )Math.Round(level.sysManager.drawSystem.debugPoints[i].Y) - circWidth / 2, circWidth, circWidth);
                    }
                    level.sysManager.drawSystem.debugPoints.Clear();
                }


                //mainG.DrawImage(drawImg, new Point((int)displayX, (int)displayY)); //Draw the view to the main window
                //mainG.DrawImageUnscaled(drawImg, new Point((int)displayX, (int)displayY)); //Draw the view to the main window
                mainG.DrawImage(drawImg, new RectangleF(displayX, displayY, displayWidth, displayHeight), new RectangleF(x, y, width, height), GraphicsUnit.Pixel);


                //Draw Border
                if (this.hasBorder)
                {
                    if (!this.borderFade)
                    {
                        mainG.DrawRectangle(new Pen(borderBrush, borderSize), new Rectangle(( int )(displayX), ( int )(displayY),
                                                                                            ( int )(displayWidth), ( int )(displayHeight)));
                    }
                    else
                    {
                        int alphaDiff = ( int )Math.Ceiling(255.0f / (borderSize - amntSolid));     //How much to decrease alpha per layer
                        //Draw the solid bit
                        //mainG.DrawRectangle(new Pen(borderBrush, amntSolid), new Rectangle((int)(displayX), (int)(displayY),
                        //(int)(displayWidth), (int)(displayHeight)));

                        int alphaVal = 255;
                        alphaVal -= alphaDiff;

                        for (int i = 0; i <= borderSize; i++)
                        {
                            if (alphaVal < 0)
                            {
                                alphaVal = 0;
                            }
                            Color tmpCol = Color.FromArgb(alphaVal, borderBrush.Color);
                            Pen   pen    = new Pen(new SolidBrush(tmpCol), 1);
                            mainG.DrawRectangle(pen, new Rectangle(( int )(displayX + i), ( int )(displayY + i),
                                                                   ( int )(displayWidth - 2 * i), ( int )(displayHeight - 2 * i))); alphaVal -= alphaDiff;
                            alphaVal -= alphaDiff;
                            if (alphaVal < 0)
                            {
                                alphaVal = 0;
                            }
                        }
                    }
                }
            }
            else
            {
                //For all applicable entities (Entities with required components)
                foreach (Entity e in entities)
                {
                    drawEntity(e);
                }
                mainG.DrawImage(drawImg, new RectangleF(displayX, displayY, displayWidth, displayHeight), new RectangleF(x, y, width, height), GraphicsUnit.Pixel);
            }
        }