/*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(); }
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); }
/// <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(); }
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); }
/// <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(); }
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 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 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); }
// CONSTRUCTOR ---------------------------------------------------------------------------- public ButtonEntity( string pLabel, Scene pScene, GamePhysics pGamePhysics, TextureInfo pTextureInfo, Vector2i pTileIndex2D ) : base(pScene, pGamePhysics, pTextureInfo, pTileIndex2D, null) { halfWidth = Width / 2.0f; halfHeight = Height / 2.0f; labelOffset = new Vector2(0.1f, 0.25f); this.setPivot(0.5f,0.5f); font = Crystallography.UI.FontManager.Instance.GetInGame("Bariol", 25); map = Crystallography.UI.FontManager.Instance.GetMap( font ); if ( pLabel != null ) { label = new Label( pLabel, map ); label.Pivot = new Vector2(0.15f, 0.25f ); label.Scale = new Vector2(1.0f/this.Width,1.0f/this.Height); } this.getNode().AddChild(label); labelOffset = Vector2.Zero; status = NORMAL; _onToggle = false; _pressed = false; _initialized = false; #if DEBUG Console.WriteLine(GetType().ToString() + " created" ); #endif }
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 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(); }
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(); } }
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); }
public static void Initialize() { Director.Initialize (); scene = new Scene (); // set backgound color as white Director.Instance.GL.Context.SetClearColor (1.0f, 1.0f, 1.0f, 0.0f); }
// CONSTRUCTORS ---------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Crystallography.WildCardCrystallonEntity"/> class. /// </summary> /// <param name='pScene'> /// The Parent Scene. /// </param> /// <param name='pGamePhysics'> /// Instance of <c>GamePhysics</c> /// </param> /// <param name='pTextureInfo'> /// <see cref="Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo"/> /// </param> /// <param name='pTileIndex2D'> /// <see cref="Sce.PlayStation.HighLevel.GameEngine2D.Base.Vector2i"/> /// </param> /// <param name='pShape'> /// <see cref="Sce.PlayStation.HighLevel.Physics2D.PhysicsShape"/> /// </param> public WildCardCrystallonEntity(Scene pScene, GamePhysics pGamePhysics, int pId, PhysicsShape pShape) : base(pScene, pGamePhysics, pId, // pTextureInfo, pTileIndex2D, pShape) { Wild = true; Flash (); }
public static void Init() { Director.Initialize(); scene = new Scene(); scene.Camera.SetViewFromViewport(); Director.Instance.RunWithScene(scene,true); survival = new SurvivalMode(scene); }
/// <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; }
/// <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; }
// CONSTRUCTOR --------------------------------------------------------------------- protected GroupManager() { availableGroups = new List<GroupCrystallonEntity>(); _scene = Director.Instance.CurrentScene; _physics = GamePhysics.Instance; Reset( _scene ); #if DEBUG Console.WriteLine(GetType().ToString() + " created" ); #endif }
// CONSTRUCTORS-------------------- /// <summary> /// Initializes a new instance of the <see cref="Crystallography.AbstractCrystallonEntity"/> class. /// </summary> /// <param name='pScene'> /// Reference to the current scene. /// </param> /// <param name='pGamePhysics'> /// Reference to the <see cref="Crystallography.GamePhysics"/>. /// </param> public AbstractCrystallonEntity( Scene pScene, GamePhysics pGamePhysics ) { GUID = Guid.NewGuid(); _scene = pScene; _physics = pGamePhysics; _offset = Vector2.Zero; #if DEBUG Console.WriteLine("{0} {1} created", this.GetType(), GUID); #endif }
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(); gameScene.Name = "gameScene"; startScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene(); startScene.Camera.SetViewFromViewport(); startScene.Name = "startScene"; endScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene(); endScene.Camera.SetViewFromViewport(); endScene.Name = "endScene"; //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; scoreLabel = new Sce.PlayStation.HighLevel.UI.Label(); scoreLabel.HorizontalAlignment = HorizontalAlignment.Center; scoreLabel.VerticalAlignment = VerticalAlignment.Top; scoreLabel.SetPosition( Director.Instance.GL.Context.GetViewport().Width / 2 - scoreLabel.Width / 2, Director.Instance.GL.Context.GetViewport().Height *0.1f - scoreLabel.Height / 2); scoreLabel.Text = "0"; panel.AddChildLast(scoreLabel); uiScene.RootWidget.AddChildLast(panel); UISystem.SetScene(uiScene); //Create the background. background = new Background(gameScene, gameScene.Name); titleBackground = new Background(startScene, startScene.Name); endBackground = new Background(endScene, endScene.Name); //Create the flappy douche bird = new Bird(gameScene); //Create some obstacles. obstacles = new Obstacle[2]; obstacles[0] = new Obstacle(Director.Instance.GL.Context.GetViewport().Width *0.5f, gameScene); obstacles[1] = new Obstacle(Director.Instance.GL.Context.GetViewport().Width, gameScene); score = 0; keyPressed = false; //Run the scene. Director.Instance.RunWithScene(startScene, true); }
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 (); } }
// CONSTRUCTORS ---------------------------------------------------------- public NodeCrystallonEntity(Scene pScene, GamePhysics pGamePhysics, PhysicsShape pShape = null) : base(pScene, pGamePhysics) { _node = new Node(); if (pShape != null) { _body = _physics.RegisterPhysicsBody(pShape, 0.1f, 0.01f, _node.Position); } else { _body = null; } Scheduler.Instance.Schedule(_node, Update, 0, false, 0); }
// CONSTRUCTORS -------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Crystallography.CardCrystallonEntity"/> class. /// </summary> /// <param name='pScene'> /// The Parent Scene. /// </param> /// <param name='pGamePhysics'> /// Instance of <c>GamePhysics</c> /// </param> /// <param name='pTextureInfo'> /// <see cref="Sce.PlayStation.HighLevel.GameEngine2D.Base.TextureInfo"/> /// </param> /// <param name='pTileIndex2D'> /// <see cref="Sce.PlayStation.HighLevel.GameEngine2D.Base.Vector2i"/> /// </param> /// <param name='pShape'> /// <see cref="Sce.PlayStation.HighLevel.Physics2D.PhysicsShape"/> /// </param> public CardCrystallonEntity(Scene pScene, GamePhysics pGamePhysics, int pId, PhysicsShape pShape) : base(pScene, pGamePhysics, pShape) { id = pId; _anim = null; GlowSprite = null; Scored = false; // _sprite.Scale*=CARD_SCALAR; _sprite.Position = new Vector2(-Width/2, -Height/2); _keepOnScreenTimer = -1.0f; setVelocity(DEFAULT_SPEED, GameScene.Random.NextAngle()); }
// CONSTRUCTOR --------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Crystallography.CardManager"/> class. /// </summary> protected CardManager() { NextId = 0; availableCards = new List<CardCrystallonEntity>(); availableWildCards = new List<CardCrystallonEntity>(); _scene = Director.Instance.CurrentScene; _physics = GamePhysics.Instance; CubeCrystallonEntity.CubeCompleteDetected += HandleSelectionGroupInstanceCubeCompleteDetected; Reset (_scene); #if DEBUG Console.WriteLine(GetType().ToString() + " created" ); #endif }
// CONSTRUCTOR ----------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="Crystallography.GroupCrystallonEntity"/> class. /// </summary> /// <param name='pScene'> /// Instance of the parent scene. /// </param> /// <param name='pGamePhysics'> /// Instance of <c>GamePhysics</c> /// </param> /// <param name='pShape'> /// <see cref="Sce.PlayStation.HighLevel.Physics2D.PhysicsShape"/> /// </param> /// <param name='pMaxMembers'> /// <c>int</c> Maximum allowed population. Probs 3. 0 = no limit. /// </param> public GroupCrystallonEntity(Scene pScene, GamePhysics pGamePhysics, PhysicsShape pShape = null, int pMaxMembers=0, bool pComplete = false) : base(pScene, pGamePhysics, pShape) { _maxMembers = pMaxMembers; _numMembers = 0; members = new AbstractCrystallonEntity[_maxMembers]; _pucks = new Node[_maxMembers]; for (int i=0; i < _maxMembers; i++) { AddPuck(i); } complete = pComplete; }
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(); }
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); }
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); }
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"); }
// CONSTRUCTORS---------------------------------------------------------------------------- public SpriteTileCrystallonEntity( Scene pScene, GamePhysics pGamePhysics, PhysicsShape pShape = null) : base(pScene, pGamePhysics, pShape) { // SPRITE STUFF _orientationIndex = 0; _patternIndex = 0; // _sprite = new SpriteTile(pTextureInfo); _sprite = new SpriteTile(); // _sprite.Scale = _sprite.CalcSizeInPixels(); _node.AddChild(_sprite); // PHYSICS STUFF // if (pShape != null) { // _body = _physics.RegisterPhysicsBody(pShape, 0.1f, 0.01f, _sprite.Position); // } else { // _body = null; // } // Scheduler.Instance.Schedule(_sprite, Update, 0.0f, false); }
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); }
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); UISystem.SetScene(uiScene); //Run the scene. Director.Instance.RunWithScene(gameScene, true); }
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); }
public MenuScene() { menuScene = new Sce.PlayStation.HighLevel.GameEngine2D.Scene(); scenePaused = false; swapScene = false; }
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); }
public void changeSceneTo(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene) { //set the director to run with the scene within the game object Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.ReplaceScene(scene); }
void replace_scene( Scene new_scene ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( "" ); System.Console.WriteLine( Common.FrameCount + " replace_scene " + get_top_scene().DebugInfo() + " -> " + new_scene.DebugInfo() ); #endif // #if DEBUG_SCENE_TRANSITIONS if ( m_canceled_replace_scene.Contains( new_scene ) ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " => replace_scene cancelled because this scene has been interrupted by an other transition during this frame" ); #endif // #if DEBUG_SCENE_TRANSITIONS return; } Common.Assert( m_scenes_stack.Count > 0, "Can't ReplaceScene: scene stack is empty" ); Scene previous_scene = get_top_scene(); m_scenes_stack[ m_scenes_stack.Count - 1 ] = new_scene; Common.Assert( previous_scene != new_scene ); on_scene_change( previous_scene, new_scene ); }
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; }
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); }
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); }
/// <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()); }
/// <summary> /// Draws the sprite. able to touch. /// Touchできる画像のspriteを作成し、sceneに追加するメソッド。 /// Touch有効フラグを引数に持つ。 /// </summary> /// <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> /// <param name='touchOn'> /// Touch on. /// </param> public void DrawSprite(String drawStr,float positionX, float positionY, int fontSize,ImageColor fontColor, Scene scene, bool touchOn) { this.SetSpriteForTouch(WriteString.DrawSprite(drawStr,positionX, positionY, fontSize,fontColor,scene), positionX, positionY, true); this.TouchOn = touchOn; }
/// <summary> /// Removes from scene. /// Scene からすべてのSpriteをremoveする。 /// </summary> /// <param name='scene'> /// Scene. /// </param> public override void RemoveFromScene(Scene scene) { foreach (SpriteForTouch spriteForTouch in this.Sprites) { scene.RemoveChild(spriteForTouch.Sprite,true); } }
// 初期化 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> (); }
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; }
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; scoreLabel = new Sce.PlayStation.HighLevel.UI.Label(); scoreLabel.HorizontalAlignment = HorizontalAlignment.Left; scoreLabel.VerticalAlignment = VerticalAlignment.Top; scoreLabel.TextShadow = new TextShadowSettings(); scoreLabel.TextShadow.Color = new UIColor(0.0f, 0.0f, 0.0f, 1.0f); scoreLabel.TextShadow.HorizontalOffset = 2.0f; scoreLabel.TextShadow.VerticalOffset = 2.0f; scoreLabel.SetPosition( Director.Instance.GL.Context.GetViewport().Width / 2 - scoreLabel.Width / 2, Director.Instance.GL.Context.GetViewport().Width *0.1f - scoreLabel.Height / 2); scoreLabel.Text = "Score: " + score.ToString(); airLabel = new Sce.PlayStation.HighLevel.UI.Label(); airLabel.HorizontalAlignment = HorizontalAlignment.Right; airLabel.VerticalAlignment = VerticalAlignment.Top; airLabel.TextShadow = new TextShadowSettings(); airLabel.TextShadow.Color = new UIColor(0.0f, 0.0f, 0.0f, 1.0f); airLabel.TextShadow.HorizontalOffset = 2.0f; airLabel.TextShadow.VerticalOffset = 2.0f; airLabel.SetPosition( Director.Instance.GL.Context.GetViewport().Width / 2 - airLabel.Width / 2, Director.Instance.GL.Context.GetViewport().Width *0.1f - airLabel.Height / 2); airLabel.Text = "Air: " + air.ToString(); windowWidth = Director.Instance.GL.Context.GetViewport().Width; windowHeight = Director.Instance.GL.Context.GetViewport().Height; panel.AddChildLast(scoreLabel); panel.AddChildLast(airLabel); uiScene.RootWidget.AddChildLast(panel); UISystem.SetScene(uiScene); //Create the background. background = new Background(gameScene); //Create the flappy guy bird = new Bird(gameScene); //Create some chains. chain = new Chain[OBSTACLE_COUNT]; chain[0] = new Chain(windowWidth * 0.5f, gameScene); chain[1] = new Chain(windowWidth, gameScene); //Create seamines and attach to chain seamine = new Mine[OBSTACLE_COUNT]; seamine[0] = new Mine((X = chain[0].GetX + chain[0].GetMaxX) - 80, Y = chain[0].GetY + chain[0].GetMaxY, gameScene); seamine[1] = new Mine((X = chain[1].GetX + chain[1].GetMaxX) - 80, Y = chain[1].GetY + chain[1].GetMaxY, gameScene); //Create Bubbles bubble = new List <Bubble>(); bubble.Add(new Bubble(windowWidth / 4, -70.0f, 0.75f, gameScene)); bubble.Add(new Bubble(windowWidth / 2, -42.0f, 0.25f, gameScene)); bubble.Add(new Bubble((windowWidth / 4) * 3, -103.0f, 0.5f, gameScene)); bubble.Add(new Bubble(windowWidth, -129.0f, 0.5f, gameScene)); //Run the scene. Director.Instance.RunWithScene(gameScene, true); }
public void pushScene(Sce.PlayStation.HighLevel.GameEngine2D.Scene scene) { Sce.PlayStation.HighLevel.GameEngine2D.Director.Instance.PushScene(scene); }
/**************************************** * 描画も一緒に行う(画像) ****************************************/ /// <summary> /// Draws the sprite. able to touch. but default TouchOn is false. /// Touchできる画像のspriteを作成し、sceneに追加するメソッド。 /// デフォルトではタッチは無効。 /// </summary> /// <param name='strPicture'> /// String picture. /// </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 width of picture /// </param> /// <param name='scene'> /// Scene. /// </param> public void DrawSprite(String strPicture, float positionX, float positionY, float sizeX, float sizeY, Scene scene) { this.SetSpriteForTouch(DrawPicture.DrawSprite(strPicture, positionX, positionY, sizeX, sizeY, scene), positionX, positionY, false); }