Ejemplo n.º 1
1
        /*private static GraphicsContext graphics;

        public static void Main (string[] args)
        {
            Initialize ();

            while (true) {
                SystemEvents.CheckEvents ();
                Update ();
                Render ();
            }
        }

        public static void Initialize ()
        {
            // Set up the graphics system
            graphics = new GraphicsContext ();
        }

        public static void Update ()
        {
            // Query gamepad for current state
            var gamePadData = GamePad.GetData (0);
        }

        public static void Render ()
        {
            // Clear the screen
            graphics.SetClearColor (0.0f, 0.0f, 0.0f, 0.0f);
            graphics.Clear ();

            // Present the screen
            graphics.SwapBuffers ();
        }*/
        public static void Main(string[] args)
        {
            //JP: initialize GameEngine2D singletion that handles loop
            Director.Initialize();
            //JP: New 2D scene (graph) container (and camera alignment to orthogonal view
            Scene scene = new Scene();
            scene.Camera.SetViewFromViewport();
            //JP: Get width and height to local variables (optimization)
            var width = Director.Instance.GL.Context.GetViewport().Width;
            var height = Director.Instance.GL.Context.GetViewport().Height;
            //JP: Create new image
            Image img = new Image(ImageMode.Rgba, new ImageSize(width,height),
                                  new ImageColor(255,0,0,0));
            img.DrawText("Dream-Gin",
                         new ImageColor(255,0,0,255),
                         new Font(FontAlias.System,170,FontStyle.Regular),
                         new ImagePosition(0,150));
            //JP: Create hax0r frame buffer and add our img to it's buffer (and consequently kill img content)
            Texture2D texture = new Texture2D(width,height,false,
                                              PixelFormat.Rgba);
            texture.SetPixels(0,img.ToBuffer());
            img.Dispose();
            //JP: Texture info needed for SpriteUV
            TextureInfo ti = new TextureInfo();
            ti.Texture = texture;
            //JP: Add ti to SpriteUV
            SpriteUV sprite = new SpriteUV();
            sprite.TextureInfo = ti;
            //JP: resize sprite and center
            sprite.Quad.S = ti.TextureSizef;
            sprite.CenterSprite();
            sprite.Position = scene.Camera.CalcBounds().Center;
            //JP: Add to Scene
            scene.AddChild(sprite);
            //JP: execute loop shit
            Director.Instance.RunWithScene(scene, true);

            bool gameOver = false;

            while(!gameOver)
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update();
                if(Input2.GamePad.GetData(0).Left.Release)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(90));
                }
                if(Input2.GamePad0.Right.Release)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(-90));
                }
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Up) == GamePadButtons.Up)
                {
                    sprite.Quad.S = new Vector2(sprite.Quad.S.X += 10.0f,sprite.Quad.S.Y += 10.0f);
                    sprite.CenterSprite();
                }
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Down) == GamePadButtons.Down)
                {
                    sprite.Quad.S = new Vector2(sprite.Quad.S.X -= 10.0f,sprite.Quad.S.Y -= 10.0f);
                    sprite.CenterSprite();
                }
                if(Input2.GamePad0.Circle.Press == true)
                    gameOver = true;

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

            Director.Terminate();
        }
Ejemplo n.º 2
0
        public Game()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();

            background = new Node();
            foreground = new Node();

            gameObjectList = new List <GameObject>();

            scene.AddChild(background);
            scene.AddChild(foreground);

            TileObject backgroundImage = new TileObject(
                "/Application/assets/art/water_1.png", 8, 4);

            backgroundImage.SetParent(background);
            backgroundImage.SetScale(new Vector2(0.5f, 0.5f));

            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);

            camera = scene.Camera as Camera2D;
            camera.SetViewFromHeightAndCenter(1000, new Vector2(0, 0));
            TitleCameraCenter = camera.Center;
            CameraTarget      = TitleCameraCenter;

            ship = new Ship("/Application/assets/art/boat.png");
            ship.ScaleUV(new Vector2(0.5f, 0.5f));
            ship.Rotate(FMath.DegToRad * 90);
            ship.Pivot = new Vector2(-0.30f, 0.0f);
            foreground.AddChild(ship);

            gameObjectList.Add(ship);

            Director.Instance.RunWithScene(scene, true);
        }
        public EndGameScene()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/endBackground.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);
            timer = 0.0f;

            scoreTxt          = new Label();
            scoreTxt.Text     = "Score: " + ScoreManager.Instance.getScore();
            scoreTxt.Scale    = new Vector2(5.0f, 5.0f);
            scoreTxt.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 2 - 150, Director.Instance.GL.Context.GetViewport().Height *0.1f);
            scoreTxt.Color    = new Vector4(0.0f, 1.0f, 0.0f, 1.0f);

            Bgm hahaSound = new Bgm("/Application/Audio/Haha.mp3");

            hahaSoundPlayer = hahaSound.CreatePlayer();
            //Fix when it plays
            hahaSoundPlayer.Play();



            scene.AddChild(scoreTxt);

            ScoreManager.Instance.reset();
        }
        public StartScene()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/MenuStart.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);

            boxtex1 = new TextureInfo("/Application/Assets/playBtn.png");
            boxtex2 = new TextureInfo("/Application/Assets/ScoreScrn.png");

            btn1          = new SpriteUV(boxtex1);
            btn1.Quad.S   = new Vector2(boxtex1.TextureSizef.X, boxtex1.TextureSizef.Y);
            btn1.Position = new Vector2(150, 110);

            btn2          = new SpriteUV(boxtex2);
            btn2.Quad.S   = new Vector2(boxtex2.TextureSizef.X, boxtex2.TextureSizef.Y);
            btn2.Position = new Vector2(500, 110);
            scene.AddChild(btn1);
            scene.AddChild(btn2);

            screenWidth  = Director.Instance.GL.Context.GetViewport().Width;
            screenHeight = Director.Instance.GL.Context.GetViewport().Height;
        }
		public static void Main (string[] args)
		{
			Director.Initialize();
			Director.Instance.GL.Context.SetClearColor( Colors.Grey20 );
			//Director.Instance.DebugFlags |= DebugFlags.Navigate; 
			
			Vector2 position = new Vector2(300,300);
			Vector2i sprIndex1 = new Vector2i(0,0);
			int step = 0;
			
			var scene = new Scene();
			
			var texture_info = new TextureInfo( new Texture2D("/Application/Dude1.png", false ),
			                                   new Vector2i(2,1));
			
			var sprite = new SpriteTile(texture_info, sprIndex1);
			scene.Camera.SetViewFromViewport();
			sprite.Quad.S = texture_info.TextureSizef; 
			scene.AddChild( sprite );
			
			var sprite2 = new SpriteUV() { TextureInfo = texture_info};
			sprite2.Quad.S = texture_info.TextureSizef; 
			scene.AddChild( sprite2 );
			//sprite2.Position = scene.Camera.CalcBounds().Center;
			sprite2.Position = position;
			
			Director.Instance.RunWithScene( scene );
			Initialize ();
			
			sprite.TileIndex2D = new Vector2i(1,0);
			
			while (true) {
				GamePadData presses = GamePad.GetData(0);
				//step++;
				//if (step == 20)
				if ((presses.Buttons & GamePadButtons.Down) != 0){
					sprite.TileIndex2D.X = 0;
					position.X++;
				}
					//sprIndex1.X = 0;
				//if (step > 40){
				//	step = 0;
				else
					sprite.TileIndex2D.X = 1;
					//sprIndex1.X = 1;
				//}
				
				//sprite.TileIndex2D = sprIndex1;
				
				SystemEvents.CheckEvents ();
				Update ();
				Render ();
			}
		}
