Example #1
0
        public void Update()
        {
            List <TouchData> touches = Touch.GetData(0);

            foreach (TouchData data in touches)
            {
                currentTouchStatus = data.Status;                 // never gets used

                float xPos = (data.X + 0.5f) * screenWidth;
                float yPos = screenHeight - ((data.Y + 0.5f) * screenHeight);

                if (data.Status == TouchStatus.Move)
                {
//					Console.WriteLine("x : " +  xPos);
//					Console.WriteLine("y : " +  yPos);
                    position = new Vector2(xPos, yPos);
                    touching = true;
                }
                else
                {
                    touching = false;
                }
            }
            previousTouchData = currentTouchStatus;             // never gets used
            sprite.Position   = position;
            sprite.CenterSprite();
        }
Example #2
0
        public void initPause()
        {
            this.Camera2D.SetViewFromViewport();

            if (sprite_button_returntogame == null)
            {
                sprite_button_returntogame = new SpriteUV(new TextureInfo("/Application/data/button_returntogame.png"));
            }

            sprite_button_returntogame.CenterSprite(new Vector2(0.5f, 0.5f));
            sprite_button_returntogame.Scale    = sprite_button_returntogame.TextureInfo.TextureSizef * 1.5f;
            sprite_button_returntogame.Position = new Vector2(960.0f / 2.0f, 544.0f / 2.0f + 100.0f);

            if (sprite_button_returntomenu == null)
            {
                sprite_button_returntomenu = new SpriteUV(new TextureInfo("/Application/data/button_returntomenu.png"));
            }

            sprite_button_returntomenu.CenterSprite(new Vector2(0.5f, 0.5f));
            sprite_button_returntomenu.Scale    = sprite_button_returntomenu.TextureInfo.TextureSizef * 1.5f;
            sprite_button_returntomenu.Position = new Vector2(960.0f / 2.0f, 544.0f / 2.0f - 100.0f);

            Foreground.AddChild(sprite_button_returntogame);
            Foreground.AddChild(sprite_button_returntomenu);
        }
        private static Vector2 newTouchPos = new Vector2(0.0f, 0.0f);           // Position of last touch on screen

        public ObstacleSeasaw(Scene scene)
        {
            //Initialise Variables
            _scale         = 1.00f;
            _rotationSpeed = -0.015f;
            _rotateLeft    = false;

            //SpriteSheet Info
            _textureInfo = new TextureInfo("/Application/textures/Seasaw.png");

            //Create Sprite
            _sprite        = new SpriteUV();
            _sprite        = new SpriteUV(_textureInfo);
            _sprite.Quad.S = _textureInfo.TextureSizef;
            _sprite.Scale  = new Vector2(_scale, _scale);
            _sprite.CenterSprite();
            _sprite.Position = new Vector2(400.0f, 70.0f);


            _hypotenuse   = (_textureInfo.TextureSizef.X * _scale);
            _angle        = 0.55f;
            _angle2       = (float)((System.Math.PI / 2) - _angle);
            _opposite     = (float)System.Math.Cos(_angle2) * _hypotenuse;
            _adjacent     = (float)System.Math.Tan(_angle) * _opposite;
            _sprite.Angle = _angle;

            //Add to the current scene.
            scene.AddChild(_sprite);
        }
Example #4
0
        public static void love_graphics_draw(TextureInfo drawable, float x, float y, float r, float sx, float sy, float ox, float oy)
        {
            // create a new sprite
            var sprite = new SpriteUV()
            {
                TextureInfo = drawable
            };

            // make the texture 1:1 on screen
            sprite.Quad.S = drawable.TextureSizef;

            // center the sprite around its own .Position
            // (by default .Position is the lower left bit of the sprite)
            sprite.CenterSprite(TRS.Local.TopLeft);

            // our scene only has 2 nodes: scene->sprite
            scene.AddChild(sprite);

            sprite.Position = new Vector2(x - ox, 544 - y + oy);
            sprite.Pivot    = new Vector2(ox, -oy);
            sprite.Scale    = new Vector2(sx, sy);
            sprite.Rotate(-r);
            sprite.BlendMode = BlendMode.Normal;
            sprite.Color     = setColor;
        }
