Example #1
0
    // Use this for initialization
    void Start()
    {
        textRender = GetComponent <TextRender>();
        string Characters = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,0,1,2,3,4,5,6,7,8,9";

        ABC = Characters.Split(',');
    }
    override public void Draw(Color[] outbuf)
    {
        Color pageColor = new Color(192, 192, 192);

        Clear(outbuf, pageColor);
        for (int x = 0; x < charWidth; ++x)
        {
            for (int y = 0; y < charHeight; ++y)
            {
                int     sx = charX + x;
                int     sy = y;
                Color32 px = pixels[charWidth * y + x];
                if (px.a > 128)
                {
                    Color noAlpha = px;
                    outbuf[64 * sy + sx] = noAlpha;
                }
            }
        }

        TextRender.DrawString(outbuf, font, 1 - stringScrollPosition, 56, Color.black, lines[lineIndex].text);

        if (IsLineDone())
        {
            TextRender.DrawString(outbuf, font, 20, 48, Color.black, "[OK]");
        }
    }
Example #3
0
        public void Draw()
        {
            SpriteRender.ResetView(800, 600);
            SpriteRender.DrawRect(10, 10, 0.0f, healthBarWidth, 15, Color4.DarkRed);
            SpriteRender.DrawRect(10, 10, 0.0f, (health / 100) * healthBarWidth, 15, Color4.Red);

            if (score != 0)
            {
                TextRender.Draw(350f, 10f, 0.0f, score.ToString(), Fonts.Standard, Color4.White, 2f);
            }

            TextRender.Draw(500f, 10f, 0.0f, lives + "", Fonts.Standard, Color4.Yellow, 2f);
            TextRender.Draw(550f, 10f, 0.0f, tokens + "", Fonts.Standard, Color4.Yellow, 2f);

            if ((int)(inventory & InventoryItem.Key1) > 0)
            {
                SpriteRender.Draw(170, 5, 0, 20, 20, Textures.Key);
            }
            if ((int)(inventory & InventoryItem.Key2) > 0)
            {
                SpriteRender.Draw(200, 5, 0, 20, 20, Textures.Key);
            }
            if ((int)(inventory & InventoryItem.Key3) > 0)
            {
                SpriteRender.Draw(230, 5, 0, 20, 20, Textures.Key);
            }
            if ((int)(inventory & InventoryItem.Key4) > 0)
            {
                SpriteRender.Draw(260, 5, 0, 20, 20, Textures.Key);
            }
        }
Example #4
0
        /// <summary>
        /// 战斗胜利消息界面
        /// </summary>
        /// <param name="context"></param>
        /// <param name="top">消息显示Y坐标</param>
        /// <param name="msg"></param>
        public MsgScreen(SimulatorContext context, int top, string msg) : base(context)
        {
            byte[] msgData;
            try
            {
                msgData = msg.GetBytes();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                msgData = new byte[0];
            }

            ResImage side = Context.LibData.GetImage(2, 8);

            _messageImg = Context.GraphicsFactory.NewImageBuilder(msgData.Length * 8 + 8, 24);
            ICanvas canvas = Context.GraphicsFactory.NewCanvas(_messageImg);;

            canvas.DrawColor(Constants.COLOR_WHITE);
            side.Draw(canvas, 1, 0, 0);
            side.Draw(canvas, 2, _messageImg.Width - 3, 0);

            Paint paint = new Paint(PaintStyle.FILL_AND_STROKE, Constants.COLOR_BLACK);

            canvas.DrawLine(0, 1, _messageImg.Width, 1, paint);
            canvas.DrawLine(0, 22, _messageImg.Width, 22, paint);
            TextRender.DrawText(canvas, msgData, 4, 4);

            _left = (160 - _messageImg.Width) / 2;
            _top  = top;
        }
Example #5
0
            public ResolutionTestNode(State stateref, string name)
                : base(stateref, name)
            {
                Body        = new Body(this, "Body");
                Body.Bounds = new Vector2(70, 70);

                _physics = new Physics(this, "_physics");
                _physics.LinkDependency(Physics.DEPENDENCY_BODY, Body);
                _physics.Mass        = 10f;
                _physics.Restitution = 1f;
                _physics.Drag        = .95f;

                Shape = new AABB(this, "AABB");
                Shape.LinkDependency(AABB.DEPENDENCY_BODY, Body);

                Collision = new Collision(this, "Collision");
                Collision.LinkDependency(Collision.DEPENDENCY_SHAPE, Shape);
                Collision.LinkDependency(Collision.DEPENDENCY_PHYSICS, _physics);
                Collision.Initialize();

                _imageRender = new ImageRender(this, "Image", Assets.Pixel);
                _imageRender.LinkDependency(ImageRender.DEPENDENCY_BODY, Body);
                _imageRender.Scale = new Vector2(70, 70);
                _imageRender.Layer = .5f;

                _textBody = new Body(this, "_textBody");

                _textRender = new TextRender(this, "_textRender");
                _textRender.LinkDependency(TextRender.DEPENDENCY_BODY, _textBody);
                _textRender.Color = Color.White;
                _textRender.Font  = Assets.Font;
                _textRender.Text  = Name;
                _textRender.Layer = 1f;
            }
