コード例 #1
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
        public GameObject(string objType, string animTopLeft, string animTop, string animTopRight, string animLeft, string animStay, string animRight, 
            string animBottomLeft, string animBottom, string animBottomRight, string x, string y, string z, string speedX, string speedY, string speedZ, string ghostYorN)
        {
            this.ObjectType = objType;

            BaseObject[0, 0] = animTopLeft;
            BaseObject[1, 0] = animTop;
            BaseObject[2, 0] = animTopRight;

            BaseObject[0, 1] = animLeft;
            BaseObject[1, 1] = animStay;
            BaseObject[2, 1] = animRight;

            BaseObject[0, 2] = animBottomLeft;
            BaseObject[1, 2] = animBottom;
            BaseObject[2, 2] = animBottomLeft;

            CurrentObject = animStay;

            Location = new Point3D(Convert.ToInt32(x), Convert.ToInt32(y), Convert.ToInt32(z));

            Speed = new Point3D(Convert.ToInt32(speedX), Convert.ToInt32(speedY), Convert.ToInt32(speedZ));

            this.Ghost = ghostYorN == "Y";
        }
コード例 #2
0
ファイル: GraphicObject.cs プロジェクト: anlugifa/GameEngine
        public void DrawGraphic(ref Hashtable graphicLibrary, int frameNumber, Point3D location, Size objSize, ref Bitmap image)
        {
            if (location.X >= 0 || location.Y >= 0 ||
                location.X + ((Bitmap)graphicLibrary[BaseImage]).Width >= 0 ||
                location.Y + ((Bitmap)graphicLibrary[BaseImage]).Height >= 0 &&
                location.X > NumberOfFrames)
                frameNumber -= NumberOfFrames;

            var gfx = Graphics.FromImage(image);

            var grab = FrameInitialOffset;
            if (Vertical)
            {
                grab.Y = FrameInitialOffset.Y + FrameSize.Height * (frameNumber - 1);
            }
            else
            {
                grab.X = FrameInitialOffset.X + FrameSize.Width * (frameNumber - 1);
            }

            var destRec = new Rectangle(location.X, location.Y, objSize.Width, objSize.Height);
            var srcRec = new Rectangle(grab, FrameSize);

            gfx.DrawImage(graphicLibrary[BaseImage] as Bitmap, destRec, srcRec, GraphicsUnit.Pixel);
        }
コード例 #3
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
        // Only for one animation
        public GameObject(string objType, string animStay, string x, string y, string z, string speedX, string speedY, string speedZ, string ghostYorN)
        {
            this.AutoChangeAnimation = false;
            this.ObjectType = objType;

            CurrentObject = animStay;

            Location = new Point3D(Convert.ToInt32(x), Convert.ToInt32(y), Convert.ToInt32(z));

            Speed = new Point3D(Convert.ToInt32(speedX), Convert.ToInt32(speedY), Convert.ToInt32(speedZ));

            this.Ghost = ghostYorN == "Y";
        }
コード例 #4
0
ファイル: Camera.cs プロジェクト: anlugifa/GameEngine
        public Camera(Point3D offset, Size resolution, Rectangle drawLocation, CameraType cameraStyle)
        {
            this.Offset = offset;

            this.CameraScreen = new Bitmap(resolution.Width, resolution.Height);

            this.DrawLocation = drawLocation;

            this.StartZDraw = 0;
            this.EndZDraw = 20;

            this.CameraStyle = cameraStyle;

            this.ShowBackground = true;
        }
コード例 #5
0
ファイル: Camera.cs プロジェクト: anlugifa/GameEngine
 public void MoveCameraRelative(Point3D newOffset)
 {
     this.Offset.X += newOffset.X;
     this.Offset.Y += newOffset.Y;
     this.Offset.Z += newOffset.Z;
 }
コード例 #6
0
ファイル: Camera.cs プロジェクト: anlugifa/GameEngine
 public void MoveCameraActual(Point3D newOffset)
 {
     this.Offset = newOffset;
 }
コード例 #7
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
 public void Move(Point3D offset)
 {
     Location.X += offset.X;
     Location.Y += offset.Y;
     Location.Z += offset.Z;
 }
コード例 #8
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
 public void SetLocationRelative(Point3D offset)
 {
     Location.X += offset.X;
     Location.Y += offset.Y;
     Location.Z += offset.Z;
 }
コード例 #9
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
 public void SetGravity(Point3D gravityLevel)
 {
     this.Gravity = gravityLevel;
 }
コード例 #10
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
 public void SetLocationActual(Point3D location)
 {
     this.Location = location;
 }