Ejemplo n.º 6
0
 /// <summary>
 /// Adds to scene.
 /// Scene にすべてのSpriteをAddする。
 /// </summary>
 /// <param name='scene'>
 /// Scene.
 /// </param>
 public override void AddToScene(Scene scene)
 {
     foreach (SpriteForTouch spriteForTouch in this.Sprites) {
         scene.AddChild(spriteForTouch.Sprite);
     }
     this.SetUnVisible();
 }
Ejemplo n.º 7
0
        public InGameScene()
        {
            InitializeUI();

            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/stone2.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);
            numTanks = 5;
            //tank = new Tank(scene);
            //tankSpawner = new Spawner(tank);
            tankList = new Tank[numTanks];
            for (int i = 0; i < numTanks; i++)
            {
                tankList[i] = new Tank(scene);
            }

            player = new Player(scene);

            ScoreManager.Instance.startTime();
            alive = true;

            bgSound       = new Bgm("/Application/Audio/BenHill.mp3");
            bgSoundPlayer = bgSound.CreatePlayer();
            //Fix when it plays

            //bgSoundPlayer.Dispose();
        }
        private SpriteTile spriteWalker = walker.Get("Walk_left00"); //最初に表示されるpngイラスト

        #endregion Fields

        #region Constructors

        /**
         *@param float positionX 描画する位置(画面の分割率)
         *@param float positionY 描画する位置(画面の分割率)
         *@param Scene scene 描画するscene
         *ファイル名等は今クラス内に埋め込み。読み込むSpriteSheetごとにCallクラスが一つ必要
         */
        public DrawWalkerSheetSample(float positionX, float positionY, int sizeX, int sizeY, Scene scene)
        {
            //positionX = Director.Instance.GL.Context.GetViewport().Width/positionX;
            //positionY = Director.Instance.GL.Context.GetViewport().Height/positionY;
            positionX = Const.DISPLAY_WIDTH - Const.DISPLAY_WIDTH*(Const.GRID_NUM_X-positionX)/Const.GRID_NUM_X;
            positionY = Const.DISPLAY_HEIGHT - Const.DISPLAY_HEIGHT*positionY/Const.GRID_NUM_Y;

            spriteOffset = 0;
            spriteName = "Walk_left" + spriteOffset.ToString("00");

            //walker = new Walker("walk.png","walk.xml");

            //var
            //scene.Camera.SetViewFromViewport();
            //var spriteWalker = walker.Get("Walk_left00");

            //spriteWalker.Position = scene.Camera.CalcBounds().Center;
            //spriteWalker.Position = new Vector2(positionX,positionY); //オブジェクトの位置
            spriteWalker.CenterSprite();
            spriteWalker.Scale = new Vector2(sizeX,sizeY); //サイズの変更
            //spriteWalker.Position = new Vector2(positionX+spriteWalker.Quad.S.X/2,positionY-spriteWalker.Quad.S.Y/2);
            spriteWalker.Position = new Vector2(0,0);
            spriteWalker.Quad.T.X = positionX;
            spriteWalker.Quad.T.Y = positionY - spriteWalker.Quad.S.Y;

            //sceneに追加
            scene.AddChild(spriteWalker);
        }
Ejemplo n.º 9
0
        public void Render( Texture2D texture, Scene scene)
        {
            TextureInfo ti1 = new TextureInfo();

            //if(flip)
                ti1.Texture = texture;
            //	else
            //		ti1.Texture = texture1;

               		SpriteUV sprite1 = new SpriteUV();
               		sprite1.TextureInfo = ti1;

               		if(type==0)
            sprite1.Quad.S = ti1.TextureSizef.Multiply(.3f);

            if(type==1)
            sprite1.Quad.S = ti1.TextureSizef.Multiply(.05f);

               		sprite1.CenterSprite();
               		sprite1.Position = position;// scene.Camera.CalcBounds().Center;

            sprite1.Rotate(-rotation);//*Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi/180);

               		scene.AddChild(sprite1);
        }
Ejemplo n.º 10
0
        public void ReOrderZ(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene)
        {
            sprite          = null;
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(0.0f, 0.0f);
            scene.AddChild(sprite);
            sprite.Visible = false;

            starsSprite          = null;
            starsSprite          = new SpriteUV(stars1Texture);
            starsSprite.Quad.S   = stars1Texture.TextureSizef;
            starsSprite.Position = new Vector2(0.0f, 0.0f);
            scene.AddChild(starsSprite);
            starsSprite.Visible = false;
        }
 /// <summary>
 /// Adds to scene.
 /// Scene にすべてのSpriteをAddする。
 /// </summary>
 /// <param name='scene'>
 /// Scene.
 /// </param>
 public override void AddToScene(Scene scene)
 {
     foreach (string keyTemp in this.Sprites.Keys) {
         scene.AddChild(this.Sprites[keyTemp].Sprite);
     }
     this.SetUnVisible();
 }