Example #6
0
        public override void Draw(ICanvas canvas)
        {
            canvas.DrawColor(Constants.COLOR_WHITE);
            canvas.DrawBitmap(Context.Util.bmpChuandai, 160 - Context.Util.bmpChuandai.Width, 0);

            // 画装备
            for (int i = 0; i < 8; i++)
            {
                if (_curEquipments[i] != null)
                {
                    _curEquipments[i].Draw(canvas, _pos[i].X + 1, _pos[i].Y + 1);
                }
            }
            canvas.DrawRect(_pos[_curItemIndex].X, _pos[_curItemIndex].Y, _pos[_curItemIndex].X + 25, _pos[_curItemIndex].Y + 25, Context.Util.sBlackPaint);
            TextRender.DrawText(canvas, _itemNames[_curItemIndex], 120, 80);

            // 画人物头像、姓名
            if (_curCharacterIndex >= 0)
            {
                PlayerCharacter p = Context.PlayContext.PlayerCharacters[_curCharacterIndex];
                p.DrawHead(canvas, 44, 12);
                TextRender.DrawText(canvas, p.Name, 30, 40);
            }

            if (_showingDesc)
            {
                canvas.DrawBitmap(_nameImg, 9, 10);
                canvas.DrawBitmap(_descImg, 9, 28);
                TextRender.DrawText(canvas, _nameText, 9 + 3, 10 + 3);
                _nextToDraw = TextRender.DrawText(canvas, _descText, _toDraw, _rectDesc);
            }
        }
Example #7
0
        public void RenderText(string text, float x, float y, float scale, vec3 color)
        {
            TextRender.BeginBatch();
            float c_Char = x;

            foreach (char c in text)
            {
                if (!Characters.ContainsKey(c))
                {
                    continue;
                }

                Character ch = Characters[c];

                float xpos = c_Char + ch.bearing.x * scale;
                float ypos = y - (ch.size.y - ch.bearing.y) * scale;

                float w = ch.size.x * scale;
                float h = ch.size.y * scale;

                TextRender.DrawText(new vec2(xpos, ypos + h), new vec2(w, -h), ch.textureID, color);

                // TODO: Do a decent bit shift and remove this Gap multiplication
                c_Char += ((ch.Advance * Gap) >> 6) * scale;
            }
            TextRender.EndBatch();
            TextRender.Flush();
        }
Example #8
0
 protected override void OnUnload()
 {
     shader.Dispose();
     mPlayer.Dispose();
     Render2D.ShutDown();
     TextRender.ShutDown();
     base.OnUnload();
 }
Example #9
0
 public override void Draw(ICanvas canvas)
 {
     canvas.DrawBitmap(_background, 12, 21);
     TextRender.DrawText(canvas, "金钱:" + _money, 15, 24);
     TextRender.DrawText(canvas, _goods.Name, 15, 40);
     TextRender.DrawText(canvas, ": " + (_goods.GoodsNum - _saleCount), 93, 40);
     TextRender.DrawText(canvas, "卖出个数 :" + _saleCount, 15, 56);
 }
Example #10
0
 public void TestTextReader()
 {
     Assert.AreEqual(TextRender.ChangeVowelCase("abceE"), "AbcEe");
     Assert.AreEqual(TextRender.ChangeVowelCase("sdf"), "sdf");
     Assert.AreEqual(TextRender.ChangeVowelCase("ыва"), "џвј");
     Assert.AreEqual(TextRender.ChangeVowelCase("цц"), "цц");
     Assert.AreEqual(TextRender.ChangeVowelCase(""), "");
 }
Example #11
0
 //================================================================
 //Methodes
 //================================================================
 #region
 public void Start()
 {
     if (TextRender == null || TextRender.Equals(""))
     {
         return;
     }
     isFinish = false;
 }
