static void Main( string[] args ) { Sce.PlayStation.Core.Graphics.GraphicsContext context = new Sce.PlayStation.Core.Graphics.GraphicsContext(); uint sprites_capacity = 500; // maximum number of vertices that can be used in debug draws uint draw_helpers_capacity = 400; // initialize GameEngine2D's singletons, passing context from outside Director.Initialize( sprites_capacity, draw_helpers_capacity, context ); Director.Instance.GL.Context.SetClearColor( Colors.Grey20 ); // set debug flags that display rulers to debug coordinates Director.Instance.DebugFlags |= DebugFlags.DrawGrid; // set the camera navigation debug flag (press left alt + mouse to navigate in 2d space) Director.Instance.DebugFlags |= DebugFlags.Navigate; //var scene = new MapTestScene(); //var scene = new GamePlayScene(); var scene = new TitleScene(); // set the camera so that the part of the word we see on screen matches in screen coordinates scene.Camera.SetViewFromViewport(); Director.Instance.RunWithScene( scene, true ); while (true ) { Sce.PlayStation.Core.Environment.SystemEvents.CheckEvents(); #if EXTERNAL_INPUT // it is not needed but you can set external input data if you want List<TouchData> touch_data_list = Touch.GetData(0); Input2.Touch.SetData( 0, touch_data_list ); GamePadData pad_data = GamePad.GetData(0); Input2.GamePad.SetData( 0, pad_data ); #endif // #if EXTERNAL_INPUT Director.Instance.Update(); Director.Instance.Render(); Director.Instance.GL.Context.SwapBuffers(); Director.Instance.PostSwap(); } Director.Terminate(); //System.Console.WriteLine( "Bye!" ); }
/// <summary>GraphicsContextAlpha constructor.</summary> public GraphicsContextAlpha( Sce.PlayStation.Core.Graphics.GraphicsContext context = null ) { m_context = context; m_context_must_be_disposed = false; if ( m_context == null ) { m_context = new Sce.PlayStation.Core.Graphics.GraphicsContext(); m_context_must_be_disposed = true; // this class takes ownership of m_context } ModelMatrix = new MatrixStack(16); ViewMatrix = new MatrixStack(16); ProjectionMatrix = new MatrixStack(8); m_white_texture = CreateTextureUnicolor( 0xffffffff ); m_white_texture_info = new TextureInfo( m_white_texture ); DebugStats = new DebugStats_(); }
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(); } }
public static Scene Init() { // create our own context Sce.PlayStation.Core.Graphics.GraphicsContext context = new Sce.PlayStation.Core.Graphics.GraphicsContext(); // maximum number of sprites you intend to use (not including particles) uint sprites_capacity = 500; // maximum number of vertices that can be used in debug draws uint draw_helpers_capacity = 400; // initialize GameEngine2D's singletons, passing context from outside Director.Initialize(sprites_capacity, draw_helpers_capacity, context); Director.Instance.GL.Context.SetClearColor(setBackgroundColor); // set debug flags that display rulers to debug coordinates // Director.Instance.DebugFlags |= DebugFlags.DrawGrid; // set the camera navigation debug flag (press left alt + mouse to navigate in 2d space) Director.Instance.DebugFlags |= DebugFlags.Navigate; // create a new scene var scene = new Scene(); // set the camera so that the part of the word we see on screen matches in screen coordinates scene.Camera.SetViewFromViewport(); // handle the loop ourself Director.Instance.RunWithScene(scene, true); // Set up LuaInterface lua = new Lua(); lua.NewTable("love"); ((LuaTable)lua["love"])["load"] = null; ((LuaTable)lua["love"])["draw"] = null; ((LuaTable)lua["love"])["update"] = null; ((LuaTable)lua["love"])["quit"] = null; // Register C# keyboard functions lua.NewTable("love.keyboard"); lua.RegisterFunction("love.keyboard.isDown", null, typeof(Graphics).GetMethod("love_keyboard_isDown")); // NEW API ONLY FOR THIS PORT lua.NewTable("love.touch"); // Register C# function lua.RegisterFunction("love.touch.getPos", null, typeof(Graphics).GetMethod("love_touch_getpos")); // Register C# audio functions lua.NewTable("love.audio"); // Register C# graphic functions lua.NewTable("love.graphics"); lua.RegisterFunction("love.graphics.setCaption", null, typeof(Graphics).GetMethod("love_graphics_setCaption")); lua.RegisterFunction("love.graphics.newImage", null, typeof(Graphics).GetMethod("love_graphics_newImage")); lua.RegisterFunction("love.graphics.setColor", null, typeof(Graphics).GetMethod("love_graphics_setColor")); lua.RegisterFunction("love.graphics.setBackgroundColor", null, typeof(Graphics).GetMethod("love_graphics_setBackgroundColor")); lua.RegisterFunction("love.graphics.rectangle", null, typeof(Graphics).GetMethod("love_graphics_rectangle")); lua.RegisterFunction("love.graphics.newQuad", null, typeof(Graphics).GetMethod("love_graphics_newQuad")); lua.RegisterFunction("love.graphics.draw", null, typeof(Graphics).GetMethod("love_graphics_draw", new Type[] { typeof(TextureInfo), typeof(float), typeof(float), typeof(float), typeof(float), typeof(float), typeof(float), typeof(float) })); lua.RegisterFunction("love.graphics.drawq", null, typeof(Graphics).GetMethod("love_graphics_drawq")); // Read Lua file lua.DoFile("/Application/assets/main.lua"); return(scene); }
internal GraphicsCaps(GraphicsContext graphics) { PsmGraphicsContext.GetCaps(graphics.handle, out this.state); }