private void AddColorizers() { int locZ = 490; Colorizer color; color = new Colorizer(); color.Rect = ERectangleF.FromLTRB(98, 12, 549, 110); color.Color = System.Drawing.Color.FromArgb(0, 0, 255); color.LocZ = locZ; this.m_interfaceSprites.Add(color); color = new Colorizer(); color.Rect = ERectangleF.FromLTRB(98, 110, 549, 202); color.Color = System.Drawing.Color.FromArgb(0, 255, 255); color.LocZ = locZ; this.m_interfaceSprites.Add(color); color = new Colorizer(); color.Rect = ERectangleF.FromLTRB(98, 202, 549, 330); color.Color = System.Drawing.Color.FromArgb(0, 0, 255); color.LocZ = locZ; this.m_interfaceSprites.Add(color); color = new Colorizer(); color.Rect = ERectangleF.FromLTRB(98, 202, 549, 330); color.Color = System.Drawing.Color.FromArgb(255, 0, 255); color.LocZ = locZ; this.m_interfaceSprites.Add(color); }
public override void CalcInParent() { base.CalcInParent(); this.collisionLines = new ArrayList(); this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Left, this.Rect.Top, this.Rect.Right, this.Rect.Top)); this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Right, this.Rect.Top, this.Rect.Right, this.Rect.Bottom)); this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Left, this.Rect.Bottom, this.Rect.Right, this.Rect.Bottom)); this.collisionLines.Add(ERectangleF.FromLTRB(this.Rect.Left, this.Rect.Top, this.Rect.Left, this.Rect.Bottom)); }
private ERectangleF[,] CreateRectanglesFromCuttingRect(ERectangleF rct, EPointF fullSize) { ERectangleF[,] rects = new ERectangleF[3, 3]; float left = 0; float right = 0; for (int x = 0; x < 3; x++) { if (x == 0) { right = rct.Left; } else if (x == 1) { right = rct.Right; } else { right = fullSize.X; } float top = 0; float bottom = 0; for (int y = 0; y < 3; y++) { if (y == 0) { bottom = rct.Top; } else if (y == 1) { bottom = rct.Bottom; } else { bottom = fullSize.Y; } //if (!(bottom-top == 0 || right-left == 0)) //right-left: could be optimized outside this loop rects[x, y] = ERectangleF.FromLTRB(left, top, right, bottom); top = bottom; } left = right; } return(rects); }
public Player() { this.Color = GameMain.Instance.m_clrOffwhite; this.m_keys = new KeysSteering(KeysSteering.KeyPresets.ArrowsSpace); this.m_keys.AddKeyPreset(KeysSteering.KeyPresets.awsdCtrlShift); this.m_keys.KeyEvent += new KeyEventHandler(m_keys_KeyEvent); this.SetGraphics("Player"); this.CenterRegPoint(); ERectangleF rct = ERectangleF.FromLTRB(145, 418, 495, 419); Endogine.GameHelpers.BhConstrain bh = new Endogine.GameHelpers.BhConstrain(); bh.AddArea(rct, null, false, null); this.AddBehavior(bh); }
public GameMain() { Instance = this; string path = AppSettings.Instance.GetPath("Media") + "SpaceInv"; AppSettings.Instance.AddPath("Media", path); PicRef.ScanDirectory(path); this.m_clrOffwhite = System.Drawing.Color.FromArgb(214, 181, 140); this.m_interfaceSprites = new ArrayList(); this.m_score = new Score(); this.m_livesLeft = new LivesLeft(); Sprite sp = new Sprite(); sp.SetGraphics("Screen"); sp.LocZ = 500; sp.Ink = RasterOps.ROPs.AddPin; this.m_interfaceSprites.Add(sp); this.AddColorizers(); this.m_covers = new ArrayList(); Cover cover; for (int nCoverNum = 0; nCoverNum < 4; nCoverNum++) { cover = new Cover(); cover.Loc = new EPointF(170 + 90 + (nCoverNum - 1) * 90, 369); this.m_covers.Add(cover); } ERectangleF rctPlayArea = ERectangleF.FromLTRB(155, 20, 550, 400); //new ERectangleF(145,10,350,200); //155 550 this.m_invadersGrid = new InvadersGrid(); //ERectangleF rctPlayerConstraints = rctPlayArea+ERectangleF.FromLTRB(-10,0,-55,0); this.m_player = new Player(); }
public PlayArea() { //this.m_bNoScalingOnSetRect = true; m_spBg = new Sprite(); m_spBg.Name = "Bg"; m_spBg.MemberName = "PlayArea"; m_spBg.Parent = this; m_spBg.RegPoint = new EPoint(30, 30); m_spBgFill = new Sprite(); m_spBgFill.Parent = this; m_spBgFill.Name = "BgFill"; m_pathCalc = new PathCalc(this); Grid = new Grid(this); m_aCollisionLines = new ArrayList(); EPointF pntTopLeft = Grid.GetGfxLocFromGridLoc(new EPointF(-1f, -0.0f)); EPointF pntBottomRight = Grid.GetGfxLocFromGridLoc(new EPointF(Grid.GridSize.Width + 0.5f, Grid.GridSize.Height)); //first line is ceiling (where balls stick) m_aCollisionLines.Add(ERectangleF.FromLTRB(pntTopLeft.X, pntTopLeft.Y, pntBottomRight.X, pntTopLeft.Y)); m_aCollisionLines.Add(ERectangleF.FromLTRB(pntTopLeft.X, pntTopLeft.Y, pntTopLeft.X, pntBottomRight.Y)); m_aCollisionLines.Add(ERectangleF.FromLTRB(pntBottomRight.X, pntTopLeft.Y, pntBottomRight.X, pntBottomRight.Y)); m_aPlayers = new ArrayList(); AddPlayer(new Hashtable()); Hashtable htKeysForPlayer2 = new Hashtable(); htKeysForPlayer2.Add("left", System.Windows.Forms.Keys.A); htKeysForPlayer2.Add("right", System.Windows.Forms.Keys.D); htKeysForPlayer2.Add("up", System.Windows.Forms.Keys.W); htKeysForPlayer2.Add("shoot", System.Windows.Forms.Keys.S); AddPlayer(htKeysForPlayer2); //TODO: A fun cooperative mode would be to force players to take turns. //TODO: write a main game class which manages levels and multiple playAreas. m_level = new LevelManager(this); NextLevel(); }
public void SetLine(EPointF a_pnt1, EPointF a_pnt2) { m_rct = ERectangleF.FromLTRB(a_pnt1.X, a_pnt1.Y, a_pnt2.X, a_pnt2.Y); if (Member != null) { Member.Dispose(); } Loc = m_rct.Location; Bitmap bmp = new Bitmap((int)Math.Abs(m_rct.Width), (int)Math.Abs(m_rct.Height), PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bmp); //Point pnt1 = a_pnt1; //if (a_pnt1.Y <= a_pnt2.Y && a_pnt1.X <= a_pnt2.X) g.DrawLine(new Pen(Color.White, 1), new Point(0, 0), new Point((int)m_rct.Width, (int)m_rct.Height)); g.Dispose(); MemberSpriteBitmap mb = new MemberSpriteBitmap(bmp); Member = mb; }
private void PlayerBall_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t) { if (t == Sprite.MouseEventType.Down) { forceMarker.Visible = true; } else if (t == Sprite.MouseEventType.StillDown) { MemberSpriteBitmap mb = forceMarker.Member; if (mb != null) { mb.Dispose(); } //this.MouseDownLoc.X, this.MouseDownLoc.Y ERectangleF rctLine = ERectangleF.FromLTRB(this.Loc.X, this.Loc.Y, this.MouseLastLoc.X, this.MouseLastLoc.Y); forceVector = rctLine.Size; if (rctLine.Width != 0 && rctLine.Height != 0) { Bitmap bmp = new Bitmap((int)Math.Abs(rctLine.Width) + 1, (int)Math.Abs(rctLine.Height) + 1, System.Drawing.Imaging.PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(bmp); ERectangleF rctOrigo = rctLine.Copy(); rctOrigo.MakeTopLeftAtOrigo(); Pen pen = new Pen(Color.Red, 2); g.DrawLine(pen, rctOrigo.X, rctOrigo.Y, rctOrigo.X + rctOrigo.Width, rctOrigo.Y + rctOrigo.Height); g.Dispose(); EPointF locOffset = new EPointF(); if (rctOrigo.Width < 0) { locOffset.X = rctOrigo.Width; } if (rctOrigo.Height < 0) { locOffset.Y = rctOrigo.Height; } mb = new MemberSpriteBitmap(bmp); forceMarker.Member = mb; forceMarker.Loc = this.Loc + locOffset; } else { forceMarker.Member = null; } } else if (t == Sprite.MouseEventType.UpOutside || t == Sprite.MouseEventType.Click) { this.Velocity = forceVector * -0.1f; forceMarker.Visible = false; MemberSpriteBitmap mb = forceMarker.Member; if (mb != null) { forceMarker.Member = null; mb.Dispose(); } } }