Example #12
0
        //================================================================
        //Methodes
        //================================================================

        //================================================================
        //Methodes overridde
        //================================================================

        public override void Draw(SpriteBatch spriteBatch)
        {
            if (Visible && !TextRender.Equals(""))
            {
                spriteBatch.DrawString(Font, TextRender, Position, Color.Lerp(Color, Color.Transparent, Alpha),
                                       Rotation, Origin, Scaling, Flip, 0);
            }
            base.Draw(spriteBatch);
        }
 public override void Draw(ICanvas canvas)
 {
     canvas.DrawBitmap(_background, 39, 29);
     TextRender.DrawText(canvas, _operateItems[_firstIndex], _strX, _strY);
     TextRender.DrawText(canvas, _operateItems[_firstIndex + 1], _strX, _strY + 16);
     TextRender.DrawText(canvas, _operateItems[_firstIndex + 2], _strX, _strY + 32);
     TextRender.DrawSelText(canvas, _operateItems[_selectedIndex], _strX, _selectedY);
     canvas.DrawBitmap(_arrowImgs[_arrowImgIndex], _arrowX, _arrowY);
 }
Example #14
0
        public override void Draw(ICanvas canvas)
        {
            canvas.DrawColor(Constants.COLOR_WHITE);
            TextRender.DrawText(canvas, _magic.Name, 0, _nameRect);
            PlayerCharacter character = Context.PlayContext.PlayerCharacters[_selectedCharacterIndex];

            character.DrawState(canvas, _curStatePageIndex);
            character.DrawHead(canvas, 5, 60);
        }
Example #15
0
 public override void Draw(ICanvas canvas)
 {
     canvas.DrawBitmap(_rectangleTopImg, 9, 3);
     TextRender.DrawText(canvas, "金钱:" + Context.PlayContext.Money, 9 + 3, 3 + 3);
     canvas.DrawBitmap(_rectangleLeftImg, 9, 3 + 16 + 6 - 1);
     TextRender.DrawText(canvas, _menuItemsText, 0, _menuItemsRect);
     TextRender.DrawSelText(canvas, _operateItems[_selectIndex], _menuItemsRect.Left,
                            _menuItemsRect.Top + _selectIndex * 16);
 }
Example #16
0
 //================================================================
 //Methodes overridde
 //================================================================
 #region
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (Visible && !TextRender.Equals(""))
     {
         string t = isFinish ? TextRender : GetTextRender();
         spriteBatch.DrawString(Font, t, Position, Color.Lerp(Color, Color.Transparent, Alpha),
                                Rotation, Origin, Scaling, Flip, 0);
     }
 }
Example #17
0
            /// <summary>
            /// 写一行
            /// </summary>
            /// <param name="row">行对象</param>
            /// <param name="cOffset">起始行</param>
            /// <param name="value">取值</param>
            protected void WriteToRow(IRow row, int cOffset, Func <String, Object> func)
            {
                ICell         cell;
                int           cStart    = cOffset;
                List <string> tmpFields = new List <string>();
                List <string> pos;

                //写内容
                foreach (string field in AllFields)
                {
                    cell = row.GetCell(cOffset++);

                    //如果是统计字段(而不是数据中提供的字段)则添加行统计
                    if (RowSumFields.ContainsKey(field))
                    {
                        tmpFields = RowSumFields[field];
                        pos       = new List <string>();
                        foreach (var item in tmpFields)
                        {
                            if (AllFields.Contains(item))
                            {
                                pos.Add(((char)('A' + cStart + AllFields.IndexOf(item))).ToString() + (row.RowNum + 1));
                            }
                        }
                        cell.SetCellFormula(string.Join("+", pos));
                        continue;
                    }

                    TextRender <object> textRender = null;
                    if (TextFields.Count > 0 && TextFields.TryGetValue(field, out textRender))
                    {
                        cell.SetCellValue(textRender.ValueRender(func(field)));
                    }
                    else if (DateTimeFields.Contains(field))
                    {
                        if (func(field) != null)
                        {
                            if (!string.IsNullOrEmpty(func(field).ToString()))
                            {
                                cell.SetCellValue(DateTime.Parse(func(field).ToString()));
                            }
                        }
                    }
                    else if (DoubleFields.Contains(field))
                    {
                        cell.SetCellValue(func(field) != null ? Double.Parse(func(field).ToString()) : 0);
                    }
                    else
                    {
                        if (func(field) != null)
                        {
                            cell.SetCellValue(func(field).ToString());
                        }
                    }
                }
            }