Ejemplo n.º 12
0
        public static void Main(string[] args)
        {
            Director.Initialize ();
            Director.Instance.GL.Context.SetClearColor(255,255,255,0);

            walker = new Walker("run.png", "run.xml");

            var scene = new Scene();
            scene.Camera.SetViewFromViewport();
            SpriteTile sprite = walker.Get("walkLeft00");

            sprite.Position = scene.Camera.CalcBounds().Center;
            sprite.CenterSprite();
            sprite.Scale = new Vector2(1,1);
            scene.AddChild(sprite);

            Director.Instance.RunWithScene(scene, true);

            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();

            int spriteOffset = 0;
            timer.Start();
            bool walkLeft = true;
            while(true) {
                if(timer.ElapsedMilliseconds > 25f) {
                    string spriteName;
                    if(walkLeft) {
                        spriteName = "walkLeft";
                        sprite.Position = new Vector2(sprite.Position.X - 10, sprite.Position.Y);
                    } else {
                        spriteName = "walkRight";
                        sprite.Position = new Vector2(sprite.Position.X + 10, sprite.Position.Y);
                    }
                    if(sprite.Position.X < 0) {
                        walkLeft = false;
                    }
                    if(sprite.Position.X > Director.Instance.GL.Context.GetViewport().Width) {
                        walkLeft = true;
                    }
                    spriteName += spriteOffset.ToString("00");

                    sprite.TileIndex2D = walker.Get(spriteName).TileIndex2D;

                    if(spriteOffset >= 8) {
                        spriteOffset = 0;
                    } else {
                        spriteOffset ++;
                    }

                    timer.Reset();
                    timer.Start();
                }

                Director.Instance.Update();
                Director.Instance.Render();
                Director.Instance.GL.Context.SwapBuffers();
                Director.Instance.PostSwap();
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Draws the sprite. and Add the sprite on scene.
        /// 画像のspriteを作成し、sceneに追加するメソッド
        /// </summary>
        /// <returns>
        /// The sprite.
        /// </returns>
        /// <param name='strPicture'>
        /// String picture. e.g.)"hoge.jpg"
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='sizeX'>
        /// Size x. if(sizeX = 0) -> sizeX is real width of picture
        /// </param>
        /// <param name='sizeY'>
        /// Size y. if(sizeY = 0) -> sizeY is real hight of picture
        /// </param>
        /// <param name='scene'>
        /// Scene.
        /// </param>
        public static SpriteUV DrawSprite(String strPicture, float positionX, float positionY,
		                                   float sizeX, float sizeY, Scene scene)
        {
            SpriteUV sprite = DrawSprite(strPicture,positionX,positionY,sizeX,sizeY);
            //sceneにspriteを追加
            scene.AddChild(sprite);

            return sprite;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Draws the sprite. and Add the scene.
        /// 文字列(のsprite)を作成し、sceneに追加するメソッド
        /// </summary>
        /// <returns>
        /// The sprite.
        /// </returns>
        /// <param name='drawStr'>
        /// Draw string.
        /// </param>
        /// <param name='positionX'>
        /// Position x.
        /// </param>
        /// <param name='positionY'>
        /// Position y.
        /// </param>
        /// <param name='fontSize'>
        /// Font size.
        /// </param>
        /// <param name='fontColor'>
        /// Font color.
        /// </param>
        /// <param name='scene'>
        /// Scene.
        /// </param>
        public static SpriteUV DrawSprite(String drawStr,float positionX, float positionY,
		                                   int fontSize,ImageColor fontColor, Scene scene)
        {
            SpriteUV sprite = DrawSprite(drawStr,positionX, positionY, fontSize, fontColor);
            //sceneにspriteを追加
            scene.AddChild(sprite);

            return sprite;
        }
Ejemplo n.º 15
0
        public SplashScene()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/Splashscreen1.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);
            splatScale     = new Vector2(10.0f, 10.0f);
            titleScale     = new Vector2(15.0f, 15.0f);
            splatTex       = new TextureInfo("/Application/Assets/splat.png");
            titleTex       = new TextureInfo("/Application/Assets/splattxt.png");
            splat          = new SpriteUV(splatTex);
            splat.Quad.S   = splatTex.TextureSizef;
            splat.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 3, Director.Instance.GL.Context.GetViewport().Height / 7);
            title          = new SpriteUV(titleTex);
            title.Quad.S   = titleTex.TextureSizef;
            title.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 3.3f, Director.Instance.GL.Context.GetViewport().Height / 2.8f);

            logoTex       = new TextureInfo("/Application/Assets/logo.png");
            logo          = new SpriteUV(logoTex);
            logo.Quad.S   = logoTex.TextureSizef;
            logo.Scale    = new Vector2(0.5f, 0.5f);
            logo.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width / 2 - 375, Director.Instance.GL.Context.GetViewport().Height / 2 - 230);
            logo.Color    = new Vector4(1.0f, 1.0f, 1.0f, 0.0f);

            scene.AddChild(splat);
            scene.AddChild(title);
            scene.AddChild(logo);
            splat.Scale = splatScale;
            title.Scale = titleScale;
            splat.Color = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
            title.Color = new Vector4(1.0f, 1.0f, 1.0f, 0.0f);
            speed       = 1.0f;

            playing     = false;
            splatSound  = new Bgm("/Application/Audio/Splat.mp3");
            SoundPlayer = splatSound.CreatePlayer();

            metalPlaying = false;
            metalSound   = new Bgm("/Application/Audio/Metal.mp3");
        }
Ejemplo n.º 16
0
        public Game()
        {
            //create a new scene
            Scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();

            //create layers for everyting
            Background   = new Layer();
            World        = new Layer();
            EffectsLayer = new Layer();
            Foreground   = new Layer();
            Curtains     = new Layer();
            Interface    = new Layer();

            //add layers to the scene
            Scene.AddChild(Background);
            Scene.AddChild(World);
            Scene.AddChild(EffectsLayer);
            Scene.AddChild(Foreground);
            Scene.AddChild(Interface);
            Scene.AddChild(Curtains);

            //set the camera for the scene
            Scene.Camera.SetViewFromViewport();
            Vector2 ideal_screen_size = new Vector2(960.0f, 544.0f);

            camera = Scene.Camera as Camera2D;
            camera.SetViewFromWidthAndCenter(10.0f, Math._00);


            //load the map
            dungeon1 = new Map();


            Sce.PlayStation.HighLevel.GameEngine2D.Scheduler.Instance.Schedule(Scene, gameTick, 0.0f, false);
        }