Example #5
0
        //Public functions.
        public Player(Scene scene, float floorHeight)
        {
            //Initialise Variables
            _frameTime      = 0;
            _animationDelay = 3;
            _speed          = 3.0f;
            _size           = 115.0f;
            _scale          = 1.00f;
            _angle          = 0.0f;
            _gravity        = -1.98f;
            _force          = 25.0f;
            _floorHeight    = floorHeight;
            _velocity       = new Vector2(0.0f, 0.0f);
            _movementVector = new Vector2(0.0f, 0.0f);
            _jumpingVector  = new Vector2(0.0f, 0.0f);
            _jumpVelocity   = new Vector2(0.0f, 0.0f);
            _jump           = false;
            _dead           = false;
            _killed         = false;
            _killedByFire   = false;

            //SpriteSheet Info
            _textureInfo           = new TextureInfo("/Application/textures/stick2.png");
            _noOnSpritesheetWidth  = 4;
            _noOnSpritesheetHeight = 2;
            _defaultYPos           = ((_textureInfo.TextureSizef.Y / _noOnSpritesheetHeight) * _scale) * 0.5f;
            _widthCount            = 0;
            _heightCount           = _noOnSpritesheetHeight - 1;

            _fireDeathTextureInfo    = new TextureInfo("/Application/textures/deathSpriteFire.png");
            _noOnFDSpritesheetWidth  = 4;
            _noOnFDSpritesheetHeight = 4;
            _counter       = _noOnFDSpritesheetWidth * _noOnFDSpritesheetHeight;
            _fDwidthCount  = 0;
            _fDheightCount = _noOnFDSpritesheetHeight - 1;

            //Create Sprite
            _sprite          = new SpriteUV();
            _sprite          = new SpriteUV(_textureInfo);
            _sprite.UV.S     = new Vector2(1.0f / _noOnSpritesheetWidth, 1.0f / _noOnSpritesheetHeight);
            _sprite.Quad.S   = new Vector2(_size, _size);
            _sprite.Scale    = new Vector2(_scale, _scale);
            _sprite.Position = new Vector2((Director.Instance.GL.Context.GetViewport().Width / 2) - 400, _defaultYPos + _floorHeight);
            _sprite.CenterSprite();

            _fireDeathSprite          = new SpriteUV();
            _fireDeathSprite          = new SpriteUV(_fireDeathTextureInfo);
            _fireDeathSprite.UV.S     = new Vector2(1.0f / _noOnFDSpritesheetWidth, 1.0f / _noOnFDSpritesheetHeight);
            _fireDeathSprite.Quad.S   = new Vector2(_size, _size);
            _fireDeathSprite.Scale    = new Vector2(1.5f, 1.5f);
            _fireDeathSprite.Position = _sprite.Position;
            _fireDeathSprite.CenterSprite();

            //Add to the current scene.
            scene.AddChild(_sprite);
            scene.AddChild(_fireDeathSprite);

            _fireDeathSprite.Visible = false;
        }
        private SpriteUV sprite;               //The background sprite

        public Background(Scene scene, Vector2 centrePos)
        {
            backgroundTexture = new TextureInfo("/Application/textures/LevelBackgrounds/bground.png");

            sprite        = new SpriteUV();
            sprite        = new SpriteUV(backgroundTexture);
            sprite.Quad.S = backgroundTexture.TextureSizef;
            //sprite.Pivot  = new Vector2(sprite.Quad.S.X, sprite.Quad.S.Y);
            sprite.CenterSprite(new Vector2(0.5f, 0.5f));
            sprite.Position = centrePos;
            sprite.Angle    = 0.0f;

            scene.AddChild(sprite);
        }
        public GameObjectAbstract(string spriteFilePath)
        {
            TextureInfo texture_info = new TextureInfo(new Texture2D(spriteFilePath, false) );
            sprite = new SpriteUV() {TextureInfo = texture_info};
            sprite.Quad.S = texture_info.TextureSizef;
            sprite.CenterSprite();
            sprite.Position = new Vector2(100,100);

            velocity =  new Vector2(0,0);
            mass = 10.0f;

            isAlive = false;

            lifeTime = 0;
        }
Example #8
0
        public Player(Scene scene, Vector2 spawnPoint)
        {
            textureInfo = new TextureInfo("/Application/textures/ninja2.png");             //Load in our lovely duck texture

            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;   //Might need to make smaller or bigger in the future
            sprite.Position = spawnPoint;                 //Starting position (will be changed)
            sprite.CenterSprite(new Vector2(0.5f, 0.5f)); //Set the origin of the sprite to the centre of the duck
            sprite.Scale = new Vector2(0.5f, 0.5f);
            sprite.Angle = 0.0f;
            alive        = true;      //Default alive true

            scene.AddChild(sprite);   //Add our FABULOUS duck to the scene
        }
Example #9
0
        public Bullet()
        {
            //starting position - calculated from the position of the player
            Vector2 startingPosition = Player.Instance.Position + (new Vector2(0.2f, 0.0f).Rotate(Player.Instance.playerBodySprite.Rotation));

            //offset,so the bullet would appear at the end of the riffle - could use improvement
            Vector2 offsetPosition = new Vector2(0.0f, 0.5f);

            //rotate the offset by the same angle the player is rotated by
            offsetPosition = offsetPosition.Rotate(Player.Instance.playerBodySprite.Rotation);

            //calculate final position from the starting position and the offset
            Position = startingPosition + offsetPosition;

            //step the bullet takes each tick
            step = (Position - startingPosition) * 1.5f;

            //if the bullet texture has not been created yet, create it
            if (Bullet.bulletTexture == null)
            {
                Bullet.bulletTexture = AppMain.ttCreateTexture(1, 1, 0xff00ffff);
            }

            //the bullet itself is made from two fireTexture textures
            //one white in the middle
            //and second one black as a shadow

            //TODO - make sure that bulletTexture is not used
            SpriteUV sprite = new SpriteUV();

            sprite.TextureInfo = new TextureInfo(fireTexture);
            sprite.Scale       = new Vector2(0.1f, 0.1f);
            sprite.Color       = Colors.White;
            sprite.CenterSprite(new Vector2(0.5f, 0.5f));


            SpriteUV shadow = new SpriteUV(new TextureInfo(Bullet.fireTexture));

            shadow.CenterSprite(new Vector2(0.5f, 0.5f));
            shadow.Color = Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.SetAlpha(Colors.Black, 0.5f);
            shadow.Scale = new Vector2(0.4f, 0.4f);
            this.AddChild(shadow);


            this.AddChild(sprite);
        }