Example #18
0
        public void DrawDead()
        {
            var totalTime = endTime.Subtract(startTime);

            SpriteRender.ResetView(800, 600);
            TextRender.Draw(100f, 100f, 0f, "GAME OVER", Fonts.Standard, Color4.Red, 5f);
            TextRender.Draw(100f, 460f, 0f, "TIME: " + (int)totalTime.TotalMinutes + ":" + totalTime.Seconds.ToString("00"), Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 480f, 0f, "SCORE: " + lastscore, Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 500f, 0f, "HIGHSCORE: " + highscore, Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 520f, 0f, "PRESS ENTER TO PLAY AGAIN", Fonts.Standard, Color4.White, 2f);
        }
Example #19
0
        public Text(EntityState es, Vector2 position, string text, SpriteFont font) : base(es)
        {
            Body = new Body(this, position, Vector2.Zero);
            Components.Add(Body);

            Physics = new Physics(this);
            Components.Add(Physics);

            Render = new TextRender(this, font, text, position);
            Components.Add(Render);
        }
 public override void Draw(ICanvas canvas)
 {
     canvas.DrawColor(Constants.COLOR_WHITE);
     Context.PlayContext.PlayerCharacters[_characterIndex].DrawState(canvas, _statePageIndex);
     Context.PlayContext.PlayerCharacters[_characterIndex].DrawHead(canvas, 5, 60);
     if (_medicine.GoodsNum > 0)
     {
         _medicine.Draw(canvas, 5, 10);
         TextRender.DrawText(canvas, "" + _medicine.GoodsNum, 13, 35);
     }
 }
Example #21
0
        private void AssignUI(UI ui, string to)
        {
            switch (to)
            {
            case "descbar":
                Studybox  = ui;
                Studyline = ui.Children[0] as TextRender;
                break;

            default: break;
            }
        }
        public void Test_Truncate()
        {
            //input params
            string text   = "The test result contains a message that describes the failure. For the AreEquals method, message displays you what was expected (the (Expected<XXX>parameter) and what was actually received (the Actual<YYY> parameter). We were expecting the balance to decline from the beginning balance, but instead it has increased by the amount of the withdrawal.A reexamination of the Debit code shows that the unit test has succeeded in finding a bug.The amount of the withdrawal is added to the account balance when it should be subtracted.";
            int    length = 100;

            //act
            string actual   = TextRender.Truncate(text, length);
            string expected = text.Substring(0, length) + "...";

            Assert.AreEqual(expected, actual, true, "Truncate return value is not equal from expected value.");
        }
Example #23
0
        public Text(EntityState es, string name, SpriteFont font, string text, Vector2 position)
            : base(es, name)
        {
            Body = new Body(this, "Body", position);
            AddComponent(Body);

            Physics = new Physics(this, "Physics");
            AddComponent(Physics);

            TextRender = new TextRender(this, "TextRender", font, text);
            AddComponent(TextRender);
        }
Example #24
0
        public Text(EntityState es, string name)
            : base(es, name)
        {
            Body = new Body(this, "Body");
            AddComponent(Body);

            Physics = new Physics(this, "Physics");
            AddComponent(Physics);

            TextRender = new TextRender(this, "TextRender");
            AddComponent(TextRender);
        }
Example #25
0
        public Label(Node parent, string name)
            : base(parent, name)
        {
            Render = new TextRender(this, "Render", Assets.Font, name);
            Render.LinkDependency(TextRender.DEPENDENCY_BODY, Body);
            Render.Text  = name;
            Render.Layer = 1f;

            Body.Bounds  = Render.Font.MeasureString(Text);
            Render.Color = Color.Black;
            Selectable   = false;
        }