Ejemplo n.º 17
0
        public HighscoreScene()
        {
            scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            textureInfo       = new TextureInfo("/Application/Assets/Highscore.png");
            background        = new SpriteUV(textureInfo);
            background.Quad.S = textureInfo.TextureSizef;
            scene.AddChild(background);

            InitializeUI();
            setScore();
        }
Ejemplo n.º 18
0
        public static void Main(string[] args)
        {
            Director.Initialize();

            //Initialize ();

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

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

            /* Color Matrix Values
             * Unfortunately C# doesn't allow the regular #define usage,
             * See: The #define directive cannot be used to declare constant values
             * as is typically done in C and C++. Constants in C# are best defined as static members of a
             * class or struct. If you have several such constants, consider creating a separate "Constants"
             * class to hold them.
             *
             */
            const int RED = 255;
            const int BLUE = 0;
            const int GREEN = 0;
            const int ALPHA = 0;

            Image img = new Image(ImageMode.Rgba, new ImageSize(width, height), new ImageColor(RED,GREEN,BLUE,ALPHA));

            img.DrawText("Hello World", new ImageColor(RED,GREEN,BLUE,ALPHA+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);
        }
Ejemplo n.º 19
0
        public void Render(Scene scene)
        {
            if(timer.Milliseconds() > 25){
                count++;
                timer.Reset();
            }

            TextureInfo ti1 = new TextureInfo();

            if(count > 11)
                count=11;

            ti1.Texture = list[count];

               		SpriteUV sprite1 = new SpriteUV();
               		sprite1.TextureInfo = ti1;

               		sprite1.Quad.S = ti1.TextureSizef.Multiply(0.7f);
               		sprite1.CenterSprite();
               		sprite1.Position = position;// scene.Camera.CalcBounds().Center;

               		scene.AddChild(sprite1);
        }
Ejemplo n.º 20
0
        public static void GameUpdate()
        {
            // Update code here
            player.Update();
            if (!player.HasBeenKilled())
            {
                UpdateTouchData();
                obstacleManager.Update(moveSpeed);
                background.Update(moveSpeed);
                UpdateCamera();
                UpdateScore();
            }

            // Sets the volcano background to follow the sprite
            background.SetVolcanoPosition((player.GetPos().X + 400) - (Director.Instance.GL.Context.GetViewport().Width / 2), 0.0f);

            if (player.IsDead())
            {
                screenManager.ChangeScreenTo(Screens.GameOver);
                gameScene.AddChild(rSprite);
                DestroyGame();
                highscoresManager.SaveScore((int)score);
            }
        }
        public LevelSelectScreen(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene, int maxLevel) : base(scene)
        {
            highestUnlockedLevel = maxLevel;
            textureInfo          = new TextureInfo("/Application/textures/LevelSelectBackground.png");
            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(0.0f, 0.0f);
//
//			loadingTexture0     = AppMain.loadingTexture0;
//			loadingTexture1     = AppMain.loadingTexture1;
//			loadingTexture2     = AppMain.loadingTexture2;
//			loadingTexture3     = AppMain.loadingTexture3;
//			loadingTexture4     = AppMain.loadingTexture4;
//			loadingTexture5     = AppMain.loadingTexture5;
//			loadingTexture6     = AppMain.loadingTexture6;
//			loadingTexture7     = AppMain.loadingTexture7;
//			loadingTexture8     = AppMain.loadingTexture8;
//			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/Level13Load.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");

//			Sequence seq = new Sequence();
//			TintTo fadeIn = new TintTo (new Vector4 (1.0f, 1.0f, 1.0f, 1.0f), 1.0f);
//			TintTo fadeOut = new TintTo (new Vector4 (1.0f, 1.0f, 1.0f, 0.0f), 1.0f);
//			fadeIn.Tween = new DTween(f => f);
//			fadeOut.Tween = new DTween(f => f);
//			seq.Add(fadeIn);
//			seq.Add(fadeOut);
//			RepeatForever flash = new RepeatForever();
//			flash.InnerAction = seq;

            levelButtons = new Button[numOfLevels];

            for (int i = 0; i < numOfLevels; i++)
            {
                levelButtons[i]               = new Button();
                levelButtons[i].Text          = i.ToString();
                levelButtons[i].Name          = i.ToString();
                levelButtons[i].ButtonAction += HandleButtonAction;
                if (i <= 8)
                {
                    levelButtons[i].SetPosition(108f * i + 18, 180f);
                }
                if (i > 8 && i <= 17)
                {
                    levelButtons[i].SetPosition(108f * (i - 9) + 18, 280f);
                }
                if (i > 17 && i <= 26)
                {
                    levelButtons[i].SetPosition(108f * (i - 18) + 18, 380f);
                }
                if (i < highestUnlockedLevel)
                {
                    levelButtons[i].BackgroundFilterColor = new UIColor(0.0f, 255.0f, 0.0f, 1.0f);
                }
                if (i == highestUnlockedLevel)
                {
                    levelButtons[i].BackgroundFilterColor = new UIColor(0.0f, 191.0f, 255.0f, 1.0f);
                }

                levelButtons[i].SetSize(65, 65);
                uiScene.RootWidget.AddChildFirst(levelButtons[i]);
            }

            backButton = new Button();
            backButton.SetPosition(10, 485);
            backButton.SetSize(100, 50);
            backButton.Text = "BACK";
            backButton.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            backButton.ButtonAction         += HandleBackButtonAction;
            uiScene.RootWidget.AddChildLast(backButton);

            scene.AddChild(sprite);
            UISystem.SetScene(uiScene);
        }
Ejemplo n.º 22
0
        public LevelComplete(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene) : base(scene)
        {
            textureInfo     = new TextureInfo("/Application/textures/levelComplete.png");
            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(0.0f, 0.0f);
            scene.AddChild(sprite);
            sprite.Visible = false;

            stars1Texture        = new TextureInfo("/Application/textures/stars1.png");
            stars2Texture        = new TextureInfo("/Application/textures/stars2.png");
            stars3Texture        = new TextureInfo("/Application/textures/stars3.png");
            starsSprite          = new SpriteUV();
            starsSprite          = new SpriteUV(stars1Texture);
            starsSprite.Quad.S   = stars1Texture.TextureSizef;
            starsSprite.Position = new Vector2(0.0f, 0.0f);
            scene.AddChild(starsSprite);
            starsSprite.Visible = false;

            CustomButtonImageSettings customNextLevelImg = new CustomButtonImageSettings();

            customNextLevelImg.BackgroundNormalImage   = new ImageAsset("/Application/assets/buttons/NewNext.png");
            customNextLevelImg.BackgroundPressedImage  = new ImageAsset("/Application/assets/buttons/NewNext.png");
            customNextLevelImg.BackgroundDisabledImage = new ImageAsset("/Application/assets/buttons/NewNext.png");

            CustomButtonImageSettings customReplayImg = new CustomButtonImageSettings();

            customReplayImg.BackgroundNormalImage   = new ImageAsset("/Application/assets/buttons/NewReplay.png");
            customReplayImg.BackgroundPressedImage  = new ImageAsset("/Application/assets/buttons/NewReplay.png");
            customReplayImg.BackgroundDisabledImage = new ImageAsset("/Application/assets/buttons/NewReplay.png");

            CustomButtonImageSettings customBackImg = new CustomButtonImageSettings();

            customBackImg.BackgroundNormalImage   = new ImageAsset("/Application/assets/buttons/NewHome.png");
            customBackImg.BackgroundPressedImage  = new ImageAsset("/Application/assets/buttons/NewHome.png");
            customBackImg.BackgroundDisabledImage = new ImageAsset("/Application/assets/buttons/NewHome.png");

            backToLevelSelect = new Button();
            backToLevelSelect.SetPosition(750, 480);
            //backToLevelSelect.Text = "B";
            backToLevelSelect.SetSize(60, 60);
            //backToLevelSelect.BackgroundNinePatchMargin = new NinePatchMargin(10,10,10,10);
            backToLevelSelect.CustomImage = customBackImg;
            backToLevelSelect.Style       = ButtonStyle.Custom;
            //backToLevelSelect.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            backToLevelSelect.ButtonAction += HandleBackButton;
            backToLevelSelect.Visible       = false;
            uiScene.RootWidget.AddChildLast(backToLevelSelect);

            replayLevel = new Button();
            replayLevel.SetPosition(820, 480);
            //replayLevel.Text = "R";
            replayLevel.SetSize(60, 60);
            replayLevel.CustomImage = customReplayImg;
            replayLevel.Style       = ButtonStyle.Custom;
            //replayLevel.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            replayLevel.ButtonAction += HandleReplayButton;
            replayLevel.Visible       = false;
            uiScene.RootWidget.AddChildLast(replayLevel);

            nextLevel = new Button();
            nextLevel.SetPosition(890, 480);
            //nextLevel.Text = "N";
            nextLevel.SetSize(60, 60);
            nextLevel.CustomImage = customNextLevelImg;
            nextLevel.Style       = ButtonStyle.Custom;
            //nextLevel.BackgroundFilterColor = new UIColor(255.0f, 255.0f, 0.0f, 1.0f);
            nextLevel.ButtonAction += HandleNextLevelButton;
            nextLevel.Visible       = false;
            uiScene.RootWidget.AddChildLast(nextLevel);

            UISystem.SetScene(uiScene);
            nextState = State.WAITING;
        }
Ejemplo n.º 23
0
        public static void Main(string[] args)
        {
            Sce.PlayStation.Core.Graphics.GraphicsContext
             		context = new Sce.PlayStation.Core.Graphics.GraphicsContext();
                        uint sprites_capacity = 500;
            uint draw_helpers_capacity=400;

            System.Random rand = new System.Random();
                Director.Initialize(sprites_capacity,
                                draw_helpers_capacity, context);
            Director.Instance.GL.Context.SetClearColor(Colors.Grey20);

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

            Director.Instance.RunWithScene(scene,true);
            _physics = new GamePhysics();
            holder = new Node();

            var _screenWidth = Director.Instance.GL.Context.GetViewport().Width;
            var _screenHeight = Director.Instance.GL.Context.GetViewport().Height;
            currentLevelData = LevelData.LEVEL_DATA[0];
            cards = new Card[currentLevelData.Length];
            for (int i = 0; i < cards.Length; i++) {
                Vector2 start_pos = new Vector2(50f + 0.75f * _screenWidth * (float)rand.NextDouble(), 50f + 0.75f * _screenHeight * (float)rand.NextDouble ());
                cards[i] = new Card(_physics.addCardPhysics(start_pos), currentLevelData[i]);

                holder.AddChild (cards[i]);
            }

            scene.AddChild(holder);

            //cubeFaces = new SpriteSingleton();
            cubeFaces = SpriteSingleton.getInstance();
            sprite = cubeFaces.Get("topSide");
            sprite.Name = "topSide";
            sprite2 = cubeFaces.Get ("leftSide");
            sprite2.Name = "leftSide";
            sprite3 = cubeFaces.Get("rightSide");
            sprite3.Name = "rightSide";

            Vector2 vectHolder = sprite2.CalcSizeInPixels();
            sprite3.Position = new Vector2(vectHolder.X-84, sprite3.Position.Y);
            sprite.Position = new Vector2(vectHolder.X/4, (sprite.Position.Y + vectHolder.X/2)-12);
            //sprite3.Position = new Vector2(sprite2.Position.Length,
            //                               sprite2.Position.Y);
            //sprite.Position = scene.Camera.CalcBounds().Center;
            //sprite.CenterSprite();
            //sprite.Scale = new Vector2(1,1);

            cube3 = new Node();
            cube3.AddChild(sprite);
            cube3.AddChild(sprite2);
            cube3.AddChild(sprite3);
            scene.AddChild(cube3);

            //pink
            //sprite.RunAction(new TintTo (new Vector4(0.96f,0.88f,0.88f,1.0f),0.1f));
            //red
            //sprite.RunAction(new TintTo (new Vector4(0.90f,0.075f,0.075f,1.0f),0.1f));

            var spriteName="topSide";
            sprite.TileIndex2D = cubeFaces.Get (spriteName).TileIndex2D;
            Console.WriteLine(sprite.TileIndex2D);
            //teal
            //sprite.RunAction(new TintTo (new Vector4(0.16f,0.88f,0.88f,1.0f),0.1f));

            var cube = new Cube();
            cube.card1("red");
            cube.card2 ("blue");
            cube.card3("blue");

                while(!Input2.GamePad0.Cross.Press)
            {
                var vect = new Vector2(cube3.Position.X +10, cube3.Position.Y +3);
                cube3.Position = vect;
                Sce.PlayStation.Core.Environment.SystemEvents.CheckEvents();
                Director.Instance.Update();
                Director.Instance.Render();
                Director.Instance.GL.Context.SwapBuffers();
                Director.Instance.PostSwap();
                    cube.testCube();

            }
        }
Ejemplo n.º 24
0
        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);
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Add NOW LOADING.
 /// NOW LOADINGの描画
 /// </summary>
 /// <param name='scene'>
 /// Scene.
 /// </param>
 public static void NOW_LOADING(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene)
 {
     sceneLowding = scene;
     //背景
     BackGround = DrawPicture.DrawSprite("black.png",0,0,Const.DISPLAY_WIDTH,Const.DISPLAY_HEIGHT,sceneLowding);
     sceneLowding.AddChild(NowLoadingSprite);
     for(byte i = 0; i < 3; i++){
         sceneLowding.AddChild(NowLoadingDotSprite[i]);
     }
     NowLoadingFlag = true;
 }
