Beispiel #1
0
 public Cursor()
 {
     Graphic = Image.CreateCircle(10, FP.Color(0x553366));
     (Graphic as Image).CenterOrigin();
     FP.Screen.SetMouseCursorVisible(false);
     Layer = -10000;
 }
Beispiel #2
0
        public StartButton()
        {
            Type   = "ButtonState";
            Button = Image.CreateRect(400, 200, FP.Color(0xFFFFFF));
            var Title = new Text("Start", 0, 0, 0, 0);

            Title.Size  = 100;
            Title.Color = FP.Color(0x000000);
            var Instructions = new Text("Instructions: W,A,S,D Control, Right Mouse to Shoot, Left Mouse to Grab Floating Parts.", 0, 0, 0, 0);

            AddGraphic(Button);
            AddGraphic(Title);
            AddGraphic(Instructions);

            Instructions.CenterOO();
            Instructions.Size  = 20;
            Instructions.Color = FP.Color(0xffffff);
            Instructions.X    -= 450;
            Instructions.Y    -= 200;
            Title.CenterOO();
            Title.X -= 125;
            Title.Y -= 75;
            SetHitboxTo(Button);
            CenterOrigin();
            Button.CenterOO();
            Button.CenterOrigin();
            X = FP.HalfWidth;
            Y = FP.HalfHeight + 100;
            FP.Log(Instructions.X, Instructions.Y);
        }