Example #26
0
        public void DrawEnd()
        {
            var totalTime = endTime.Subtract(startTime);

            SpriteRender.ResetView(800, 600);
            TextRender.Draw(100f, 100f, 0f, "CONGRATULATIONS", Fonts.Standard, Color4.Green, 5f);
            TextRender.Draw(100f, 150f, 0f, "", Fonts.Standard, Color4.White, 1.75f);
            TextRender.Draw(100f, 440f, 0f, "TIME: " + (int)totalTime.TotalMinutes + ":" + totalTime.Seconds.ToString("00"), Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 460f, 0f, "TOKENS: " + savedTokens, Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 480f, 0f, "SCORE: " + savedScore, Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 500f, 0f, "HIGHSCORE: " + highscore, Fonts.Standard, Color4.White, 2f);
            TextRender.Draw(100f, 520f, 0f, "PRESS ENTER TO PLAY AGAIN", Fonts.Standard, Color4.White, 2f);
        }
        public void Test_HighlightKeyWords()
        {
            //input params - text, keyword, css style, full match
            string text      = "he method is rather simple. We set up a new BankAccount object with a beginning balance and then withdraw a valid amount. We use the Microsoft unit test framework for managed code AreEqual";
            string keyword   = "BankAcc";
            string css       = "yellow";
            bool   isMatched = true;

            //act
            string actual   = TextRender.HighlightKeyWords(text, keyword, css, isMatched);
            string expected = "he method is rather simple. We set up a new <span style=\"background-color:yellow\">BankAcc</span>ount object with a beginning balance and then withdraw a valid amount. We use the Microsoft unit test framework for managed code AreEqual";

            Assert.AreEqual(expected, actual, true, "HighlightKeyWords value is not equal from expected value.");
        }
 public override void Draw(ICanvas canvas)
 {
     canvas.DrawBitmap(_background, 39, 39);
     if (_selectedId == 0)
     {
         TextRender.DrawSelText(canvas, _operateItems[0], 39 + 3, 39 + 3);
         TextRender.DrawText(canvas, _operateItems[1], 39 + 3, 39 + 3 + 16);
     }
     else if (_selectedId == 1)
     {
         TextRender.DrawText(canvas, _operateItems[0], 39 + 3, 39 + 3);
         TextRender.DrawSelText(canvas, _operateItems[1], 39 + 3, 39 + 3 + 16);
     }
 }
 public void DrawState(ICanvas canvas, int page)
 {
     canvas.DrawLine(37, 10, 37, 87, Context.Util.sBlackPaint);
     if (page == 0)
     {
         TextRender.DrawText(canvas, "等级   " + Level, 41, 4);
         TextRender.DrawText(canvas, "生命   " + HP + "/" + MaxHP, 41, 23);
         TextRender.DrawText(canvas, "真气   " + MP + "/" + MaxMP, 41, 41);
         TextRender.DrawText(canvas, "攻击力 " + Attack, 41, 59);
         TextRender.DrawText(canvas, "防御力 " + Defend, 41, 77);
     }
     else if (page == 1)
     {
         TextRender.DrawText(canvas, "经验值", 41, 4);
         int w = Context.Util.DrawSmallNum(canvas, CurrentExp, 97, 4);
         TextRender.DrawText(canvas, "/", 97 + w + 2, 4);
         Context.Util.DrawSmallNum(canvas, LevelupChain.GetNextLevelExp(Level), 97 + w + 9, 10);
         TextRender.DrawText(canvas, "身法   " + Speed, 41, 23);
         TextRender.DrawText(canvas, "灵力   " + Lingli, 41, 41);
         TextRender.DrawText(canvas, "幸运   " + Luck, 41, 59);
         StringBuilder sb  = new StringBuilder("免疫   ");
         StringBuilder tmp = new StringBuilder();
         if (HasBuff(CombatBuff.BUFF_MASK_DU))
         {
             tmp.Append('毒');
         }
         if (HasBuff(CombatBuff.BUFF_MASK_LUAN))
         {
             tmp.Append('乱');
         }
         if (HasBuff(CombatBuff.BUFF_MASK_FENG))
         {
             tmp.Append('封');
         }
         if (HasBuff(CombatBuff.BUFF_MASK_MIAN))
         {
             tmp.Append('眠');
         }
         if (tmp.Length > 0)
         {
             sb.Append(tmp);
         }
         else
         {
             sb.Append('无');
         }
         TextRender.DrawText(canvas, sb.ToString(), 41, 77);
     }
 }
Example #30
0
 public override void Draw(ICanvas canvas)
 {
     canvas.DrawBitmap(bg, 50, 14);
     for (int i = 0; i < itemsText.Length; i++)
     {
         if (i != curSel)
         {
             TextRender.DrawText(canvas, itemsText[i], 50 + 3, 14 + 3 + 16 * i);
         }
         else
         {
             TextRender.DrawSelText(canvas, itemsText[i], 50 + 3, 14 + 3 + 16 * i);
         }
     }
 }