Ejemplo n.º 26
0
        /// <summary>
        /// 初期化処理
        /// </summary>
        public void Initialize(GraphicsContext graphics)
        {
            _graphics = graphics;

            // ① 各データ読み込み
            Parameters.LoadData();

            // ルートシーンを作成する
            _rootScene = new Scene();

            // ② カメラの初期設定
            // 960x544 を基本サイズとして設定する
            Vector2 idealScreenSize = new Vector2(960.0f, 544.0f);
            Camera2D camera = _rootScene.Camera as Camera2D;
            camera.SetViewFromHeightAndCenter(idealScreenSize.Y, idealScreenSize / 2.0f);

            // ③ リール表示用のクラスの作成と初期化
            _reelView = new ReelView(_rootScene);
            _reelView.Initialize();

            // すべてのリールが停止したときのイベントハンドラーを設定
            _reelView.Stopped += AllStopped;

            // ④ Directorセットアップ
            Director.Instance.RunWithScene( _rootScene, true );

            // ⑤ Schedulerセットアップ
            Scheduler.Instance.Schedule(_rootScene, Update, 0.0f, false);

            // ⑥ リール表示用クラスをルートシーンに追加
            _rootScene.AddChild(_reelView);

            // ⑦ Gameシーンインスタンス作成
            _slotGameScene = new SlotGameScene();
            _slotGameScene.Shown += (sender, e) => {
                // モードをスタートシーンモードに設定する
                Parameters.SceneMode = Parameters.SceneModeType.GameScene;
            };

            // ラベルセットアップ
            _slotGameScene.TotalCoinTitleText = "Total Coins";
            _slotGameScene.InsertCoinTitleText = "Insert Coins";
            _slotGameScene.RewordCoinTitleText = "Reword Coins";

            // ⑧ StartMenuシーンインスタンス作成
            _startMenuScene = new StartMenuScene(_slotGameScene);
            _startMenuScene.Shown += (sender, e) => {
                // Gameシーンモードに設定する
                Parameters.SceneMode = Parameters.SceneModeType.StartScene;
            };

            // ⑨ モードをStartMenuシーンにセット
            Parameters.SceneMode = Parameters.SceneModeType.StartScene;

            // ⑩ StartMenuシーンセットアップ
            Sce.PlayStation.HighLevel.UI.UISystem.SetScene(_startMenuScene);

            // ⑪ サウンド、サウンドプレイヤー用辞書作成
            _soundDic.Add(SoundType.InsertCoin, new Sound("/Application/resources/InsertCoin.wav"));
            _soundDic.Add(SoundType.ReelStart, new Sound("/Application/resources/ReelStart.wav"));
            _soundDic.Add(SoundType.ReelStop, new Sound("/Application/resources/ReelStop.wav"));
            _soundDic.Add(SoundType.Replay, new Sound("/Application/resources/Replay.wav"));
            _soundDic.Add(SoundType.Win, new Sound("/Application/resources/Win.wav"));

            _soundPlayerDic.Add(SoundType.InsertCoin, _soundDic[SoundType.InsertCoin].CreatePlayer());
            _soundPlayerDic.Add(SoundType.ReelStart, _soundDic[SoundType.ReelStart].CreatePlayer());
            _soundPlayerDic.Add(SoundType.ReelStop, _soundDic[SoundType.ReelStop].CreatePlayer());
            _soundPlayerDic.Add(SoundType.Replay, _soundDic[SoundType.Replay].CreatePlayer());
            _soundPlayerDic.Add(SoundType.Win, _soundDic[SoundType.Win].CreatePlayer());
        }
