private static void PostFxWithRenderTexture() { Window win = new Window(800, 600, "RenderTV"); Sprite bkgSprite = new Sprite(win.Width, win.Height); GrayScaleFX grayFx = new GrayScaleFX(); RenderTexture renderTxt = new RenderTexture(win.Width, win.Height); Sprite renderSpr = new Sprite(win.Width, win.Height); Texture prova = new Texture(win.Width, win.Height); while (win.IsOpened) { win.RenderTo(renderTxt); bkgSprite.DrawColor(255, 0, 0); grayFx.Apply(renderTxt); win.RenderTo(null); renderSpr.DrawRenderTexture(renderTxt); /* * byte[] data = renderTxt.Download(); * prova.Update(data); * renderSpr.DrawTexture(prova); */ win.Update(); } }
public static void Run() { Window window = new Window(400, 300, "Draw Sprite Example"); Sprite redLine = new Sprite(100, 10); redLine.position.X = 0; redLine.position.Y = 0; Sprite greenLine = new Sprite(100, 10); greenLine.position.X = 80; greenLine.position.Y = 51; Sprite wireFrame = new Sprite(100, 100); wireFrame.position.X = 100; wireFrame.position.Y = 100; while (window.IsOpened) { redLine.DrawColor(255, 0, 0); greenLine.DrawColor(0, 255, 0); wireFrame.DrawWireframe(255, 0, 0, 1); window.Update(); } }
protected override void Update(GameTime gameTime) { UiState.Update(); Shortcuts.Update(); if (!GraphicsDevice.Viewport.Bounds.Contains(UiState.Mouse.Position)) { _window.LastHitTest = null; } if (Modals.Count > 0) { Modals.Update(); _waitForMouseUp = true; return; } if (!_waitForMouseUp) { _window.Update(); } else { _waitForMouseUp = !MouseManager.AreAllUp(); } }
public static void Run() { Window window = new Window(1024, 768, "GetPixels"); RenderTexture screen = new RenderTexture(800, 600); Sprite sprite = new Sprite(100, 100); // half the render texture (to retain aspect ratio) Sprite lowAngle = new Sprite(400, 300); Sprite final = new Sprite(800, 600); GrayscaleEffect effect = new GrayscaleEffect(); YellowizerEffect yellowizer = new YellowizerEffect(); sprite.position = new Vector2(200, 200); lowAngle.position = new Vector2(400, 400); Random random = new Random(); Texture dumbTexture = new Texture(800, 600); // in opengl, textures are flipped on the y axis dumbTexture.flipped = true; Masker masker = new Masker(); masker.AddTexture("mask", new Texture("RenderTexture/Assets/star.png")); window.AddPostProcessingEffect(masker); window.SetClearColor(0, 0, 255, 255); while (window.IsOpened) { sprite.EulerRotation += 30 * window.DeltaTime; window.RenderTo(screen); sprite.DrawColor(255, 0, 0); if (random.Next() % 2 == 0) { screen.ApplyPostProcessingEffect(effect); } if (random.Next() % 2 == 0) { screen.ApplyPostProcessingEffect(yellowizer); } window.RenderTo(null); final.DrawRenderTexture(screen); byte[] data = screen.Download(); dumbTexture.Update(data); lowAngle.DrawTexture(dumbTexture); GC.Collect(); window.Update(); } }
static void Main(string[] args) { Window window = new Window(1024, 576, "castle"); window.EnableDepthTest(); Mesh3[] meshes = ObjLoader.Load("Assets/Castle.obj", Vector3.One * 5); PerspectiveCamera camera = new PerspectiveCamera(new Vector3(0, 250, 750), new Vector3(10, 180, 0), 60, 0.1f, 1000); Console.WriteLine(meshes.Length); DirectionalLight sun = new DirectionalLight(new Vector3(-0.5f, 0, -1).Normalized()); float rot = 0; while (window.IsOpened) { rot += 10 * window.deltaTime; foreach (Mesh3 mesh in meshes) { mesh.EulerRotation3 = new Vector3(0, rot, 0); //mesh.DrawWireframe(new Vector4(1, 0, 0, 1)); mesh.DrawPhong(new Vector4(1, 0, 0, 1), sun, new Vector3(0.1f, 0.1f, 0.1f)); } window.Update(); } }
public static void Play() { currentScene.Start(); isRunning = true; while (Win.IsOpened && isRunning) { //Change scene if (!currentScene.isPlaying) { // Need to change scene Scene nextScene = currentScene.OnExit(); GC.Collect(); if (nextScene != null) { currentScene = nextScene; currentScene.Start(); } else { return; } } //GameLoop currentScene.Input(); currentScene.Update(); currentScene.Draw(); Win.Update(); } }
public static void Update() { while (window.opened) { window.Update(); } }
private void ListWnd_ButtonClicked(object sender, EventArgs e) { if (((ListObject)sender).ActiveLine == 0) { characterWindow.Update(); app.AddWindow(characterWindow); foreach (Window win in app.windows) { if (win.IdentificationNumber == 1) { win.TimerStart(1000); } } } if (((ListObject)sender).ActiveLine == 1) { processWindow.Update(); app.AddWindow(processWindow); } if (((ListObject)sender).ActiveLine == 2) { networkWindow.Update(); app.AddWindow(networkWindow); foreach (Window win in app.windows) { if (win.IdentificationNumber == 3) { win.TimerStart(1000); } } } }
/// <summary> /// Sprite Based tiling is always affected by wrong pixel texture selection, /// even using GL_NEAREST. /// - With GL_NEAREST, the last pixel column of the first Sprite (tile00) is filled with the first pixel column of the second Sprite (tile01) /// So where should be a black column of pixel, there is a yellow one. /// = Without GL_NEAREST (default seems to be GL_LINEAR), the first pixel column of tile01 is interpolated with the last pixel column of tile00 /// So where should be a yellow column of pixel, there is a very dark yellow one. /// /// Possible Solution to the issue is: /// - wrap each tile in the tilesheet with 1px border who repeat the color of each tile edge. /// - This way using both GL_NEAREST or GL_LINEAR should select the right color when on the edge of the tile /// /// NOTE: Anyway Sprite based tiling is not good for perfomrance because for each sprite/tile we want to draw on window we need to make a Draw Call /// to upload Vertices and UV. /// </summary> private static void SpriteBasedTiling() { Window window = new Window(400, 300, "Tiling Example"); Texture tilesheet = new Texture("Tiling/Assets/simple-sheet-32x32.png"); tilesheet.SetNearest(); Sprite tile00 = new Sprite(32, 32); tile00.position.X = 0; tile00.position.Y = 0; Sprite tile01 = new Sprite(32, 32); tile01.position.X = 32; tile01.position.Y = 0; int size = 32; int offset = 32; while (window.IsOpened) { window.SetClearColor(255, 255, 255); tile00.DrawTexture(tilesheet, 0, 0, size, size); tile01.DrawTexture(tilesheet, offset, 0, size, size); window.Update(); } }
private static void Main(string[] args) { using SDL.SDL2 sdl2 = new SDL.SDL2(Subsystems.Video); using Window window = new Window( "SDL2_dotnet Example", WindowPosition.Undefined, ScreenResolution.VGA, WindowOptions.Shown); bool quit = false; // While application is running while (!quit) { while (Event.Next) { if (Event.Type == EventType.Quit) { quit = true; } } window.Surface.Fill(NextColor()); window.Update(); } Timer.Delay(2000); }
public void Run() { while (window.IsOpened) { Update(); window.Update(); } }
public void Update(GameTime gameTime) { if (Window == null) { return; } Window.Update(gameTime); }
public static void Main(string[] args) { Window window = new Window("Test", 960, 540); while (!window.Closed()) { Vector2 mouse = window.GetMousePosition(); Console.WriteLine("{0}, {1}", mouse.x, mouse.y); window.Update(); } }
private static void FullExample() { Window Win = new Window(1280, 720, "RenderTV"); Texture bgTexture = new Texture("RenderTV/Assets/vaporBg.jpg"); Sprite bg = new Sprite(bgTexture.Width, bgTexture.Height); Texture shipTexture = new Texture("RenderTV/Assets/futurama_ship.png"); Sprite ship = new Sprite(shipTexture.Width, shipTexture.Height); ship.position = new Vector2(300, 300); RenderTexture renderT = new RenderTexture(Win.Width, Win.Height); Sprite renderSprite = new Sprite(Win.Width * 0.4f, Win.Height * 0.4f); renderSprite.pivot = new Vector2(renderSprite.Width * 0.5f, renderSprite.Height * 0.5f); renderSprite.position = new Vector2(Win.Width * 0.5f, Win.Height * 0.5f); Texture tvTexture = new Texture("RenderTV/Assets/tv.png"); Sprite tv = new Sprite(tvTexture.Width, tvTexture.Height); tv.pivot = new Vector2(tv.Width * 0.5f, tv.Height * 0.5f); tv.position = renderSprite.position; tv.scale = new Vector2(0.4f, 0.4f); float accumulator = 0; WobbleFX wobble = new WobbleFX(2); GrayScaleFX grayScale = new GrayScaleFX(); while (Win.IsOpened) { //Update accumulator += Win.DeltaTime * 2; ship.position.Y -= (float)Math.Sin(accumulator) * 50 * Win.DeltaTime; wobble.Update(Win); //Draw Win.RenderTo(renderT); bg.DrawTexture(bgTexture); ship.DrawTexture(shipTexture); renderT.ApplyPostProcessingEffect(wobble); renderT.ApplyPostProcessingEffect(grayScale); Win.RenderTo(null); renderSprite.DrawRenderTexture(renderT); tv.DrawTexture(tvTexture); Win.Update(); } }
// This gets called on each frame render protected override void OnRenderFrame(FrameEventArgs e) { if (this.mobileGame.requestedExit) { this.mobileGame.FinishActivity(0); return; } base.OnRenderFrame(e); mobileGame.GameUpdate(window); window.Update(); }
private static void DisplayColors(Window window, int count) { for (int i = 0; i < count; i++) { foreach (Color color in colors) { window.Surface.Fill(color); window.Update(); Timer.Delay(16); // ~60 FPS } } }
static void Main(string[] args) { var window = new Window("Hello, IdiotGraphics", 800, 600); window.Visiable = true; while (true) { window.Update(); window.Render(); Thread.Sleep(15); } }
static void Main(string[] args) { //Object scale float size = 4f; #region InstanceWindow //Instance new window Window window = new Window(1024, 768, "Test", false, 16, 4); #endregion #region DecompressTexture /* * Decompress Texture from single file * This method has to be called only once, * because it could slows down the game, * do decompression in single project which is not * a part of your own working project. */ TextureHelper.GenerateDecompressedTextureFromFile("Assets/drum1_ambient.png", "NewAssets"); //Decompress Textures from list of files (Has to be called only once) //bool bRecursive = false; //string sExtension = "tex"; //TextureHelper.GenerateDecompressedTexturesFromFolder("Assets", "NewAssets", bRecursive, sExtension); #endregion #region LoadDecompressedTexture //Return decompressed texture and save it. Texture loadedTexture = TextureHelper.LoadDecompressedTexture("GasFuel.txt"); #endregion #region LoadOBJModel //Create a Mesh3[] to load custo ".obj"'s model Mesh3 mesh = ObjLoader.Load("Assets/GasFuel.obj", Vector3.One * size)[0]; #endregion #region GameLoop while (window.opened) { //draw the mesh mesh.DrawTexture(loadedTexture); //Break while loop if (window.GetKey(KeyCode.Esc)) { break; } window.Update(); } #endregion }
public static void Play() { //scenesCreation TitleScene aivTitle = new TitleScene("Assets/aivBG.png", KeyCode.Return); WelcomeScene welcome = new WelcomeScene("Assets/welcomeBg.jpg", KeyCode.Return); PlayScene playScene = new PlayScene(); GameOverScene gameover = new GameOverScene(); //scenes config aivTitle.NextScene = welcome; aivTitle.ShowTime = 3; aivTitle.FadeIn = true; aivTitle.FadeOut = true; welcome.NextScene = playScene; welcome.FadeOut = false; playScene.NextScene = gameover; gameover.NextScene = playScene; aivTitle.Start(); CurrentScene = aivTitle; //GfxManager.Load(); while (Window.opened) { if (!CurrentScene.IsPlaying) { //next scene if (CurrentScene.NextScene != null) { CurrentScene.OnExit(); CurrentScene = CurrentScene.NextScene; CurrentScene.Start(); } else return; } //Input if (Window.GetKey(KeyCode.Esc)) break; CurrentScene.Input(); //Update CurrentScene.Update(); //Draw CurrentScene.Draw(); Window.Update(); } }
public override void Update(double elapsedSeconds) { if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Back)) { Manager.ExitGame(); } touchInput.HandleGestures(); window.Update(elapsedSeconds); window.PerformLayout(Manager.GraphicsDevice.Viewport.Width, Manager.GraphicsDevice.Viewport.Height); base.Update(elapsedSeconds); }
public override void Update(double elapsedSeconds) { if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.Back)) { Manager.TransitionTo <MainMenuScreen>(); } touch.HandleGestures(); gui.PerformLayout(Manager.GraphicsDevice.Viewport.Width, Manager.GraphicsDevice.Viewport.Height); gui.Update(elapsedSeconds); base.Update(elapsedSeconds); }
private static void MeshBasedTilingSimple() { Window window = new Window(800, 600, "Tiling Example"); SmartTilemap tmap = new SmartTilemap("Tiling/Assets/simple-scene.csv", "Tiling/Assets/simple-sheet-32x32.png", 32); while (window.IsOpened) { window.SetClearColor(255, 255, 255); tmap.Draw(); window.Update(); } }
public static void Run() { while (window.IsOpened) { if (window.GetKey(KeyCode.Esc)) { window.Exit(); } window.Update(); } }
private static void MeshBasedTilingComplex() { Window window = new Window(800, 600, "Tiling Example"); SmartTilemap tmap = new SmartTilemap("Tiling/Assets/complex-01-scene.csv", "Tiling/Assets/complex-01-sheet-71x71.png", 70, true); //window.SetAlphaBlending(); while (window.IsOpened) { window.SetClearColor(0, 0, 0); tmap.Draw(); window.Update(); } }
public ISlidingWindowCalculation GetCalculationFor(DateTime timeStamp) { if (dateTimeProvider.Now - timeStamp > windowLength) { throw new ArgumentOutOfRangeException(nameof(timeStamp)); } // Use CurrentWindow as base. Later, cache the Windows generated and use the one covering most of the requested frame. var window = new Window(calculationProvider()); window.Clone(currentWindow); window.Update(GetWindowStartTimeStamp(timeStamp), GetTimeStampKey(timeStamp), bucketsList); return(window.Calculation); }
private static void GameLoop() { while (gameState != -1) { if (gameState == 1) { PlayerUpdate(); EnemiesUpdate(); BulletsUpdate(); Game.Update(3); Window.HUDUpdate(hud); Window.Update(); } if (Console.KeyAvailable) { if (gameState == 0) { Reset(); } ConsoleKey input = Console.ReadKey(true).Key; if (gameState == 2) { gameState = 1; } else if (input == ConsoleKey.Escape) { if (gameState == 0) { gameState = -1; } else if (gameState == 1) { gameState = 2; } } else if (input == ConsoleKey.Spacebar) { player.Fire(); } else { player.gameObject.ChangeDirection(input); } } } }
/// <summary> /// This is where all the Tower defense update calls should be placed so that it is easy to transfer our /// project over to the main one without having to add a lot of code to the main program. /// </summary> /// <param name="gametime">current game time</param> /// <param name="keyboard">keyboard state</param> /// <param name="mouse">mouse state</param> public static void Update(GameTime gametime, KeyboardState keyboard, MouseState mouse) { Random random = new Random(); if (LastWaveUpdate == TimeSpan.Zero) { LastWaveUpdate = gametime.TotalGameTime; } if (currentWave != null && !currentWave.complete) { currentWave.update(gametime); LastWaveUpdate = gametime.TotalGameTime; } else if ((gametime.TotalGameTime - LastWaveUpdate) > SpawnNextWaveIn) { if (TDPlayerStats.currentWave == TDPlayerStats.maxWaves) { TPEngine.Get().State.PopState(); TPEngine.Get().State.PushState(new TDScoreScreenState()); } TDPlayerStats.Money += 5; TDPlayerStats.currentWave++; currentWave = new EnemyWave(random.Next(8, 12), 1); //LastWaveUpdate = gametime.TotalGameTime; } if (TDPlayerStats.Grade <= 0) { TPEngine.Get().State.PopState(); TPEngine.Get().State.PushState(new TDScoreScreenState()); } if (Keyboard.GetState().IsKeyDown(Keys.X) && !clicked) { TDPlayerStats.Grade = 0; TPEngine.Get().State.PopState(); TPEngine.Get().State.PushState(new TDScoreScreenState()); clicked = true; } TowerBuilder.UpdateKeyboardInput(keyboard, mouse); Enemy.Update(gametime); Tower.Update(gametime); Projectile.UpdateProjectiles(gametime); Window.Update(gametime, keyboard, mouse); }
public override void Update() { base.Update(); this.SortItems(); for (int i = 0; i < items.Count; i++) { if (items[i].Enabled) { items[i].Draw(); } } Window.Update(); }
static void Main(string[] args) { Window window = new Window(800, 600, "TEST"); while (window.opened) { Input.Update(window); if (Input.IsKeyDown(KeyCode.Space)) { Console.WriteLine("KEY DOWN"); } window.Update(); } }
private static void PostFxOnWindow() { Window win = new Window(800, 600, "RenderTV"); Sprite bkgSprite = new Sprite(win.Width, win.Height); GrayScaleFX grayFx = new GrayScaleFX(); win.AddPostProcessingEffect(grayFx); while (win.IsOpened) { bkgSprite.DrawColor(255, 0, 0); win.Update(); } }
private void GameUpdate(Window window) { if (window.IsTouching) { window.Vibrate(1000); } else { window.CancelVibration(); } mesh001.DrawColor(0f, 1f, 0f, 1f); alien.SetAdditiveTint(0f, 0, 0, 0); alien.position = window.TouchPosition; alien.DrawTexture(alienTexture); alien.SetAdditiveTint(1f, 0, 0, 0); alien.position = new Vector2(100, 100); alien.DrawTexture(alienTexture); window.Update(); }
static void Main(string[] args) { Window window = new Window(800, 600, "Aiv.Fast2D.Example"); window.SetLogger(new ExampleLogger()); window.SetIcon("aiv_fast2d_example.Assets.2.ico"); window.SetCursor(false); Texture logoAiv = new Texture("aiv_fast2d_example.Assets.LogoAIV.png"); Texture alien = new Texture("aiv_fast2d_example.Assets.owl.png"); Sprite logo = new Sprite(logoAiv.Width, logoAiv.Height); int height = 150; Sprite ship = new Sprite(alien.Width / 10, height); Sprite ship2 = new Sprite(alien.Width / 10, height); Sprite square = new Sprite(100, 100); InstancedSprite tiles = new InstancedSprite(100, 100, 3); tiles.SetPosition(0, new Vector2(150, 100)); tiles.SetPosition(1, new Vector2(200, 200)); tiles.SetPosition(2, new Vector2(500, 500)); tiles.SetScale(0, new Vector2(0.5f, 0.5f)); tiles.SetScale(1, new Vector2(1.5f, 1.5f)); InstancedSprite tiles2 = new InstancedSprite(20, 20, 30); RenderTexture screen = new RenderTexture(800, 600); RenderTexture fake = new RenderTexture(1, 1); fake.Dispose(); Sprite monitor = new Sprite(100, 100); monitor.position = new Vector2(400, 200); int index = 0; float t = 0; window.SetClearColor(100, 100, 100); int counter = 0; ParticleSystem particleSystem = new ParticleSystem(2, 2, 100); particleSystem.position = new Vector2(400, 200); Rope rope = new Rope(400, 3); rope.position = new Vector2(400, 200); rope.SetDestination(new Vector2(400, 400)); ship2.pivot = new Vector2(alien.Width / 20, height / 2); ParticleSystem particleSystem2 = new ParticleSystem(1, 2, 50); Mesh triangle = new Mesh(); triangle.v = new float[] { 100, 100, 50, 200, 150, 200 }; triangle.UpdateVertex(); triangle.uv = new float[] { 0.5f, 0.5f, 0, 0, 1, 0 }; triangle.UpdateUV(); Mesh farTriangles = new Mesh(); farTriangles.v = new float[] { 300, 100, 200, 200, 400, 200, 400, 400, 300, 500, 500, 500 }; farTriangles.UpdateVertex(); Mesh colouredTriangle = new Mesh(); colouredTriangle.v = new float[] { 500, 200, 400, 300, 600, 300 }; colouredTriangle.UpdateVertex(); colouredTriangle.vc = new float[] { 1, 0, 0, 0.5f, 0, 1, 0, 0.5f, 0, 0, 1, 0.5f }; colouredTriangle.UpdateVertexColor(); Texture alien2 = new Texture("aiv_fast2d_example.Assets.2.png"); RenderTexture maskedAlien = new RenderTexture(alien2.Width, alien2.Height); Sprite spriteMask = new Sprite(50, 50); Texture circleMask = new Texture("aiv_fast2d_example.Assets.mask_circle.png"); Texture circleMask2 = new Texture("aiv_fast2d_example.Assets.mask_circle2.png"); Sprite maskedObject = new Sprite(alien2.Width, alien2.Height); maskedObject.position = new Vector2(200, 200); Sprite maskedBackground = new Sprite(alien2.Width, alien2.Height); PostProcessingEffect mainEffect = window.AddPostProcessingEffect(new GrayscaleEffect()); mainEffect.enabled = false; window.AddPostProcessingEffect(new MaskEffect("aiv_fast2d_example.Assets.mask_circle.png")); window.AddPostProcessingEffect(new BlackBands()); window.AddPostProcessingEffect(new RedBands()); // insert a postprocessing effect at the specific position window.SetPostProcessingEffect(1, new WASDEffect()); window.SetPostProcessingEffect(1, new WobbleEffect(5)); Tilemap tileMap = new Tilemap("Assets/map001.csv", "Assets/tiles_spritesheet.png"); while (window.opened) { if (window.GetKey(KeyCode.Right)) { tileMap.position += new Vector2(1, 0) * window.deltaTime * 300; } if (window.GetKey(KeyCode.Left)) { tileMap.position += new Vector2(-1, 0) * window.deltaTime * 300; } if (window.GetKey(KeyCode.Up)) { tileMap.position += new Vector2(0, -1) * window.deltaTime * 300; } if (window.GetKey(KeyCode.Down)) { tileMap.position += new Vector2(0, 1) * window.deltaTime * 300; } tileMap.position += window.JoystickAxisRight(0) * window.deltaTime * 300; tileMap.Draw(); for (int i = 0; i < tiles2.Instances; i++) { tiles2.SetPosition(i, new Vector2(20 * i, 20 * i), true); if (i % 2 == 0) { tiles2.SetAdditiveColor(i, new Vector4(1, -1, -1, 1), true); } } tiles2.UpdatePositions(); tiles2.UpdateAdditiveColors(); ship.position.Y = 10; ship.position += new Vector2(5f, 0) * window.deltaTime; ship.scale = new Vector2(1f, 1f); t += window.deltaTime; if (t > 1f / 24f) { index++; if (index >= 51) index = 0; t = 0; } int x = (index % 10) * (alien.Width / 10); int y = (index / 10) * height; ship.DrawTexture(alien, x, y, alien.Width / 10, height); square.DrawSolidColor(1f, 0, 0, 0.5f); window.SetClearColor(255, 0, 0); window.RenderTo(screen); logo.position.Y = 100; logo.position += new Vector2(50f, 0) * window.deltaTime; logo.scale = new Vector2(1f, 1f); logo.DrawTexture(logoAiv); if (window.GetKey(KeyCode.Esc)) break; if (window.GetKey(KeyCode.F)) { window.SetFullScreen(true); window.SetResolution(1920, 1080); } if (window.GetKey(KeyCode.T)) { window.Title = string.Format("Counter = {0}", counter++); } if (window.GetKey(KeyCode.R)) { ship.SetAdditiveTint(1f, -1f, -1f, 0); //ship.SetMultiplyTint(2f, 0, 0, 1); } if (window.GetKey(KeyCode.N)) { ship.SetAdditiveTint(0, 0, 0, 0); //ship.SetMultiplyTint(2f, 0, 0, 1); } window.SetClearColor(100, 100, 100); window.RenderTo(null); monitor.DrawTexture(screen); Vector2 newPosition = tiles.GetPosition(2) - Vector2.One * 20f * window.deltaTime; tiles.SetPosition(2, newPosition); tiles.DrawSolidColor(0, 1, 1, 1); tiles2.position.X += 30 * window.deltaTime; tiles2.DrawSolidColor(1, 1, 0, 1); particleSystem.Update(window); //rope.SetDestination(window.mousePosition); rope.UpdatePhysics(window); rope.DrawSolidColor(1f, 0f, 1f, 1f); ship2.position = rope.position + rope.Point2; ship2.SetAdditiveTint(-1f, 1f, -1f, 0); ship2.DrawTexture(alien, x, y, alien.Width / 10, height); particleSystem2.position = ship2.position; particleSystem2.Update(window); farTriangles.DrawColor(0f, 0f, 1f, 1f); triangle.v[4] = window.mouseX; triangle.v[5] = window.mouseY; triangle.UpdateVertex(); if (window.HasFocus) { triangle.DrawTexture(alien); } else { window.SetScissorTest(window.Width / 2 - 200, window.Height / 2 - 200, 400, 400); triangle.DrawColor(1f, 0f, 1f, 1f); window.SetScissorTest(false); } window.SetClearColor(0f, 0f, 0f, 0f); window.RenderTo(maskedAlien); maskedBackground.DrawTexture(alien2); window.SetMaskedBlending(); spriteMask.scale = Vector2.One; spriteMask.position = new Vector2(150, 100); spriteMask.DrawTexture(circleMask); spriteMask.scale = new Vector2(2f, 2.7f); spriteMask.position = new Vector2(180, 280); spriteMask.DrawTexture(circleMask2); window.SetAlphaBlending(); window.SetClearColor(0.5f, 0.5f, 0.5f); window.RenderTo(null); maskedObject.DrawTexture(maskedAlien); if (window.GetKey(KeyCode.Space)) { mainEffect.enabled = true; } if (window.GetKey(KeyCode.Return)) { mainEffect.enabled = false; } if (window.GetKey(KeyCode.Num1)) { window.SetDefaultOrthographicSize(window.CurrentOrthoGraphicSize + window.deltaTime * 100); } colouredTriangle.position = window.mousePosition; colouredTriangle.pivot = new Vector2(500, 250); float triggerRight = window.JoystickTriggerRight(0); float triggerLeft = window.JoystickTriggerLeft(0); colouredTriangle.scale = new Vector2(1 + triggerLeft, 1 + triggerRight); colouredTriangle.Draw(); window.Update(); } }
private void GameUpdate(Window window) { if (window.IsTouching) { alien.position = window.TouchPosition; if ((sprite001.position-window.TouchPosition).Length < 100) { window.Vibrate(1000); } } else { window.CancelVibration(); } alien.DrawTexture(alienTexture); particleSystem001.Update(window); sprite001.position.X += 10f * window.deltaTime; sprite001.DrawSolidColor(1, 0, 0, 0.5f); lineDrawer.Point2 = window.TouchPosition; lineDrawer.DrawSolidColor(1f, 1f, 0f, 1f); window.Update(); }
static void Main(string[] args) { Window windowFake = new Window(800, 600, "Fake"); windowFake.SetDefaultOrthographicSize(7); windowFake.SetClearColor(1f, 0, 0); Mesh triangleFake = new Mesh(); triangleFake.v = new float[] { 2, 0, 1, 2, 3, 2 }; triangleFake.UpdateVertex(); Mesh wireframeTriangle = new Mesh(); wireframeTriangle.v = new float[] { 4, 0, 3, 1, 5, 1 }; wireframeTriangle.UpdateVertex(); Window window = new Window(1024, 576, "Units based example"); window.SetClearColor(0f, 1f, 0f); window.SetDefaultOrthographicSize(10); Mesh triangle = new Mesh(); triangle.v = new float[] { 2, 0, 1, 1, 3, 1 }; triangle.UpdateVertex(); triangle.pivot = new Vector2(2, 0.5f); Camera camera1 = new Camera(); Camera camera2 = new Camera(); Camera camera3 = new Camera(); Camera movingCamera = new Camera(); Sprite pointer = new Sprite(1, 1); while (window.opened && windowFake.opened) { window.SetCurrent(); window.SetViewport(0, 0, 1024/2, 576 / 2, 5); window.SetScissorTest(window.CurrentViewportPosition.X, window.CurrentViewportPosition.Y, window.CurrentViewportSize.X, window.CurrentViewportSize.Y); window.SetClearColor(0.5f, 0.5f, 0.5f); window.ClearColor(); window.SetCamera(movingCamera); triangle.scale = new Vector2(1f, 1f); triangle.position = window.mousePosition; triangle.DrawColor(0f, 1f, 0f, 1f); triangle.position = new Vector2(2, 2); triangle.DrawColor(1f, 0f, 0f, 1f); window.SetViewport(0, 576/2, 1024/2, 576 / 2, 5); window.SetScissorTest(window.CurrentViewportPosition.X, window.CurrentViewportPosition.Y, window.CurrentViewportSize.X, window.CurrentViewportSize.Y); window.SetClearColor(0.5f, 0.5f, 1f); window.ClearColor(); window.SetCamera(camera1); triangle.scale = new Vector2(1f, 1f); triangle.position = window.mousePosition; triangle.DrawColor(1f, 1f, 0f, 1f); window.SetViewport(1024/2, 0, 1024 / 2, 576 / 2, 5); window.SetScissorTest(window.CurrentViewportPosition.X, window.CurrentViewportPosition.Y, window.CurrentViewportSize.X, window.CurrentViewportSize.Y); window.SetClearColor(0.5f, 1f, 0.5f); window.ClearColor(); window.SetCamera(camera3); triangle.scale = new Vector2(1f, 1f); triangle.position = window.mousePosition; triangle.DrawColor(1f, 0f, 0f, 1f); triangle.position = new Vector2(2, 2); triangle.DrawColor(1f, 1f, 0f, 1f); window.SetViewport(1024/2, 576 / 2, 1024 / 2, 576 / 2, 5); window.SetScissorTest(window.CurrentViewportPosition.X, window.CurrentViewportPosition.Y, window.CurrentViewportSize.X, window.CurrentViewportSize.Y); window.SetClearColor(1f, 0.5f, 0.5f); window.ClearColor(); window.SetCamera(camera2); triangle.scale = new Vector2(1f, 1f); triangle.position = window.mousePosition; triangle.DrawColor(1f, 0f, 1f, 1f); if (window.GetKey(KeyCode.Esc)) break; if (window.GetKey(KeyCode.Right)) movingCamera.position.X += window.deltaTime; if (window.GetKey(KeyCode.Left)) movingCamera.position.X -= window.deltaTime; pointer.position = window.mousePosition; pointer.DrawSolidColor(1f, 0, 0, 1f); window.Update(); windowFake.SetCurrent(); triangleFake.position = windowFake.mousePosition; triangleFake.DrawColor(1f, 0f, 1f, 1f); wireframeTriangle.DrawWireframe(0f, 1f, 0f); windowFake.Update(); } }