Example #10
0
        protected static void SetUpScene(BaseScene scene, string filename, ref SpriteUV sprite,
                                         float cameraHeight, Vector2 cameraCenter,
                                         Vector2i numOftiles)
        {
            scene.Camera2D.SetViewFromHeightAndCenter(cameraHeight, cameraCenter);

            var texture_info = new TextureInfo(new Texture2D(filename, false), numOftiles, TRS.Quad0_1);

            sprite.TextureInfo = texture_info;

            sprite.Quad.S = texture_info.TextureSizef;

            sprite.CenterSprite();

            sprite.Position = scene.Camera.CalcBounds().Center;

            scene.AddChild(sprite);
        }
        public Tank(Scene scene)
        {
            // Tank Base
            texture2D   = new Texture2D("/Application/Assets/tankBase2.png", false);
            numTiles    = new Vector2i(1, 1);      // tiles in the sprite sheet
            tiles       = new Vector2i(0, 0);      // tile you are displaying
            textureInfo = new TextureInfo(texture2D, numTiles);
            sprite      = new SpriteTile(textureInfo);

            sprite.Quad.S      = new Vector2(textureInfo.TextureSizef.X, textureInfo.TextureSizef.Y);
            sprite.TileIndex2D = tiles;             // sets which tile you are viewing
            sprite.CenterSprite();

            // tank turret
            turretTex     = new TextureInfo("/Application/Assets/tankTurret2.png");
            turret        = new SpriteUV(turretTex);
            turret.Quad.S = turretTex.TextureSizef;
            turret.CenterSprite(TRS.Local.Center);

            if (SceneManager.Instance.rand.NextDouble() > 0.5)
            {
                leftRight = true;
                sprite.Rotate((float)System.Math.PI / 2);
                //turret.Rotate((float)System.Math.PI/2);
            }
            else
            {
                leftRight = false;
                sprite.Rotate(-(float)System.Math.PI / 2);
                //turret.Rotate(-(float)System.Math.PI/2);
            }

            speed    = (float)SceneManager.Instance.rand.NextDouble() * 800.0f;
            position = new Vector2(300.0f, 300.0f);
            minSpeed = 100;
            maxSpeed = 200;
            setRandom();


            scene.AddChild(sprite);
            scene.AddChild(turret);
        }
Example #12
0
        public AmmoItem(Vector2 pos)
        {
            //assign the position of the item
            Position = pos;

            //create a new texture if one doesn't exist yet
            if (AmmoItem.ammoTexture == null)
            {
                ammoTexture = new Texture2D("/Application/data/tiles/ammo.png", false);
            }

            //create a sprite for this specific ammo item
            SpriteUV sprite = new SpriteUV();

            sprite.TextureInfo = new TextureInfo(AmmoItem.ammoTexture);
            sprite.Scale       = new Vector2(0.5f, 0.5f);
            sprite.Pivot       = new Vector2(0.5f, 0.5f);

            //rotate by a random angle
            sprite.Rotation = sprite.Rotation.Rotate(Support.random.Next(-180, 180));

            //schedule this sprite to rotate every frame by a fraction of an angle
            sprite.Schedule((dt) => {
                sprite.Rotate(0.01f);
            }, -1);

            //create an underlying shadow for the item
            SpriteUV shadow = new SpriteUV(new TextureInfo(Bullet.fireTexture));

            shadow.CenterSprite(new Vector2(0.25f, 0.25f));
            shadow.Color = Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.SetAlpha(Colors.Yellow, 0.5f);
            shadow.Scale = new Vector2(2.0f, 2.0f);

            //add a shadow and a sprite to this GameEntity
            this.AddChild(shadow);
            this.AddChild(sprite);

            //calculate the bounds of this AmmoItem
            bounds = new Bounds2();
            sprite.GetlContentLocalBounds(ref bounds);
        }