Ejemplo n.º 27
0
        public void Render(Scene scene)
        {
            TextureInfo ti1 = new TextureInfo();

            ti1.Texture = texture;

               		SpriteUV sprite1 = new SpriteUV();
               		sprite1.TextureInfo = ti1;

               		sprite1.Quad.S = ti1.TextureSizef.Multiply(multipier);
               		sprite1.CenterSprite();
               		sprite1.Position = position;// scene.Camera.CalcBounds().Center;

            sprite1.Rotate(-rotationAngle);//*Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi/180);

               		scene.AddChild(sprite1);
        }
Ejemplo n.º 28
0
        // 初期化
        public void Initialize()
        {
            // GameEngine2D 画面クリアー色の設定
            Director.Instance.GL.Context.SetClearColor (Colors.Grey20);

            // 画面解像度情報
            //			ScreenSize = new Vector2i (854, 480);
            ScreenSize = new Vector2i (960, 544);

            // 効果音の設定
            var soundObj = new Sound ("/Application/assets/se.wav");
            Sound = soundObj.CreatePlayer ();

            // BGMの設定
            bgm = new Bgm ("/Application/assets/bgm.mp3");
            player = bgm.CreatePlayer ();
            player.Loop = true; // リピート再生する
            // BGMの再生
            player.Play ();

            // シーン生成(ノードのルートになる)
            var scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene ();

            // 2Dゲーム向けにカメラを設定
            scene.Camera.SetViewFromViewport ();

            // GameEngine2Dを実行
            Director.Instance.RunWithScene (scene, true);

            Pause = false;

            World = new Node ();
            //	Interface = new Node ();
            // シーンにWorldを追加する
            scene.AddChild (World);
            // シーンにInterface(UIで利用する)を追加する
            //	scene.AddChild (Interface);

            // 背景登録
            for (int y = 0; y < 7; y++) {
                for (int x = 0; x < 6; x++) {
                    var backGround = new BackGround (new Vector2 (x * 192, y * 128));
                    World.AddChild (backGround);
                }
            }

            // 自機(プレイヤー)登録
            Player = new Player (new Vector2 (Game.Instance.ScreenSize.X/2, 100));
            World.AddChild (Player);
            // 敵機(ボス)登録
            Boss = new Boss (new Vector2 (Game.Instance.ScreenSize.X/2, 250));
            World.AddChild (Boss);
            // UI登録
            UI = new UI ();
            //Interface.AddChild (UI);
            scene.AddChild (UI);
            // 当たり判定処理の生成
            HitTest = new HitTest ();
            // 登録キュー
            AddQueue = new List<GameEntity> ();
            // 削除キュー
            RemoveQueue = new List<GameEntity> ();
        }