Example #31
0
        public static void Main(string[] args)
        {
            // set starting stage
            stageNumber = 0;

            randomator = new Random();
            explosions = new List<Explosion>();

            //// build ships
            //
            ships = new List<ShipDrone>();

            // build secondary ship
            ShipDrone otherShip = new ShipDrone(VEL, ACC, ROT_VEL, ROT_ACC, SHIP_RADIUS, S_HEALTH, S_LIVES);
            otherShip.SetProjectile(PROJECTILE_ROF, PROJECTILE_VEL, PROJECTILE_RADIUS, PROJECTILE_MASS, PROJECTILE_DAMAGE);
            otherShip.Color = new byte[] { 255, 255, 255 };
            otherShip.ProjectileColor = new byte[] { 170, 170, 255 };
            otherShip.Id = 0;
            otherShip.SetShip(S0_START_X, S0_START_Y, S0_START_R);

            ships.Add(otherShip);

            // build main ship
            ShipDrone mainShip = new ShipDrone(VEL, ACC, ROT_VEL, ROT_ACC, SHIP_RADIUS, S_HEALTH, S_LIVES);
            mainShip.SetProjectile(PROJECTILE_ROF, PROJECTILE_VEL, PROJECTILE_RADIUS, PROJECTILE_MASS, PROJECTILE_DAMAGE);
            mainShip.Color = new byte[] { 255, 255, 255 };
            mainShip.ProjectileColor = new byte[] { 255, 255, 0 };
            mainShip.Id = 1;
            myShipID = mainShip.Id;
            mainShip.SetShip(S1_START_X, S1_START_Y, S1_START_R);

            ships.Add(mainShip);

            //// connect to server
            //
            connectedToServer = false;
            tcpConnection = new ClientTCP();

            try
            {
                if (args.Length < 1)
                {
                    tcpConnection.ConnectToServer(SERVER_IP_ADDRESS, SERVER_PORT);
                    Console.WriteLine("Connected to server at: " + SERVER_IP_ADDRESS + ":" + SERVER_PORT);
                }
                else
                {
                    tcpConnection.ConnectToServer(args[0], SERVER_PORT);
                    Console.WriteLine("Connected to server at: " + args[0] + ":" + SERVER_PORT);
                }
                connectedToServer = true;
                new GraphicsWindow(tcpConnection);
            }
            catch (Exception e)
            {
                Console.WriteLine("Unable to connect to server: \n" + e.ToString());
            }

            // send main ship information to server
            if(connectedToServer)
            {
                float[] shipSpecs = mainShip.RenderShip();
                tcpConnection.SendMessage("Join: DRONE x: " + shipSpecs[0] + " y: " + shipSpecs[1] + " r: " + shipSpecs[2] + "\n");
            }

            //// Main
            //
            using (var game = new GameWindow((int)(1600 / 1.25), (int)(1000 / 1.25)))
            {
                game.Load += (sender, e) =>
                {
                    game.VSync = VSyncMode.On;
                    // determine map size
                    mapWidth = TILE_SIZE * TILE_COUNT_WIDTH;
                    mapHeight = TILE_SIZE * TILE_COUNT_HEIGHT;

                    Console.WriteLine("Game started at: " + game.Width + "x" + game.Height + "on a " + mapWidth + "x" + mapHeight + " map.");

                    // collision detection grid
                    collisionGrid = new byte[TILE_COUNT_WIDTH + 1, TILE_COUNT_HEIGHT + 1][];

                    // set up star field
                    starField = CreateStarField(mapWidth, mapHeight, 1000, mapWidth * 2, mapWidth / 2);

                    ////  Graphics
                    //

                    // make background color the color of null space
                    GL.ClearColor(0.1f, 0.1f, 0.1f, 1.0f); // Set background color to black and opaque

                    // load textures
                    droneShipTex = LoadTexture("t_drone_ship1_shadow.png");
                    explosionTex = LoadTexture("t_explosion1.png");
                    carrierShipTex = LoadTexture("t_carrier_ship1.png");
                    starTex = LoadTexture("t_star1.png");
                    carrierShipUpperTex = LoadTexture("t_carrier_ship1_upper.png");
                    carrierShipLowerTex = LoadTexture("t_carrier_ship1_lower.png");
                    number1Tex = LoadTexture("t_1.png");
                    number2Tex = LoadTexture("t_2.png");
                    number3Tex = LoadTexture("t_3.png");
                    loseTex = LoadTexture("t_lose.png");
                    winTex = LoadTexture("t_win.png");
                    droneShip2Tex = LoadTexture("t_drone_ship2_shadow.png");
                    carrierShip2Tex = LoadTexture("t_carrier_ship2.png");
                    carrierShip2UpperTex = LoadTexture("t_carrier_ship2_upper.png");
                    carrierShip2LowerTex = LoadTexture("t_carrier_ship2_lower.png");
                    waitingTex = LoadTexture("t_waiting.png");

                    countdown = new Countdown(new int[] { number3Tex, number2Tex, number1Tex }, 160, 160); // 160 is dimension of number-pngs in pixels

                    GL.Enable(EnableCap.Texture2D);

                    // enable transparency

                    // ready the text
                    text = new TextRender(new Size(game.Width, game.Height), new Size(300, 100),  new Font(FontFamily.GenericMonospace, 15.0f));
                    text.AddLine("HEALTH " + (int) ((ships[myShipID].Health * 100) / S_HEALTH) + "%", new PointF(10, 10), new SolidBrush(Color.Red));
                    text.AddLine("LIVES " + ships[myShipID].Lives, new PointF(10, 40), new SolidBrush(Color.Red));

                    GL.Enable(EnableCap.Blend);
                    GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                   // GL.Disable(EnableCap.DepthTest);
                };

                //// Game resize?
                //
                game.Resize += (sender, e) =>
                {
                    GL.Viewport(0, 0, game.Width, game.Height);
                };

                //// Physics recalculation and keyboard updates
                //
                game.UpdateFrame += (sender, e) =>
                {
                    // collision detection grid
                    collisionGrid = new byte[TILE_COUNT_WIDTH + 1, TILE_COUNT_HEIGHT + 1][];

                    if (game.Keyboard[Key.Escape])
                    {
                        if (connectedToServer)
                        {
                            connectedToServer = false;
                            tcpConnection.Shutdown();
                            tcpConnection = null;
                        }
                        game.Exit();
                    }
                    if (game.Keyboard[Key.Up])
                    {
                        if(stageNumber == 1)
                            ships[myShipID].ThrottleOn();
                    }
                    if (game.Keyboard[Key.Left])
                    {
                        if (!ships[myShipID].FreezeShipMovement && stageNumber == 1)
                            ships[myShipID].TurnLeft();
                    }
                    if (game.Keyboard[Key.Right])
                    {
                        if (!ships[myShipID].FreezeShipMovement && stageNumber == 1)
                            ships[myShipID].TurnRight();
                    }
                    if (game.Keyboard[Key.Enter])
                    {
                        if (!ships[myShipID].FreezeShipMovement && stageNumber == 1)
                            ships[myShipID].FireProjectile();
                        //ships[0].FireShotgun();
                    }

                    if (game.Keyboard[Key.W])
                    {
                        if(myShipID == 0)
                            ships[1].ThrottleOn();
                        else
                            ships[0].ThrottleOn();
                    }
                    if (game.Keyboard[Key.A])
                    {
                        if (myShipID == 0)
                            ships[1].TurnLeft();
                        else
                            ships[0].TurnLeft();
                    }
                    if (game.Keyboard[Key.D])
                    {
                        if (myShipID == 0)
                            ships[1].TurnRight();
                        else
                            ships[0].TurnRight();
                    }
                    if (game.Keyboard[Key.Space])
                    {
                        if (myShipID == 0)
                            ships[1].FireProjectile();
                        else
                            ships[0].FireProjectile();
                    }

                    if(connectedToServer)
                        mainShip.CalculatePhysics(mapWidth, mapHeight);
                    else
                        foreach (ShipDrone ship in ships)
                        {
                            ship.CalculatePhysics(mapWidth, mapHeight);
                        }

                    foreach (ShipDrone ship in ships)
                    {
                        // if the ship collides with another ship, sometimes they get stuck, have them separate one to
                        // allow them to get unstuck
                        ShipDrone collidedWith = CollisionTest(ship);
                        if (collidedWith != null)
                        {
                            ship.CalculatePhysics(mapWidth, mapHeight);
                            collidedWith.CalculatePhysics(mapWidth, mapHeight);
                        }
                    }

                    // determine if ship is ready to move after respawn
                    if (ships[myShipID].FreezeShipMovement)
                    {
                        float[] xy = ships[myShipID].GetShipPosition();
                        double distance = Math.Sqrt((xy[0] - ships[myShipID].StartingCoordinates[0]) * (xy[0] - ships[myShipID].StartingCoordinates[0]) + (xy[1] - ships[myShipID].StartingCoordinates[1]) * (xy[1] - ships[myShipID].StartingCoordinates[1]));

                        if (distance > DISTANCE_UNFREEZE)
                            ships[myShipID].FreezeShipMovement = false;

                    }

                    for (int i = 0; i < explosions.Count; i++)
                    {
                        if (!(explosions[i].CalculateStreams()))
                            explosions.RemoveAt(i);
                    }

                    // advance the countdown frame, start the game when ready.
                    if (stageNumber == 0)
                        if (countdown.OneFrame())
                            stageNumber = 1;

                    // tell server of updates.
                    // specifically of main ship's coordinates and projectiles
                    if(connectedToServer)
                    {
                        //Console.WriteLine("Sending...");

                        StringBuilder sb = new StringBuilder();
                        float[] shipSpecs = mainShip.RenderShip();
                        foreach(float[] projectileSpecs in mainShip.GetNewProjectiles())
                        {
                            // missing [3], [4], [5]
                            sb.Append(" P: " + projectileSpecs[0] + " " + projectileSpecs[1] + " " + projectileSpecs[2]);
                        }
                        mainShip.ClearNewProjectiles();
                        tcpConnection.SendMessage("Update: DRONE x: " + shipSpecs[0] + " y: " + shipSpecs[1] + " r: " + shipSpecs[2] + sb.ToString() + "\n");
                    }
                };

                //// Render game
                //
                game.RenderFrame += (sender, e) =>
                {

                    // always begins with GL.Clear() and ends with a call to SwapBuffers
                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                    GL.MatrixMode(MatrixMode.Projection);
                    GL.LoadIdentity();
                    // game window follows the ship
                    float[] shipCoord = ships[myShipID].RenderShip();
                    GL.Ortho(shipCoord[0] - game.Width / 2, shipCoord[0] + game.Width / 2, shipCoord[1] - game.Height / 2, shipCoord[1] + game.Height / 2, -1.0, 0.0);
                    //GL.Ortho(0, game.Width, 0, game.Height, -1.0, 0.0);
                    GL.MatrixMode(MatrixMode.Modelview);

                    //text.Draw();

                    RenderBackground(mapWidth, mapHeight);

                    foreach (ShipDrone ship in ships)
                    {
                        if (ship.FreezeShipMovement)
                        {
                            //// The main drone ship should be wedged between the top part of the carrier and the carrier's bay
                            //
                            RenderCarrierShip("lower", ship);
                            RenderParticles(ship.RenderShipParticles());
                            RenderDroneShip(ship.Color, ship);
                            RenderCarrierShip("upper", ship);
                        }
                        else
                        {
                            RenderCarrierShip(ship);
                        }
                    }

                    foreach (ShipDrone ship in ships)
                    {
                        // do not render drone ship if in carrier.  Previously rendered.
                        if (!ship.FreezeShipMovement)
                            RenderParticles(ship.RenderShipParticles());
                    }

                    foreach (ShipDrone ship in ships)
                    {
                        RenderProjectiles(ship.ProjectileColor, ship);
                        // do not render drone ship if in carrier.  Previously rendered.
                        if (!ship.FreezeShipMovement)
                            RenderDroneShip(ship.Color, ship);
                    }

                    /*if (ships[myShipID].FreezeShipMovement)
                    {
                        //                    RenderCollisionGrid();

                        //// The main drone ship should be wedged between the top part of the carrier and the carrier's bay
                        //
                        RenderCarrierShip("lower", ships[0]);
                        RenderParticles(ships[myShipID].RenderShipParticles());
                        RenderDroneShip(ships[myShipID].Color, ships[myShipID]);
                        RenderCarrierShip("upper", ships[0]);

                        foreach (ShipDrone ship in ships)
                        {
                            // do not render player's drone ship's exhaust particles, rendered previously
                            if (ship.Id != myShipID)
                                RenderParticles(ship.RenderShipParticles());
                            RenderParticles(ship.RenderProjectileParticles());
                        }

                        foreach (ShipDrone ship in ships)
                        {
                            RenderProjectiles(ship.ProjectileColor, ship);
                            // do not render player's drone ship, rendered previously
                            if (ship.Id != myShipID)
                                RenderDroneShip(ship.Color, ship);
                        }

                    }
                    else
                    {

                        RenderCarrierShip(ships[0]);
                        //                    RenderCollisionGrid();

                        foreach (ShipDrone ship in ships)
                        {
                            RenderParticles(ship.RenderShipParticles());
                            RenderParticles(ship.RenderProjectileParticles());
                        }

                        foreach (ShipDrone ship in ships)
                        {
                            RenderProjectiles(ship.ProjectileColor, ship);
                            RenderDroneShip(ship.Color, ship);
                        }
                    }
                    */
                    foreach (Explosion explosion in explosions)
                    {
                        RenderParticles(explosion.RenderParticles());
                        RenderExplosion(explosion.Color, explosion);
                    }

                    // render text, anything drawn after text will be in relation to the screen and not the game grid
                    text.Draw();

                    if (stageNumber == 0)
                        RenderCountdown(game.Width, game.Height);

                    if (stageNumber == 2)
                        RenderEndScreen(game.Width, game.Height);

                    game.SwapBuffers(); // draw the new matrix

                };

                // Run the game at 60 updates per second
                game.Run(60.0);
            }
        }