Example #13
0
        public static void Main(string[] args)
        {
            RayTraceBenchmark.Console.WriteLineCallback = print;
            RayTraceBenchmark.BenchmarkMain.SaveImageCallback = drawImage;
            RayTraceBenchmark.BenchmarkMain.Start();

            // Render results
            Director.Initialize();

            Scene scene = new Scene();
            scene.Camera.SetViewFromViewport();

            var width = Director.Instance.GL.Context.GetViewport().Width;
            var height = Director.Instance.GL.Context.GetViewport().Height;

            Image img = new Image(ImageMode.Rgba, new ImageSize(width,height),
                                 new ImageColor(255,0,0,0));
            img.DrawText(printValue,
                        new ImageColor(255,0,0,255),
                        new Font(FontAlias.System,170,FontStyle.Regular),
                        new ImagePosition(0,150));

            Texture2D texture = new Texture2D(width,height,false,
                                             PixelFormat.Rgba);
            texture.SetPixels(0,img.ToBuffer());
            img.Dispose();

            TextureInfo ti = new TextureInfo();
            ti.Texture = texture;

            SpriteUV sprite = new SpriteUV();
            sprite.TextureInfo = ti;

            sprite.Quad.S = ti.TextureSizef;
            sprite.CenterSprite();
            sprite.Position = scene.Camera.CalcBounds().Center;

            scene.AddChild(sprite);

            Director.Instance.RunWithScene(scene);
        }
Example #14
0
        public Seasaw(Scene scene, float xPos, float floorHeight)
        {
            //Initialise Variables
            rand = new Random();

            _scale         = 1.00f;
            _rotationSpeed = 0.01f;
            _scaleLimiter  = 0.3f;
            _tempScale     = 1.0f;
            _rotateLeft    = false;
            _onObstacle    = false;
            _floorHeight   = floorHeight;
            _defaultYPos   = floorHeight + 45.0f;


            //SpriteSheet Info
            _textureInfo = new TextureInfo("/Application/textures/Seasaw.png");

            //Create Sprite
            _sprite        = new SpriteUV();
            _sprite        = new SpriteUV(_textureInfo);
            _sprite.Quad.S = _textureInfo.TextureSizef;
            _sprite.Scale  = new Vector2(_scale, _scale);
            _sprite.CenterSprite();
            _sprite.Position = new Vector2(xPos + 180, _defaultYPos);

            _hypotenuse   = (_textureInfo.TextureSizef.X * _scale);
            _angle        = -0.32f;
            _angle2       = (FMath.PI / 2) - _angle;
            _opposite     = FMath.Cos(_angle2) * _hypotenuse;
            _adjacent     = FMath.Tan(_angle) * _opposite;
            _sprite.Angle = _angle;
            _scalerValue  = _tempScale / (_angle * 10);

            _trap = new Trap(scene, new Vector2(xPos, 60.0f));
            _pit  = new Pit(scene, new Vector2(xPos, 60));

            //Add to the current scene.
            scene.AddChild(_sprite);
        }
Example #15
0
        public override void Tick(float dt)
        {
            Enemy tempEnemy;


            //check the collision with the walls
            if (Collisions.checkWallsCollisions(this, MapManager.Instance.currentMap, ref step))
            {
                //play a sound
                SoundSystem.Instance.Play("wallhit2.wav");
                float scale = 0.5f;


                //try a texture in place of the bullethole
                SpriteUV bulletHole = new SpriteUV();
                bulletHole.TextureInfo = new TextureInfo(fireTexture);
                bulletHole.Scale       = new Vector2(0.15f, 0.15f);
                bulletHole.Color       = Colors.Black;
                bulletHole.CenterSprite(new Vector2(0.5f, 0.5f));
                bulletHole.Position = Position + step;

                //remove the bulletHole after half a second
                bulletHole.ScheduleInterval((at) => bulletHole.Parent.RemoveChild(bulletHole, true), 0.5f, -1);

                //add the bullethole to the background
                Game.Instance.Background.AddChild(bulletHole);

                //remove this bullet
                this.Parent.RemoveChild(this, true);

                Game.Instance.bulletList.Remove(this);

                //die
                this.Die();
            }
            else if (Collisions.checkEnemiesCollisions(this, Game.Instance.enemyList, step, out tempEnemy))
            {
                //reduce the health of the enemy the bullet hit
                tempEnemy.health -= bulletDamage;

                float scale = 0.5f;
                //particles!

                //create and start the particle emmiter

                /*Particles fire_node= new Particles( 10 );
                 * ParticleSystem fire = fire_node.ParticleSystem;
                 *
                 * fire.TextureInfo = new TextureInfo( fireTexture );
                 * fire.Emit.Velocity = step;
                 * fire.Emit.VelocityVar = new Vector2( 2.0f, 2.0f );
                 * fire.Emit.ForwardMomentum = 0.0f;
                 * fire.Emit.AngularMomentun = 0.0f;
                 * fire.Emit.LifeSpan = 0.5f;
                 * fire.Emit.WaitTime = 0.0f;
                 * float s = 0.0f;
                 * fire_node.Position = Position+step;
                 * fire.Emit.PositionVar = new Vector2(s,s);
                 * fire.Emit.ColorStart = Colors.Red;
                 * fire.Emit.ColorStartVar = new Vector4(0.0f,0.0f,0.0f,0.0f);
                 * fire.Emit.ColorEnd = Colors.Red;
                 * fire.Emit.ColorEndVar = new Vector4(0.2f,0.0f,0.0f,0.0f);
                 * fire.Emit.ScaleStart = 0.3f * scale;
                 * fire.Emit.ScaleStartRelVar = 0.2f;
                 * fire.Emit.ScaleEnd = 0.6f * scale;
                 * fire.Emit.ScaleEndRelVar = 0.2f;
                 * fire.Simulation.Fade = 0.5f;
                 * fire.Simulation.Gravity = 0.0f;
                 *
                 * fire.Emit.Transform = fire_node.GetWorldTransform();
                 * fire.Emit.TransformForVelocityEstimate = fire_node.GetWorldTransform();
                 * fire.RenderTransform = Director.Instance.CurrentScene.GetWorldTransform(); // most probably identity
                 *
                 * Director.Instance.CurrentScene.AddChild(fire_node);
                 *
                 * Director.Instance.CurrentScene.RegisterDisposeOnExit(fire);
                 *
                 * //remove the particle emmiter after 0.5 seconds
                 * fire_node.ScheduleInterval((at) => Director.Instance.CurrentScene.RemoveChild(fire_node,true),0.5f,1);
                 */
                this.Parent.RemoveChild(this, true);

                Game.Instance.bulletList.Remove(this);

                this.Die();
            }
            else
            {
                //no collisions with anything,move the bullet
                Position += step;
            }
        }