Ejemplo n.º 29
0
        public Game()
        {
            //			Director.Instance.DebugFlags |= DebugFlags.Navigate; // press left alt + mouse to navigate in 2d space
            //			Director.Instance.DebugFlags |= DebugFlags.DrawGrid;
            Director.Instance.DebugFlags |= DebugFlags.DrawContentWorldBounds;
            Director.Instance.DebugFlags |= DebugFlags.DrawContentLocalBounds;
            //			Director.Instance.DebugFlags |= DebugFlags.DrawTransform;
            //			Director.Instance.DebugFlags |= DebugFlags.DrawPivot;

            DebugString = new DebugString(Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.GL.Context);
            Scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            Background = new Layer();
            World = new Layer();
            EffectsLayer = new Layer();
            Foreground = new Layer();
            Curtains = new Layer();
            Interface = new Layer();
            Random = new Random();
            Collider = new EntityCollider();
            ParticleEffects = new Support.ParticleEffectsManager();
            TextureTileMaps = new Support.TextureTileMapManager();
            UI = new UI();
            ScoreManager = new ScoreManager();

            SpriteBatch = new SpriteBatch();

            BuildTextureTileMaps();

            AddQueue = new List<GameEntity>();
            RemoveQueue = new List<GameEntity>();

            Scene.AddChild(Background);
            Scene.AddChild(World);
            Scene.AddChild(EffectsLayer);
            Scene.AddChild(Foreground);
            Scene.AddChild(Interface);
            Scene.AddChild(Curtains);

            Scene.Camera.SetViewFromViewport();

            // temporary: munge viewport to match vita + assets
            Vector2 ideal_screen_size = ScreenSize;
            Camera2D camera = Scene.Camera as Camera2D;
            camera.SetViewFromHeightAndCenter(ideal_screen_size.Y, ideal_screen_size / 2.0f);
            TitleCameraCenter = camera.Center;
            CameraTarget = TitleCameraCenter;

            if(ParticleEffects!=null)
                EffectsLayer.AddChild(ParticleEffects);
            Interface.AddChild(UI);

            // world
            var bg_forest = Support.SpriteFromFile("/Application/assets/background_test2.png");
            bg_forest.Scale *= 1;

            bg_forest.Position = new Vector2(0f, 0.0f);

            Background.AddChild(bg_forest);

            UI.TitleMode();

            Sce.PlayStation.HighLevel.GameEngine2D.Scheduler.Instance.Schedule(Scene, TickTitle, 0.0f, false);

            World.AdHocDraw += this.DrawWorld;
        }
Ejemplo n.º 30
0
        public TitleScreen(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene, Sce.PlayStation.HighLevel.UI.Scene uiScene) : base(scene)
        {
            scene1 = scene;

            textureInfo     = new TextureInfo("/Application/textures/GravityNinja.png");
            sprite          = new SpriteUV();
            sprite          = new SpriteUV(textureInfo);
            sprite.Quad.S   = textureInfo.TextureSizef;
            sprite.Position = new Vector2(0.0f, 0.0f);

            playTexture         = new TextureInfo("/Application/textures/play.png");
            playSelectTexture   = new TextureInfo("/Application/textures/playSelected.png");
            playSprite          = new SpriteUV();
            playSprite          = new SpriteUV(playSelectTexture);
            playSprite.Quad.S   = playTexture.TextureSizef * 0.7f;
            playSprite.Position = new Vector2(Director.Instance.GL.Context.GetViewport().Width *0.78f - (playTexture.TextureSizef.X / 2), 200);

            controlTexture         = new TextureInfo("/Application/textures/cog.png");
            controlSprite          = new SpriteUV();
            controlSprite          = new SpriteUV(controlTexture);
            controlSprite.Quad.S   = controlTexture.TextureSizef * 0.05f;
            controlSprite.Position = new Vector2(10.0f, 10.0f);

            playBox.Min = playSprite.Position;
            playBox.Max = playSprite.Position + playSprite.TextureInfo.TextureSizef;

            controlsBox.Min = controlSprite.Position;
            controlsBox.Max = controlSprite.Position + controlSprite.TextureInfo.TextureSizef * 0.05f;

            label = new Sce.PlayStation.HighLevel.UI.Label();
            label.SetPosition(10, 90);
            label.Text = "Awaiting Input...";

            backButton = new Button();
            backButton.SetPosition(10, 140);
            backButton.SetSize(100, 50);
            backButton.Text          = "Back";
            backButton.ButtonAction += HandleButtonAction;

            inputButton = new Button();
            inputButton.SetPosition(380, 10);
            inputButton.SetSize(100, 50);
            inputButton.Text          = "Enter";
            inputButton.ButtonAction += HandleInputAction;

            command = new EditableText();
            command.SetPosition(10, 10);
            command.Text = "Enter Command";

            dialog = new Dialog();
            dialog.SetSize(500, 200);
            dialog.ShowEffect = new BunjeeJumpEffect(dialog, 0.4f);
            dialog.HideEffect = new TiltDropEffect();
            dialog.AddChildFirst(label);
            dialog.AddChildFirst(command);
            dialog.AddChildFirst(backButton);
            dialog.AddChildFirst(inputButton);

            scene.AddChild(sprite);
            scene.AddChild(playSprite);
            scene.AddChild(controlSprite);

            UISystem.SetScene(uiScene);
        }