コード例 #11
0
ファイル: GameObject.cs プロジェクト: anlugifa/GameEngine
        public void Redraw(Camera cam, ref Hashtable graphicLibrary, ref Hashtable graphicObjects)
        {
            int xOffset = 0;

            var currentObject = graphicObjects[CurrentObject] as GraphicObject;

            if (MaxFrame == 0)
            {
                MaxFrame = currentObject.NumberOfFrames;

                if (ObjectSize.Width == -1 || AutoSizeWithAnimation)
                {
                    ObjectSize = currentObject.FrameSize;
                }
            }

            if (cam.CameraStyle == CameraType.Left3D)
                xOffset += Location.Z;
            else if (cam.CameraStyle == CameraType.Right3D)
                xOffset -= Location.Z;
            else
                xOffset = 0;

            var location = new Point3D(Location.X - cam.Offset.X + xOffset, Location.Y - cam.Offset.Y, Location.Z);
            currentObject.DrawGraphic(ref graphicLibrary, CurrentFrame, location, ObjectSize, ref cam.CameraScreen);
        }
コード例 #12
0
ファイル: GameWorld.cs プロジェクト: anlugifa/GameEngine
 public void SetGravity(string group, bool includeGhosts, Point3D gravityLevel)
 {
     foreach(GameObject item in WorldObjects)
     {
         if (includeGhosts || !item.Ghost)
         {
             if (group == "All")
             {
                 item.SetGravity(gravityLevel);
             }
             else
             {
                 if (item.ObjectType == group)
                     item.SetGravity(gravityLevel);
             }
         }
     }
 }
コード例 #13
0
ファイル: GameWorld.cs プロジェクト: anlugifa/GameEngine
        /// <summary>
        /// Draws the current environment into all cameras
        /// </summary>
        public void Frame()
        {
            foreach (Camera cam in WorldCameras)
            {
                // Check boundaries
                var offset = new Point3D(cam.Offset.X, cam.Offset.Y, cam.Offset.Z);

                if (offset.X > LevelSize.Width) // intuitivo
                {
                    offset.X = 0;
                }
                else if (cam.Offset.X + cam.CameraScreen.Width > LevelSize.Width)
                {
                    offset.X = LevelSize.Width - cam.CameraScreen.Width;
                }

                if (offset.Y > LevelSize.Height) // intuitivo
                {
                    offset.Y = 0;
                }
                else if (cam.Offset.Y + cam.CameraScreen.Height > LevelSize.Height)
                {
                    offset.Y = LevelSize.Height - cam.CameraScreen.Height;
                }

                cam.MoveCameraActual(offset);

                if (cam.ShowBackground)
                    Background.Redraw(cam, LevelSize);

                // Draw items in z-order
                int currentZOrder = cam.StartZDraw;
                while (currentZOrder < cam.EndZDraw) // intuitivo
                {
                    foreach(GameObject item in WorldObjects)
                    {
                        if (item.Location.Z == currentZOrder)
                            item.Redraw(cam, ref GraphicLibrary, ref GraphicObjects);
                    }

                    currentZOrder++;
                }

                // Draw Foreground

                Foreground.Redraw(cam, LevelSize);
            }
        }
コード例 #14
0
ファイル: GameWorld.cs プロジェクト: anlugifa/GameEngine
        /// <summary>
        /// Check if a single point touched the bump map array.
        /// </summary>
        /// <param name="location">The point to test.</param>        
        /// <returns>True if touchs</returns>
        public bool CheckBumpMap(ref Point3D location)
        {
            if (BumpMapSize.X > 0) // intuitivo
            {
                if (location.X > 0 && location.Y > 0)
                {
                    int leftX = location.X / BumpMapSize.X;
                    int leftY = location.Y / BumpMapSize.Y;

                    return BumpMap[leftX, leftY] != 0;
                }
            }

            return false;
        }
コード例 #15
0
ファイル: GameWorld.cs プロジェクト: anlugifa/GameEngine
        /// <summary>
        /// Check to see if any part of an object  has toouched a '1' inside of bump map array. All four corners of the objet are tested.        
        /// 
        /// </summary>
        /// <param name="location">Object location</param>
        /// <param name="objSize">Object size</param>
        /// <returns>True if is has touched</returns>
        public bool CheckBumpMap(ref Point3D location, ref Size objSize)
        {
            if (BumpMapSize.X > 0) // intuitivo
            {
                if (location.X > 0 && location.Y > 0)
                {
                    // test two corners
                    int leftX = location.X / BumpMapSize.X;
                    int leftY = location.Y / BumpMapSize.Y;

                    int rightX = (location.X + objSize.Width) / BumpMapSize.X;
                    int rightY = (location.Y + objSize.Height) / BumpMapSize.Y;

                    return BumpMap[leftX, leftY] != 0 || BumpMap[rightX, rightY] != 0;
                }
            }

            return false;
        }