Example #16
0
    static void Main(string[] args)
    {
        Log.SetToConsole();

                #if EASY_SETUP
        // initialize GameEngine2D's singletons
        Director.Initialize();
                #else // #if EASY_SETUP
        // create our own context
        Sce.Pss.Core.Graphics.GraphicsContext context = new Sce.Pss.Core.Graphics.GraphicsContext();

        // maximum number of sprites you intend to use (not including particles)
        uint sprites_capacity = 500;

        // maximum number of vertices that can be used in debug draws
        uint draw_helpers_capacity = 400;

        // initialize GameEngine2D's singletons, passing context from outside
        Director.Initialize(sprites_capacity, draw_helpers_capacity, context);
                #endif // #if EASY_SETUP

        Director.Instance.GL.Context.SetClearColor(Colors.Grey20);

        // set debug flags that display rulers to debug coordinates
//		Director.Instance.DebugFlags |= DebugFlags.DrawGrid;
        // set the camera navigation debug flag (press left alt + mouse to navigate in 2d space)
        Director.Instance.DebugFlags |= DebugFlags.Navigate;

        // create a new scene
        var scene = new Scene();

        // set the camera so that the part of the word we see on screen matches in screen coordinates
        scene.Camera.SetViewFromViewport();

        // create a new TextureInfo object, used by sprite primitives
        var texture_info = new TextureInfo(new Texture2D("/Application/Sample/GameEngine2D/HelloSprite/king_water_drop.png", false));

        // create a new sprite
        var sprite = new SpriteUV()
        {
            TextureInfo = texture_info
        };

        // make the texture 1:1 on screen
        sprite.Quad.S = texture_info.TextureSizef;

        // center the sprite around its own .Position
        // (by default .Position is the lower left bit of the sprite)
        sprite.CenterSprite();

        // put the sprite at the center of the screen
        sprite.Position = scene.Camera.CalcBounds().Center;
        //sprite.Scale = Vector2.One * 0.9f;
        // our scene only has 2 nodes: scene->sprite
        scene.AddChild(sprite);

                #if EASY_SETUP
        Director.Instance.RunWithScene(scene);
                #else // #if EASY_SETUP
        // handle the loop ourself

        Director.Instance.RunWithScene(scene, true);

        while (!Input2.GamePad0.Cross.Press)
        {
            Sce.Pss.Core.Environment.SystemEvents.CheckEvents();

                        #if EXTERNAL_INPUT
            // it is not needed but you can set external input data if you want

            List <TouchData> touch_data_list = Touch.GetData(0);
            Input2.Touch.SetData(0, touch_data_list);

            GamePadData pad_data = GamePad.GetData(0);
            Input2.GamePad.SetData(0, pad_data);
                        #endif // #if EXTERNAL_INPUT

            Director.Instance.Update();
//			Debug.WriteLine("===============>" + Director.Instance.SpriteRenderer);
            Director.Instance.Render();

            Director.Instance.GL.Context.SwapBuffers();
            Director.Instance.PostSwap();             // you must call this after SwapBuffers

//			System.Console.WriteLine( "Director.Instance.DebugStats.DrawArraysCount " + Director.Instance.GL.DebugStats.DrawArraysCount );
        }
                #endif // #if EASY_SETUP

        Director.Terminate();

        System.Console.WriteLine("Bye!");
    }
        public LoadingScreen(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene) : base(scene)
        {
//			loadingTexture0     = new TextureInfo("/Application/textures/LoadingScreens/Level0Load.png");
//			loadingTexture1     = new TextureInfo("/Application/textures/LoadingScreens/Level1Load.png");
//			loadingTexture2     = new TextureInfo("/Application/textures/LoadingScreens/Level2Load.png");
//			loadingTexture3     = new TextureInfo("/Application/textures/LoadingScreens/Level3Load.png");
//			loadingTexture4     = new TextureInfo("/Application/textures/LoadingScreens/Level4Load.png");
//			loadingTexture5     = new TextureInfo("/Application/textures/LoadingScreens/Level5Load.png");
//			loadingTexture6     = new TextureInfo("/Application/textures/LoadingScreens/Level6Load.png");
//			loadingTexture7     = new TextureInfo("/Application/textures/LoadingScreens/Level7Load.png");
//			loadingTexture8     = new TextureInfo("/Application/textures/LoadingScreens/Level8Load.png");
//			loadingTexture9     = new TextureInfo("/Application/textures/LoadingScreens/Level9Load.png");
//			loadingTexture10    = new TextureInfo("/Application/textures/LoadingScreens/Level10Load.png");
//			loadingTexture11    = new TextureInfo("/Application/textures/LoadingScreens/Level11Load.png");
//			loadingTexture12    = new TextureInfo("/Application/textures/LoadingScreens/Level12Load.png");
//			loadingTexture13    = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture14  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture15  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture16  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture17  = new TextureInfo("/Application/textures/LoadingScreens/Level0Load.png");
//			//loadingTexture18	= new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture19  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture20  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture21  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture22  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture23  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture24  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture25  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");
//			//loadingTexture26  = new TextureInfo("/Application/textures/LoadingScreens/Level13Load.png");

            textureInfo     = AppMain.loadingTexture0;
            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(-5000.0f, -5000.0f);
            sprite.CenterSprite(new Vector2(0.5f, 0.5f));

            loadingLabel           = new Sce.PlayStation.HighLevel.UI.Label();
            loadingLabel.X         = 804.0f;
            loadingLabel.Y         = 503.0f;
            loadingLabel.Text      = "Loading...";
            loadingLabel.TextColor = new UIColor(0.0f, 0.0f, 0.0f, 1.0f);
            uiScene.RootWidget.AddChildLast(loadingLabel);

            levelLabel           = new Sce.PlayStation.HighLevel.UI.Label();
            levelLabel.X         = 15.0f;
            levelLabel.Y         = 503.0f;
            levelLabel.Text      = "";
            levelLabel.TextColor = new UIColor(1.0f, 1.0f, 1.0f, 1.0f);
            //levelLabel.Font = new UIFont(FontAlias.System, 32, FontStyle.Regular);
            uiScene.RootWidget.AddChildLast(levelLabel);

            loadingSymbol = new BusyIndicator(true);
            loadingSymbol.SetPosition(910, 495);
            loadingSymbol.SetSize(48, 48);
            loadingSymbol.Anchors = Anchors.Height | Anchors.Width;
            uiScene.RootWidget.AddChildLast(loadingSymbol);
            loadingSymbol.Start();

            readyButton = new Button();
            readyButton.SetPosition(860, 490);
            readyButton.Text = "PLAY";
            readyButton.SetSize(88, 48);
            readyButton.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            readyButton.ButtonAction         += HandleButtonAction;
            readyButton.Visible = false;
            uiScene.RootWidget.AddChildLast(readyButton);

            readyButton2 = new Button();
            readyButton2.SetPosition(190, 450);
            readyButton2.Text = "JOIN X";
            readyButton2.SetSize(88, 48);
            readyButton2.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            readyButton2.ButtonAction         += HandleButtonAction;
            readyButton2.Visible = false;
            uiScene.RootWidget.AddChildLast(readyButton2);

            scene.AddChild(sprite);
            UISystem.SetScene(uiScene);

            startBox.Min = new Vector2(sprite.Position.X + loadingLabel.X - 500, sprite.Position.Y + loadingLabel.Y - 500);
            startBox.Max = new Vector2(sprite.Position.X + loadingLabel.X + 500, sprite.Position.Y + loadingLabel.Y + 500);
        }