Ejemplo n.º 31
0
        //初期化 ・・・AppMainから呼ばれる
        public void Initialize()
        {
            flg = false;
            var width = Director.Instance.GL.Context.GetViewport().Width;
            var height = Director.Instance.GL.Context.GetViewport().Height;

            Director.Instance.GL.Context.SetClearColor(Colors.Grey20);
            ScreenSize = new Vector2i(width,height);

            //sceneの作成
            Sce.PlayStation.HighLevel.GameEngine2D.Scene scene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene();
            scene.Camera.SetViewFromViewport();

            //GameEngine2Dの設定・実行
            Director.Instance.RunWithScene(scene,true);

            World = new Node();
            scene.AddChild(World);

            //自弾敵弾はキューで管理
            AddQueue = new List<BulletEntity>();
            RemoveQueue = new List<BulletEntity>();

            HitTest = new HitTest();

            //背景登録
            for (int y = 0; y < 3; y++) {
                for (int x = 0; x < 3; x++) {
                    var backGround = new BackGround (new Vector2 (x * 416f*2.5f, y * 232f * 2.5f),Const.BACKGROUND_PATH,2.5f);
                    World.AddChild (backGround);
                }
            }

            //敵機登録
            Boss = new Boss(new Vector2(Game.Instance.ScreenSize.X-Game.Instance.ScreenSize.X/8,0),Const.BOSS_SHIP_PATH);
            World.AddChild (Boss);

            //自機登録・・・(初期位置,自機画像path)で自機ノードを作成してworldに登録
            Player = new Player(new Vector2(50,Game.Instance.ScreenSize.Y/2),Const.PLAYER_SHIP_PATH);
            World.AddChild(Player);

            HpBar = new hpDialog();
        }
Ejemplo n.º 32
0
        public void Render(Scene scene, int width, int height)
        {
            Image img1 = new Image(ImageMode.Rgba, new ImageSize(width/5,height/10),
                             new ImageColor(255,0,0,0));
               		img1.DrawText(RotationAngle.ToString()+" "+currentAngle.ToString(),
                    new ImageColor(0,0,255,255),
                    new Font(FontAlias.System,20,FontStyle.Regular),
                    new ImagePosition(0,0));

               		Texture2D texture1 = new Texture2D(width/5,height/10,false,
                                         PixelFormat.Rgba);
               		texture1.SetPixels(0,img1.ToBuffer());
               		img1.Dispose();

               		TextureInfo ti1 = new TextureInfo();

            //			if(timer.Milliseconds()>100){
            //				flip = !flip;
            //				timer.Reset();
            //			}

              		//if(flip) {
                ti1.Texture = shipTexture;
                //flip= !flip;
            //	}
            //	else {

            //		ti1.Texture = shipTexture1;
                //flip = !flip;

            //	}

            //	else
            //		ti1.Texture = texture1;

               		SpriteUV sprite1 = new SpriteUV();
               		sprite1.TextureInfo = ti1;

               		sprite1.Quad.S = ti1.TextureSizef.Multiply(.3f);
               		sprite1.CenterSprite();
               		sprite1.Position = position;// scene.Camera.CalcBounds().Center;

            sprite1.Rotate(-RotationAngle);//*Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi/180);

               		scene.AddChild(sprite1);
        }
Ejemplo n.º 33
-1
        public static void Main(string[] args)
        {
            Director.Initialize();

            //Initialize ();

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

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

            /* Color Matrix Values
             * Unfortunately C# doesn't allow the regular #define usage,
             * See: The #define directive cannot be used to declare constant values
             * as is typically done in C and C++. Constants in C# are best defined as static members of a
             * class or struct. If you have several such constants, consider creating a separate "Constants"
             * class to hold them.
             *
             */
            const int RED = 255;
            const int BLUE = 0;
            const int GREEN = 0;
            const int ALPHA = 0;

            Image img = new Image(ImageMode.Rgba, new ImageSize(width, height), new ImageColor(RED,GREEN,BLUE,ALPHA));

            img.DrawText("Hello World", new ImageColor(RED,GREEN,BLUE,ALPHA+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);

            /* Important: The second argument 'true' defines that the Scene processing would be done manually,
             * So in this case, we would like to do the following ourselves:
             * Update();	-- Tells us to move to the next frame.
             * Render();	-- Draws the next frame.
             * SwapBuffers(); -- Swaps what the Render() drew in the previous frame. {Hence happens after the render}
             * PostSwap(); -- Tells us that we've finished with SwapBuffer();
             * */

            Director.Instance.RunWithScene(scene, true);

            bool gameOver = false;

            while(!gameOver)
            {
                Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.Update();
                // Rotate Left: Preferred Method to Rotate, although not so smooth.
                /*
                if(Input2.GamePad.GetData(0).Left.Release)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(1));
                }
                */

                /*
                 * AWWx1 to do rotation per interrupt.
                 if(Input2.GamePad0.Left.Release)
                 {
                 	sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(90));
                 }
                 */

                // AWWx2 to do rotation per interrupt, with bitwise comparison.
                // Interesting Fact, doing a bitwise comparison does a continous rendering. So doing it 1 degree at a time smoothens it out.
                // Smoothness = 1/InputDegree.
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Left) == GamePadButtons.Left)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(1.0f));
                }

                // Rotate Right
                // Notice that this is NOT continous as compared to the Left Rotate.
                if(Input2.GamePad.GetData(0).Right.Release)
                {
                    sprite.Rotate(Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Deg2Rad(-90));
                }

                // Scale Up by a factor of 1/10th.
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Up) == GamePadButtons.Up)
                {
                    sprite.Quad.S = new Vector2(sprite.Quad.S.X += 10.0f, sprite.Quad.S.Y += 10.0f);
                    sprite.CenterSprite();
                }

                // Scale Down by a factor of 1/10th.
                if((Sce.PlayStation.Core.Input.GamePad.GetData(0).Buttons & GamePadButtons.Down) == GamePadButtons.Down)
                {
                    sprite.Quad.S = new Vector2(sprite.Quad.S.X -= 10.0f, sprite.Quad.S.Y -= 10.0f);
                    sprite.CenterSprite();
                }

                // Exit if Circle is Pressed.
             	if(Input2.GamePad0.Circle.Press == true)
                {
                    gameOver = true;
                }

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

            Director.Terminate();
        }