Beispiel #3
0
        private void RenderEntities()
        {
            if (_debug)
            {
                var verts = new SFML.Graphics.VertexArray(SFML.Graphics.PrimitiveType.Lines);

//				var g:Graphics = _entScreen.graphics,
//					sx:Number = FP.screen.scaleX * FP.screen.scale,
//					sy:Number = FP.screen.scaleY * FP.screen.scale;
//				g.clear();

                var scale = FP.Camera.Zoom;
                foreach (var e in SCREEN_LIST)
                {
                    // If the Entity is not selected.
//					if (SELECT_LIST.indexOf(e) < 0)
//					{
//						 Draw the normal hitbox and position.

                    var color  = FP.Color(0xff0000);
                    var x      = e.X - e.OriginX - (FP.Camera.X - FP.HalfWidth);
                    var y      = e.Y - e.OriginY - (FP.Camera.Y - FP.HalfHeight);
                    var width  = e.Width;
                    var height = e.Height;

                    if (e.Width != 0 && e.Height != 0)
                    {
                        if (e.Mask != null)
                        {
                            e.Mask.RenderDebug(verts);
                        }

                        Draw.Rect(x, y, width, height, color);
                    }

                    color  = FP.Color(0x00ff00);
                    x      = e.X - (FP.Camera.X - FP.HalfWidth) - 3;
                    y      = e.Y - (FP.Camera.Y - FP.HalfHeight) - 3;
                    width  = 6;
                    height = 6;

                    Draw.Rect(x, y, width, height, color);
//					}
//					else
//					{
//						// Draw the selected hitbox and position.
//						if (e.width && e.height)
//						{
//							g.lineStyle(1, 0xFFFFFF);
//							g.drawRect((e.x - e.originX - FP.camera.x) * sx, (e.y - e.originY - FP.camera.y) * sy, e.width * sx, e.height * sy);
//							if (e.mask) e.mask.renderDebug(g);
//						}
//						g.lineStyle(1, 0xFFFFFF);
//						g.drawRect((e.x - FP.camera.x) * sx - 3, (e.y - FP.camera.y) * sy - 3, 6, 6);
//					}
                }

                FP.Screen.Draw(verts);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="text">Text to display</param>
        /// <param name="x">X offset</param>
        /// <param name="y">Y offset</param>
        /// <param name="width">Image width (leave as 0 to size to the starting text string).</param>
        /// <param name="height">Image height (leave as 0 to size to the starting text string).</param>
        public Text(string text, float x = 0, float y = 0, uint width = 0, uint height = 0)
        {
            if (Text.font == null)
            {
                Text.font = Library.GetFont("Punk.Embeds/DefaultFont.ttf");
            }

            _field.Font            = Text.font;
            _field.CharacterSize   = Text.size;
            _field.Color           = FP.Color(0xFFFFFF);
            _field.DisplayedString = text;
            if (width == 0)
            {
                width = (uint)_field.GetGlobalBounds().Width;
            }
            if (height == 0)
            {
                height = (uint)_field.GetGlobalBounds().Height;
            }
            _source = new Texture(width, height);
            base.Init(_source);
            updateBuffer();
            this.X = x;
            this.Y = y;

            //TODO: Take this out once text field rects are in.
            // This _width and _height refers to the size of the text field rect.
            _width  = width;
            _height = height;
        }
Beispiel #5
0
 public override void Load(System.Xml.XmlNode node)
 {
     base.Load(node);
     Type    = Collision;
     Graphic = Image.CreateRect(Width, Height, FP.Color(0x000000));
     face    = (DoorFace)Enum.Parse(typeof(DoorFace), node.Attributes["DoorFace"].Value);
 }
Beispiel #6
0
 public override void Added()
 {
     base.Added();
     Type       = "Ship";
     ShipCenter = Image.CreateRect(64, 64, FP.Color(0xffffff));
     ShipCenter.CenterOO();
     X = FP.HalfWidth;
     Y = FP.HalfHeight;
 }
Beispiel #7
0
 public override void Added()
 {
     base.Added();
     World.Add(new Part(this, 1, 0, 0));
     Type       = "EmptyShip";
     ShipCenter = Image.CreateRect(64, 64, FP.Color(0xffffff));
     ShipCenter.CenterOO();
     X = FP.Rand(SpaceWorld.WorldLength);
     Y = FP.Rand(SpaceWorld.WorldHeight);
 }
Beispiel #8
0
        /// <summary>
        /// Updates the tween.
        /// </summary>
        public override void Update()
        {
            base.Update();

            var r     = Convert.ToUInt32(FP.Clamp(_startR + _rangeR * _t, 0, 255));
            var g     = Convert.ToUInt32(FP.Clamp(_startG + _rangeG * _t, 0, 255));
            var b     = Convert.ToUInt32(FP.Clamp(_startB + _rangeB * _t, 0, 255));
            var color = r << 16 | g << 8 | b;

            Color = FP.Color(color);
        }
Beispiel #9
0
 public Bullet(float x, float y, Vector2f VelocityIn, Entity ShipIn)
     : base(x, y, Punk.SpaceWorld.WorldLength, Punk.SpaceWorld.WorldHeight)
 {
     Type    = "Bullet";
     Graphic = BulletShot = Image.CreateCircle(2, FP.Color(0x4083FF));
     X       = x;
     Y       = y;
     BulletShot.CenterOO();
     SetHitboxTo(BulletShot);
     CenterOrigin();
     myShip   = ShipIn as Ship;
     Velocity = VelocityIn + myShip.Velocity;
 }
Beispiel #10
0
        public override void Load(System.Xml.XmlNode node)
        {
            base.Load(node);
            Graphic = Image.CreateRect(64, 64, FP.Color(0x66FF33));
            Type    = "platform";

            foreach (System.Xml.XmlNode n in node)
            {
                FP.Log(int.Parse(n.Attributes["x"].Value) + " " + float.Parse(n.Attributes["y"].Value));
                positionNodes.Add(new Vector2i(int.Parse(n.Attributes["x"].Value), int.Parse(n.Attributes["y"].Value)));
            }
            if (positionNodes.Count > 0)
            {
                currentPosition = positionNodes[0];
                MoveToNextPos();
            }

            SetHitbox(64, 64, 0, 0);
        }
Beispiel #11
0
        public override void Update()
        {
            base.Update();
            if ((World as Room).RoomsAreLoading)
            {
                (Graphic as Image).Color = FP.Color(0xFF00AA);
            }
            else
            {
                (Graphic as Image).Color = FP.Color(0xFF0000);
            }
            if (Collide(Player.CollisionType, X, Y) != null)
            {
                FP.Log("Collided with player");

                if (!(World as Room).RoomsAreLoading && Input.Pressed(Keyboard.Key.W))
                {
                    (World as Room).NextRoom(this);
                }
            }
        }
Beispiel #12
0
        public override void Update()
        {
            if (Input.Down(Keyboard.Key.Escape))
            {
                FP.Screen.Close();
            }

            if (Input.Down(Keyboard.Key.Escape))
            {
                base.Update();
            }
            if (Input.Down(Keyboard.Key.Left))
            {
                Camera.X -= 10;
            }
            else if (Input.Down(Keyboard.Key.Right))
            {
                Camera.X += 10;
            }
            if (Input.Down(Keyboard.Key.Up))
            {
                Camera.Y -= 10;
            }
            else if (Input.Down(Keyboard.Key.Down))
            {
                Camera.Y += 10;
            }
            if (Input.Down(Keyboard.Key.PageDown))
            {
                Camera.Zoom -= 1 * FP.Elapsed;
            }
            else if (Input.Down(Keyboard.Key.PageUp))
            {
                Camera.Zoom += 1 * FP.Elapsed;
            }
            FP.Engine.ClearColor = FP.Color(0x123410);
        }
Beispiel #13
0
        public override void Update()
        {
            base.Update();

            if (isFirst)
            {
                GetType("Door", Doors);
                roomLoader.Start();
                isFirst = false;

                List <Entity> l = new List <Entity>();

                Add(player = new Player(300, 300, 1));
                GetType("PlayerSpawn", l);
                //FP.Log(l[0].);
                player.X = l[0].X + player.HalfWidth;
                player.Y = l[0].Y + player.HalfHeight;
            }

            if (Input.Down(Keyboard.Key.Escape))
            {
                FP.Screen.Close();
            }
            if (Input.Down(Keyboard.Key.PageDown))
            {
                Camera.Zoom -= 1 * FP.Elapsed;
            }
            else if (Input.Down(Keyboard.Key.PageUp))
            {
                Camera.Zoom += 1 * FP.Elapsed;
            }

            //FP.Log(roomLoader.IsAlive);

            FP.Engine.ClearColor = FP.Color(0x123410);
        }
Beispiel #14
0
        public void Enable()
        {
            // Quit if the console is already enabled.
            if (_enabled)
            {
                return;
            }

            // Enable it and add the Sprite to the stage.
            _enabled = true;
//			FP.engine.addChild(_sprite);

            // Used to determine some text sizing.
            var big = FP.Width >= 480;

            // The transparent FlashPunk logo overlay bitmap.
            background       = Image.CreateRect(FP.Width, FP.Height, FP.Color(0x0));
            background.Alpha = BG_ALPHA;
            background.CenterOO();

            logo       = new Image(Library.GetTexture("Punk.Embeds/console_logo.png"));
            logo.Alpha = LOGO_ALPHA;
            logo.CenterOO();


//			_sprite.addChild(_back);
//			_back.bitmapData = new BitmapData(width, height, true, 0xFFFFFFFF);
//			var b:BitmapData = (new CONSOLE_LOGO).bitmapData;
//			FP.matrix.identity();
//			FP.matrix.tx = Math.max((_back.bitmapData.width - b.width) / 2, 0);
//			FP.matrix.ty = Math.max((_back.bitmapData.height - b.height) / 2, 0);
//			FP.matrix.scale(Math.min(width / _back.bitmapData.width, 1), Math.min(height / _back.bitmapData.height, 1));
//			_back.bitmapData.draw(b, FP.matrix, null, BlendMode.MULTIPLY);
//			_back.bitmapData.draw(_back.bitmapData, null, null, BlendMode.INVERT);
//			_back.bitmapData.colorTransform(_back.bitmapData.rect, new ColorTransform(1, 1, 1, 0.5));
//
//			// The entity and selection sprites.
//			_sprite.addChild(_entScreen);
//			_entScreen.addChild(_entSelect);
//
//			// The entity count text.
//			_sprite.addChild(_entRead);
//			_entRead.addChild(_entReadText);
//			_entReadText.defaultTextFormat = format(16, 0xFFFFFF, "right");
//			_entReadText.embedFonts = true;
//			_entReadText.width = 100;
//			_entReadText.height = 20;
//			_entRead.x = width - _entReadText.width;
//
//			// The entity count panel.
//			_entRead.graphics.clear();
//			_entRead.graphics.beginFill(0, .5);
//			_entRead.graphics.drawRoundRectComplex(0, 0, _entReadText.width, 20, 0, 0, 20, 0);
//
//			// The FPS text.
//			_sprite.addChild(_fpsRead);
//			_fpsRead.addChild(_fpsReadText);
//			_fpsReadText.defaultTextFormat = format(16);
//			_fpsReadText.embedFonts = true;
//			_fpsReadText.width = 70;
//			_fpsReadText.height = 20;
//			_fpsReadText.x = 2;
//			_fpsReadText.y = 1;
//
//			// The FPS and frame timing panel.
//			_fpsRead.graphics.clear();
//			_fpsRead.graphics.beginFill(0, .75);
//			_fpsRead.graphics.drawRoundRectComplex(0, 0, big ? 320 : 160, 20, 0, 0, 0, 20);
//
//			// The frame timing text.
//			if (big) _sprite.addChild(_fpsInfo);
//			_fpsInfo.addChild(_fpsInfoText0);
//			_fpsInfo.addChild(_fpsInfoText1);
//			_fpsInfoText0.defaultTextFormat = format(8, 0xAAAAAA);
//			_fpsInfoText1.defaultTextFormat = format(8, 0xAAAAAA);
//			_fpsInfoText0.embedFonts = true;
//			_fpsInfoText1.embedFonts = true;
//			_fpsInfoText0.width = _fpsInfoText1.width = 60;
//			_fpsInfoText0.height = _fpsInfoText1.height = 20;
//			_fpsInfo.x = 75;
//			_fpsInfoText1.x = 60;
//
//			// The memory usage
//			_fpsRead.addChild(_memReadText);
//			_memReadText.defaultTextFormat = format(16);
//			_memReadText.embedFonts = true;
//			_memReadText.width = 110;
//			_memReadText.height = 20;
//			_memReadText.x = _fpsInfo.x + _fpsInfo.width + 5;
//			_memReadText.y = 1;
//
//			// The output log text.
//			_sprite.addChild(_logRead);
//			_logRead.addChild(_logReadText0);
//			_logRead.addChild(_logReadText1);
//			_logReadText0.defaultTextFormat = format(16, 0xFFFFFF);
//			_logReadText1.defaultTextFormat = format(big ? 16 : 8, 0xFFFFFF);
//			_logReadText0.embedFonts = true;
//			_logReadText1.embedFonts = true;
//			_logReadText0.selectable = false;
//			_logReadText0.width = 80;
//			_logReadText0.height = 20;
//			_logReadText1.width = width;
//			_logReadText0.x = 2;
//			_logReadText0.y = 3;
//			_logReadText0.text = "OUTPUT:";
//			_logHeight = height - 60;
//			_logBar = new Rectangle(8, 24, 16, _logHeight - 8);
//			_logBarGlobal = _logBar.clone();
//			_logBarGlobal.y += 40;
//			if (big) _logLines = _logHeight / 16.5;
//			else _logLines = _logHeight / 8.5;
//
//			// The debug text.
//			_sprite.addChild(_debRead);
//			_debRead.addChild(_debReadText0);
//			_debRead.addChild(_debReadText1);
//			_debReadText0.defaultTextFormat = format(16, 0xFFFFFF);
//			_debReadText1.defaultTextFormat = format(8, 0xFFFFFF);
//			_debReadText0.embedFonts = true;
//			_debReadText1.embedFonts = true;
//			_debReadText0.selectable = false;
//			_debReadText0.width = 80;
//			_debReadText0.height = 20;
//			_debReadText1.width = 160;
//			_debReadText1.height = int(height / 4);
//			_debReadText0.x = 2;
//			_debReadText0.y = 3;
//			_debReadText1.x = 2;
//			_debReadText1.y = 24;
//			_debReadText0.text = "DEBUG:";
//			_debRead.y = height - (_debReadText1.y + _debReadText1.height);
//
//			// The button panel buttons.
//			_sprite.addChild(_butRead);
//			_butRead.addChild(_butDebug = new CONSOLE_DEBUG);
//			_butRead.addChild(_butOutput = new CONSOLE_OUTPUT);
//			_butRead.addChild(_butPlay = new CONSOLE_PLAY).x = 20;
//			_butRead.addChild(_butPause = new CONSOLE_PAUSE).x = 20;
//			_butRead.addChild(_butStep = new CONSOLE_STEP).x = 40;
//			updateButtons();
//
//			// The button panel.
//			_butRead.graphics.clear();
//			_butRead.graphics.beginFill(0, .75);
//			_butRead.graphics.drawRoundRectComplex(-20, 0, 100, 20, 0, 0, 20, 20);

            // Default the display to debug view
            Debug = true;

            // Set the state to unpaused.
            Paused = false;
        }
Beispiel #15
0
        public override void RenderDebug(VertexArray vertexArray)
        {
            base.RenderDebug(vertexArray);

            Draw.Rect(Parent.X + X, Parent.Y + Y, Width, Height, FP.Color(0xff0000));
        }