Example #18
0
    public static Scene MakeParticlesScene()
    {
        var scene = new Scene()
        {
            Name = "Particles"
        };

        float scale = 1.5f;

        var body = new SpriteUV(new TextureInfo(new Texture2D("/Application/Sample/GameEngine2D/FeatureCatalog/data/arrow.png", false), new Vector2i(4, 4)));

        body.CenterSprite(TRS.Local.BottomCenter);
        body.Scale     = body.TextureInfo.TextureSizef * scene.Camera.GetPixelSize() * scale;
        body.BlendMode = BlendMode.Additive;

        scene.AddChild(body);

        body.Schedule((dt) => {
            if (Input2.Touch00.Down)
            {
                Vector2 touch_pos = Director.Instance.CurrentScene.Camera.GetTouchPos();
                if ((body.Position - touch_pos).Length() > 0.01f)
                {
                    body.Rotation = Math.LerpUnitVectors(body.Rotation, Math.Perp((body.Position - touch_pos).Normalize( )), 0.3f);
                }
                body.Position = Math.Lerp(body.Position, touch_pos, 0.3f);
            }

            body.Position += Input2.GamePad0.Dpad * 0.1f;
        });

        Particles      fire_node = new Particles(300);
        ParticleSystem fire      = fire_node.ParticleSystem;

        fire.TextureInfo = new TextureInfo(new Texture2D("/Application/Sample/GameEngine2D/FeatureCatalog/data/fire.png", false));
//		fire.BlendMode = BlendMode.PremultipliedAlpha;

        fire_node.Schedule((dt) =>

        {
            fire.Emit.Transform = fire_node.GetWorldTransform();
            fire.Emit.TransformForVelocityEstimate = fire_node.GetWorldTransform();
            fire.RenderTransform = Director.Instance.CurrentScene.GetWorldTransform();                     // most probably identity
        }

                           , -1);

        fire_node.AdHocDraw += () =>

        {
            // debug draw the emission rectangle in pink

            Director.Instance.GL.SetBlendMode(BlendMode.Additive);
            Director.Instance.DrawHelpers.SetColor(Colors.Pink * 0.3f);
            Director.Instance.DrawHelpers.DrawBounds2(Bounds2.QuadMinus1_1.Scale(fire.Emit.PositionVar, Math._00));
        };

        fire.Emit.Velocity        = new Vector2(0.0f, -2.0f);
        fire.Emit.VelocityVar     = new Vector2(0.2f, 0.3f);
        fire.Emit.ForwardMomentum = 0.2f;
        fire.Emit.AngularMomentun = 0.0f;
        fire.Emit.LifeSpan        = 0.4f;
        fire.Emit.WaitTime        = 0.005f;
        float s = 0.25f;

        fire_node.Position         = new Vector2(0.0f, -s);
        fire.Emit.PositionVar      = new Vector2(s, s);
        fire.Emit.ColorStart       = Colors.Red;
        fire.Emit.ColorStartVar    = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
        fire.Emit.ColorEnd         = Colors.White;
        fire.Emit.ColorEndVar      = new Vector4(0.2f, 0.0f, 0.0f, 0.0f);
        fire.Emit.ScaleStart       = 0.3f * scale;
        fire.Emit.ScaleStartRelVar = 0.2f;
        fire.Emit.ScaleEnd         = 0.6f * scale;
        fire.Emit.ScaleEndRelVar   = 0.2f;
        fire.Simulation.Fade       = 0.3f;

        body.AddChild(fire_node);

        Particles      smoke_node = new Particles(300);
        ParticleSystem smoke      = smoke_node.ParticleSystem;

        smoke.TextureInfo = new TextureInfo(new Texture2D("/Application/Sample/GameEngine2D/FeatureCatalog/data/fire.png", false));
//		smoke.BlendMode = BlendMode.PremultipliedAlpha;

        smoke_node.Schedule((dt) =>

        {
            smoke.Emit.Transform = smoke_node.GetWorldTransform();
            smoke.Emit.TransformForVelocityEstimate = smoke_node.GetWorldTransform();
            smoke.RenderTransform = Director.Instance.CurrentScene.GetWorldTransform();                     // most probably identity
        }

                            , -1);

        smoke_node.AdHocDraw += () =>

        {
            // debug draw the emission rectangle in pink

            Director.Instance.GL.SetBlendMode(BlendMode.Additive);
            Director.Instance.DrawHelpers.SetColor(Colors.Pink * 0.3f);
            Director.Instance.DrawHelpers.DrawBounds2(Bounds2.QuadMinus1_1.Scale(smoke.Emit.PositionVar, Math._00));
        };

        smoke.Emit.Velocity        = new Vector2(0.0f, -2.0f);
        smoke.Emit.VelocityVar     = new Vector2(0.2f, 0.3f);
        smoke.Emit.ForwardMomentum = 0.2f;
        smoke.Emit.AngularMomentun = 0.0f;
        smoke.Emit.LifeSpan        = 2.4f;
        smoke.Emit.WaitTime        = 0.02f;

        smoke_node.Position         = new Vector2(0.0f, -s);
        smoke.Emit.PositionVar      = new Vector2(s, s);
        smoke.Emit.ColorStart       = Colors.Black;
        smoke.Emit.ColorStartVar    = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
        smoke.Emit.ColorEnd         = Colors.Grey30;
        smoke.Emit.ColorEndVar      = new Vector4(0.2f, 0.0f, 0.0f, 0.0f);
        smoke.Emit.ScaleStart       = 0.3f * scale * 3.0f;
        smoke.Emit.ScaleStartRelVar = 0.2f;
        smoke.Emit.ScaleEnd         = 0.6f * scale * 4.0f;
        smoke.Emit.ScaleEndRelVar   = 0.2f;
        smoke.Simulation.Fade       = 0.3f;

        body.AddChild(smoke_node);

        scene.RegisterDisposeOnExit((System.IDisposable)fire);
        scene.RegisterDisposeOnExit((System.IDisposable)smoke);
        scene.RegisterDisposeOnExit((System.IDisposable)body.TextureInfo);

        return(scene);
    }
