1 2 3 4 5 6 7 8 9 10 11 12 | public class Program : App { public Program() { // Initialization code goes here } public static void Main() { new Program().Run(); } } |
1 | Resolve<Window>().BackgroundColor = Color.CornflowerBlue; |
1 | resolver->Resolve<Window>()->SetBackgroundColor(Color::CornflowerBlue); |
1 | Resolve<Window>().BackgroundColor = Color.CornflowerBlue; |
1 | Resolve<Window>().BackgroundColor = Color.CornflowerBlue |
Windows | Android | Play in Browser |
1 2 3 4 5 | var line = new Line2D(-Vector2D.Half, Vector2D.Half, Color.Red); line.Rotation = 0; line.Entity.AddComponent( new Rotate2D()); Scene.Current.AttachGestureAndMessages(line, Gesture.Click, new SetRenderDataMessage<Color> { NewValue = Color.Yellow }); |
1 | auto line = std::make_shared<Line2D>(Point::Zero, Point::One, Color::Red); |
1 | Resolve<Window>().BackgroundColor = Color.CornflowerBlue; |
1 | Resolve<Window>().BackgroundColor = Color.CornflowerBlue |
Windows | Android | Play in Browser |
1 | new Ellipse(Vector2D.Half, 0.4f, 0.2f, Color.Red); |
1 | std::make_shared<Ellipse>(Point::Half, 0.4f, 0.2f, Color::Red); |
1 | new Ellipse(Point.Half, 0 .4f, 0 .2f, Color.Red); |
1 | new Ellipse(Point.Half, 0.4f, 0.2f, Color.Red) |
Windows | Android | Play in Browser |
1 | new Sprite( "DeltaEngineLogo" , Vector2D.Zero); |
1 | std::make_shared<Sprite>( "DeltaEngineLogo" , Vector2D::Zero); |
1 | new Sprite( "DeltaEngineLogo" , Vector2D.Zero); |
1 | new Sprite( "DeltaEngineLogo" , Vector2D.Zero) |
Windows | Android | Play in Browser |
1 2 3 4 5 6 | var sprite = new Sprite( "DeltaEngineLogo" , Vector2D.Zero) { Size = new Size(0.5f), Rotation = 0 }; sprite.Entity.AddComponent( new Rotate2D()); |
1 | std::make_shared<Ellipse>(Point::Half, 0.4f, 0.2f, Color::Red); |
1 2 3 | new Sprite(ContentLoader.Load<Material>( "Logo" ), Rectangle.HalfCentered). StartRotating(Randomizer.Current.Get(- 50 , 50 )); |
1 2 3 | new Sprite(ContentLoader.Load<Material>( "Logo" ), Rectangle.HalfCentered). StartRotating(Randomizer.Current. Get (-50, 50)) |
Windows | Android | Play in Browser |
1 2 3 4 | var sprite = new Sprite( "Road" , Vector2D.Zero); sprite.Size = Size.One; sprite.UV = UVRectangle.One; sprite.Entity.AddComponent( new MoveUV { Speed = Vector2D.Down }); |
1 | std::make_shared<Ellipse>(Point::Half, 0.4f, 0.2f, Color::Red); |
1 2 3 | new Sprite(ContentLoader.Load<Material>( "Logo" ), Rectangle.HalfCentered). StartRotating(Randomizer.Current.Get(- 50 , 50 )); |
1 2 3 | new Sprite(ContentLoader.Load<Material>( "Logo" ), Rectangle.HalfCentered). StartRotating(Randomizer.Current. Get (-50, 50)) |
Windows | Android | Play in Browser |
1 | new FontText(Font.Default, "Hi there" , Vector2D.Zero); |
1 | std::make_shared<FontText>(Font::Default, "Hi there" , Vector2D::Zero); |
1 | new FontText(Font.Default, "Hi there" , Vector2D.Zero); |
1 | new FontText(Font. Default , "Hi there" , Vector2D.Zero) |
Windows | Android | Play in Browser |
1 2 3 4 | var sound = new Sound( "DefaultSound" ); new FontText(Font.Default, "Click to play sound" , Vector2D.Zero); Scene.Current.AttachGestureAndMessages(sound, Gesture.Click, new PlayMessage()); |
1 | std::make_shared<Sound>( "DefaultSound" ); |
1 2 | var sound = ContentLoader.Load<Sound>( "DefaultSound" ); new Command( "Click" , () => sound.Play()); |
1 2 | var sound = ContentLoader.Load<Sound>( "DefaultSound" ) new Command( "Click" , () => sound.Play()) |
Windows | Android | Play in Browser |
1 2 3 4 | var music = new Music( "DefaultMusic" ); new FontText(Font.Default, "Click to play music" , Vector2D.Zero); Scene.Current.AttachGestureAndMessages(music, Gesture.Click, new PlayMessage()); |
1 | std::make_shared<Music>( "DefaultMusic" ); |
1 2 | var music = ContentLoader.Load<Music>( "DefaultMusic" ); new Command( "Click" , () => music.Play()); |
1 2 | var music = ContentLoader.Load<Music>( "DefaultMusic" ) new Command( "Click" , () => music.Play()) |
Windows | Android | Play in Browser |
1 2 3 4 | var video = new Video( "DefaultVideo" ); new FontText(Font.Default, "Click to play video" , Vector2D.Zero); Scene.Current.AttachGestureAndMessages(video, Gesture.Click, new PlayMessage()); |
1 | std::make_shared<Music>( "DefaultMusic" ); |
1 2 | var music = ContentLoader.Load<Music>( "DefaultMusic" ); new Command( "Click" , () => music.Play()); |
1 2 | var music = ContentLoader.Load<Music>( "DefaultMusic" ) new Command( "Click" , () => music.Play()) |
Windows | Android | Play in Browser |
1 2 3 4 5 6 | public class Earth : Sprite { public Earth(Vector2D position) : base (Scene.Current.GetEntity( "EarthImagesAnimation" ), position) {} } |
1 2 3 4 5 | Scene.Current.AttachGestureAndMessages( Scene.Current.GetEntity( "EarthImagesAnimation" ), Gesture.Click, new TogglePauseMessage()); for ( int num = 0; num < 10; num++) new Earth( new Vector2D(-0.45f + num / 10.0f, 0)); |
Windows | Android | Play in Browser |
1 2 3 4 5 6 7 8 9 10 11 | public class Earth : Sprite { public Earth(Vector2D position) : base (Scene.Current.GetEntity( "EarthImagesAnimation" ), position) { Entity.AddComponent(Gravity2D.Shared); Entity.AddComponent( new Velocity2D()); Entity.AddComponent( new BounceIfAtScreenEdge()); } } |
Windows | Android | Play in Browser |
1 2 3 4 5 6 7 8 9 10 11 12 | public class Earth : Sprite { public Earth(Vector2D position) : base (Scene.Current.GetEntity( "EarthImagesAnimation" ), position) { Entity.AddComponent( new OutlineColor { Color = Color.Red }); Entity.AddComponent(Gravity2D.Shared); Entity.AddComponent( new Velocity2D()); Entity.AddComponent( new BounceIfAtScreenEdge()); } } |
Windows | Android | Play in Browser |
1 2 3 4 5 6 7 8 9 10 11 12 13 | public class Earth : Sprite { public Earth(Vector2D position) : base ( "DeltaEngineLogo" , position) { Entity.AddComponent( new Velocity2D { Speed = new Vector2D(0.2f, 0.5f)}); Entity.AddComponent( new BounceIfAtScreenEdge { ReflectionStrength = 1 }); Scene.Current.AttachTriggerAndMessages(Entity, new CollisionTrigger(), new RandomColorMessage()); } } |
Windows | Android | Play in Browser |
1 2 3 | new Earth( new Vector2D(0.3f, 0.5f)).AddTag( "EarthToggle" ); new Earth( new Vector2D(0.5f, 0.5f)).AddTag( "EarthToggle" ); new Earth( new Vector2D(0.7f, 0.5f)).AddTag( "EarthNormal" ); |
1 2 3 4 5 6 | new Command(Command.Click, () => { foreach (Earth entity in EntitiesRunner.Current.GetEntitiesWithTag( "EarthToggle" )) entity.IsPlaying = !entity.IsPlaying; }); |
Windows | Android | Play in Browser |
1 2 3 4 5 6 7 | public Program() { var random = Randomizer.Current; for ( int num = 0; num < 3; num++) new Earth( new Vector2D(random.Get(0.2f, 0.8f), random.Get(0.3f, 0.7f)), new Vector2D(random.Get(-0.4f, 0.4f), random.Get(-0.3f, 0.3f))); } |
1 2 3 4 5 6 7 | public void Update() { var allEarths = EntitiesRunner.Current.GetEntitiesOfType<Earth>(); Set(allEarths.Any(other => this != other && Center.DistanceTo(other.Center) < Size.Width) ? Color.Yellow : Color.White); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | public void Update() { var allEarths = EntitiesRunner.Current.GetEntitiesOfType<Earth>(); bool isCollidingWithAnotherEarth = false ; foreach (Earth otherEarth in allEarths) if ( this != otherEarth && Center.DistanceTo(otherEarth.Center) < Size.Width) { isCollidingWithAnotherEarth = true ; break ; } Set(isCollidingWithAnotherEarth ? Color.Yellow : Color.White); } |
Windows | Android | Play in Browser |
1 2 | var earth = new Earth(Vector2D.Half); new Command(Command.Click, () => earth.IsActive = !earth.IsActive); |
1 | entity.Dispose(); |
1 | entity.IsActive = true ; |
1 | Time.IsPaused = true ; |
Windows | Android | Play in Browser |
1 | new Command(Command.Exit, Resolve<Window>().CloseAfterFrame); |
1 2 3 4 5 6 7 8 9 10 11 12 | public class Player : Sprite { public Player() : base (ContentLoader.Load<Material>( "Logo" ), new Vector2D(0.5f, 0.7f)) { new Command(Command.MoveLeft, () => Center -= new Vector2D(Time.Delta * 0.5f, 0)); new Command(Command.MoveRight, () => Center += new Vector2D(Time.Delta * 0.5f, 0)); } } |
Windows | Android | Play in Browser |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public class EnemySpawner : Entity, Updateable { public void Update() { if (Time.CheckEvery(2.5f)) new Enemy(); } public bool IsPauseable { get { return true ; } } } public class Enemy : Sprite { public Enemy() : base (ContentLoader.Load<Material>( "Earth" ), Rectangle.FromCenter( new Vector2D(Randomizer.Current.Get(), 0.1f), new Size(0.1f * 1.35f, 0.1f))) { Add( new SimplePhysics.Data { Gravity = new Vector2D(0.0f, 0.1f), Duration = 10 }); Start<SimplePhysics.Move>(); } } |
Windows | Android | Play in Browser |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | public Program() { new Sprite(ContentLoader.Load<Material>( "Road" ), Rectangle.One). StartMovingUV( new Vector2D(0, -0.8f)); new ScoreDisplay( new Player(), new EnemySpawner()); new Command( "Exit" , Resolve<Window>().CloseAfterFrame); } public class ScoreDisplay : FontText, Updateable { public ScoreDisplay(Player player, EnemySpawner spawner) : base (Font.Default, "Score: " , Rectangle.FromCenter(0.5f, 0.25f, 0.2f, 0.1f)) { this .player = player; this .spawner = spawner; RenderLayer = 1; } private readonly Player player; private readonly EnemySpawner spawner; public void Update() { if (Text.StartsWith( "Game Over" )) return ; if (player.Color == Color.White) Text = "Score: " + spawner.EnemiesSpawned; else Text = "Game Over! " + Text; } public bool IsPauseable { get { return false ; } } } public class EnemySpawner : Entity, Updateable { public void Update() { if (!Time.CheckEvery(spawnTime)) return ; EnemiesSpawned++; if (spawnTime > 0.5f) spawnTime -= 0.15f; new Enemy(); } private float spawnTime = 2.5f; public int EnemiesSpawned { get ; private set ; } public bool IsPauseable { get { return true ; } } } public class Enemy : Sprite { public Enemy() : base (ContentLoader.Load<Material>( "Earth" ), Rectangle.FromCenter( new Point(Randomizer.Current.Get(), 0.1f), new Size(0.1f * 1.35f, 0.1f))) { Add( new SimplePhysics.Data { Gravity = new Point(0.0f, 0.1f), Duration = 10 }); Start<SimplePhysics.Fall>(); } } public class Player : Sprite, Updateable { public Player() : base (ContentLoader.Load<Material>( "Logo" ), new Point(0.5f, 0.7f)) { new Command( "MoveLeft" , () => Center -= new Point(Time.Delta * 0.5f, 0)); new Command( "MoveRight" , () => Center += new Point(Time.Delta * 0.5f, 0)); } public void Update() { var earths = EntitiesRunner.Current.GetEntitiesOfType<Enemy>(); if (!earths.Any(e => Center.DistanceTo(e.Center) < Size.Width/3 + e.Size.Width/2)) return ; Set(Color.Red); foreach (var command in commands) command.IsActive = false ; } public bool IsPauseable { get { return true ; } } } |
Windows | Android | Play in Browser |