Example #19
0
        public Map(string filePath)
        {
            this.filePath = filePath;
            random        = new Random();

            tileLocations = new Dictionary <MapTile.Types, Vector2i>();

            setupLocations();

            tiles     = new List <MapTile> ();
            wallTiles = new List <MapTile> ();


            ParseFile(this, filePath, tiles);

            tiles.Reverse();

            prepareDescriptions(this, tiles);

            spriteList = prepareTiles(this, tiles);


            Console.WriteLine("map: " + filePath);
            Console.WriteLine("width: " + width);
            Console.WriteLine("heigh: " + height);

            //prepare thumbnail

            //create new scene for the thumbnail
            ThumbnailScene ts = new ThumbnailScene();

            //set up the camera so the entire level is visible
            ts.Camera2D.SetViewFromWidthAndCenter(FMath.Max(width, height), new Vector2(width / 2.0f, height / 2.0f));



            //create a new framebuffer for the thumbnail
            FrameBuffer thumbnailBuffer = new FrameBuffer();
            //create an associated texture
            Texture2D tex2d = new Texture2D(256, 256, false, PixelFormat.Rgba, PixelBufferOption.Renderable);

            thumbnailBuffer.SetColorTarget(tex2d, 0);

            //sprite to contain the thumbnail
            thumbnailSprite = new SpriteUV(new TextureInfo(tex2d));


            //render the thumbnail:
            if (Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.CurrentScene == null)
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.RunWithScene(ts, true);
            }
            else
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.ReplaceScene(ts);
            }
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update();

            //save the current framebuffer and viewport
            FrameBuffer oldBuffer      = Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.GetFrameBuffer();
            ImageRect   oldViewport    = Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.GetViewport();
            Vector4     oldClearColour = Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.GetClearColor();

            //set the new framebuffer for the thumbnail
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetFrameBuffer(thumbnailBuffer);
            //set the correct viewport
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetViewport(0, 0, 256, 256);

            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetClearColor(new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.Clear();

            //add the spritelists to the scene
            foreach (SpriteList sl in spriteList)
            {
                ts.Background.AddChild(sl);
            }

            //render the thumbnail scene
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.CurrentScene.render();

            //switch back to old framebuffer and viewport:
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetFrameBuffer(oldBuffer);
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetViewport(oldViewport);
            Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SetClearColor(oldClearColour);


            //get rid of the scene
            //remove all children,but WITHOUT THE CLEANUP(otherwise they won't work in the main Game scene)
            ts.Background.RemoveAllChildren(false);
            ts = null;

            //Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context.SwapBuffers ();
            //Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PostSwap ();

            //make the thumbnail larger
            //thumbnailSprite.Position = new Vector2(100.0f,100.0f);
            thumbnailSprite.FlipV = true;
            thumbnailSprite.CenterSprite(new Vector2(0.5f, 0.5f));
            thumbnailSprite.Scale = new Vector2(400.0f, 400.0f);
        }
Example #20
0
        public static void Initialize()
        {
            //Set up director and UISystem.
            Director.Initialize();
            UISystem.Initialize(Director.Instance.GL.Context);

            //Set game scene
            gameScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            gameScene.Camera.SetViewFromViewport();

            //Set the ui scene.
            uiScene = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel panel = new Panel();

            panel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            panel.Height = Director.Instance.GL.Context.GetViewport().Height;
            uiScene.RootWidget.AddChildLast(panel);

            //Set the highscores scene.
            highscoresManager = new HighScoreManager(gameScene);
            highscoresScene   = new Sce.PlayStation.HighLevel.UI.Scene();
            Panel highscoresPanel = new Panel();

            highscoresPanel.Width  = Director.Instance.GL.Context.GetViewport().Width;
            highscoresPanel.Height = Director.Instance.GL.Context.GetViewport().Height;
            highscoresScene.RootWidget.AddChildLast(highscoresPanel);

            // Setup highscores label
            highscoresLabel        = new Sce.PlayStation.HighLevel.UI.Label();
            highscoresLabel.Height = 200.0f;
            highscoresLabel.Text   = "Retrieving Data";
            highscoresPanel.AddChildLast(highscoresLabel);
            highscoresScene.RootWidget.AddChildLast(highscoresPanel);

            // Setup ui scene labels
            scoreLabel = new Sce.PlayStation.HighLevel.UI.Label();
            scoreLabel.SetPosition(10, 8);
            int roundedScore = (int)FMath.Floor(score / 100) * 100;

            scoreLabel.Text = "Score: " + roundedScore.ToString("N0");
            panel.AddChildLast(scoreLabel);

            gameSpeedLabel = new Sce.PlayStation.HighLevel.UI.Label();
            gameSpeedLabel.SetPosition(770, 8);
            float speed = FMath.Round(moveSpeed * 10) / 10;             // round to 1dp

            gameSpeedLabel.Text = "Game Speed: " + moveSpeed.ToString("N1");
            panel.AddChildLast(gameSpeedLabel);

            soundManager = new SoundManager();

            //Create Sprite
            rTextureInfo     = new TextureInfo("/Application/textures/reset.png");
            rSprite          = new SpriteUV();
            rSprite          = new SpriteUV(rTextureInfo);
            rSprite.Quad.S   = rTextureInfo.TextureSizef;
            rSprite.Scale    = new Vector2(1.0f, 1.0f);
            rSprite.Position = new Vector2(0.0f, 0.0f);
            rSprite.CenterSprite();

            //Run the scene.
            Director.Instance.RunWithScene(gameScene, true);
            screenManager = new ScreenManager(gameScene);
        }