From: Ben Beltran Date: Tue, 26 Jun 2018 22:03:58 +0000 (-0500) Subject: Update source to compile on VS Studio for mac X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/commitdiff_plain/9ad526c0233134a928cb5889dccb94458fc6dfd0 Update source to compile on VS Studio for mac --- diff --git a/SuperPolarity/ActorFactory.cs b/SuperPolarity/ActorFactory.cs index f9c7697..1a8c10e 100644 --- a/SuperPolarity/ActorFactory.cs +++ b/SuperPolarity/ActorFactory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -132,8 +132,8 @@ namespace SuperPolarity ship.MaxVelocity = 0.5f; ship.FleeVelocity = 5; ship.ChargeVelocity = 1; - ship.Value = 10; - ship.HP = 29; + ship.Value = 7; + ship.HP = 39; ship.SetPolarity(polarity); ActorManager.CheckIn(ship); diff --git a/SuperPolarity/ActorManager.cs b/SuperPolarity/ActorManager.cs index 56db26c..3a9b0db 100644 --- a/SuperPolarity/ActorManager.cs +++ b/SuperPolarity/ActorManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -47,6 +47,11 @@ namespace SuperPolarity foreach (Actor actor in Actors) { actor.Draw(spriteBatch); + + if (actor.GetType ().IsAssignableFrom (typeof(MainShip))) { + var mainActor = (MainShip)actor; + mainActor.ResetEnemyModification (); + } } } @@ -102,6 +107,16 @@ namespace SuperPolarity var angle = (float) Math.Atan2(dy, dx); var otherAngle = (float)Math.Atan2(-dy, -dx); + if (actor.GetType ().IsAssignableFrom (typeof(MainShip))) { + var mainActor = (MainShip)actor; + mainActor.UpdateEnemyModification (other); + } + + if (other.GetType ().IsAssignableFrom (typeof(MainShip))) { + var mainOther = (MainShip)other; + mainOther.UpdateEnemyModification (actor); + } + if (linearDistance < actor.MagneticRadius || linearDistance < other.MagneticRadius) { actor.Magnetize(other, (float)linearDistance, angle); diff --git a/SuperPolarity/Actors/Actor.cs b/SuperPolarity/Actors/Actor.cs index 2c6a895..b25de42 100644 --- a/SuperPolarity/Actors/Actor.cs +++ b/SuperPolarity/Actors/Actor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Actors/Bullet.cs b/SuperPolarity/Actors/Bullet.cs index 13d61c1..7801777 100644 --- a/SuperPolarity/Actors/Bullet.cs +++ b/SuperPolarity/Actors/Bullet.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Actors/GameActor.cs b/SuperPolarity/Actors/GameActor.cs index 8015ffa..3f426c0 100644 --- a/SuperPolarity/Actors/GameActor.cs +++ b/SuperPolarity/Actors/GameActor.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -55,7 +55,11 @@ namespace SuperPolarity { base.Draw(spriteBatch); - spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f); + try { + spriteBatch.Draw(Texture, Position, null, Color, Angle, Origin, 1f, SpriteEffects.None, 0f); + } catch (ArgumentNullException) { + Console.WriteLine ("Where'd the texture go?."); + } } public override void CleanUp() diff --git a/SuperPolarity/Actors/MainShip.cs b/SuperPolarity/Actors/MainShip.cs index 307bef4..7eef0b7 100644 --- a/SuperPolarity/Actors/MainShip.cs +++ b/SuperPolarity/Actors/MainShip.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -16,8 +16,6 @@ namespace SuperPolarity public static Color BlueColor; public static Color RedColor; - ParticleEngine particleEngine; - protected bool Shooting; protected int ShotCooldown; @@ -29,25 +27,52 @@ namespace SuperPolarity protected SoundEffect ShootSound; protected SoundEffect Hit; + // Aura stuff + protected Texture2D AuraPoint; + protected double AuraRadius; + protected double AuraAmplitude; + protected double AuraFrequency; + protected double AuraSubAmplitude; + protected double AuraWaveSize; + protected double AuraSubPhase; + protected double AuraSubFrequency; + public double[] EnemyModifications; + public double MaxEnemyModification; + public double EnemyModificationSpread; + public MainShip(SuperPolarity newGame) : base(newGame) {} ~MainShip() { - particleEngine = null; } public override void Initialize(Texture2D texture, Vector2 position) { base.Initialize(texture, position); - MainShip.BlueColor = new Color(211, 230, 234); + MainShip.BlueColor = new Color(71, 182, 226); MainShip.RedColor = new Color(235, 160, 185); + AuraPoint = CreateCircle (2); + + AuraRadius = 75; + AuraAmplitude = 7; + AuraFrequency = 3; + AuraSubAmplitude = 7; + AuraWaveSize = 3; + AuraSubPhase = 0; + AuraSubFrequency = 9 * Math.PI / 180; + MaxEnemyModification = 20; + EnemyModificationSpread = 10; + EnemyModifications = new double[360]; + for ( int i = 0; i < EnemyModifications.Length; i++ ) { + EnemyModifications[i] = 0; + } + PolarityChange = game.Content.Load("Sound\\polaritychange"); ShootSound = game.Content.Load("Sound\\bullet"); Hit = game.Content.Load("Sound\\hit"); - InitParticleEngine(); SetPolarity(Polarity.Positive); ActVelocity = 2.5f; @@ -64,11 +89,6 @@ namespace SuperPolarity BindInput(); } - void InitParticleEngine() - { - particleEngine = ParticleEffectFactory.CreatePolarCircle(Position); - } - void BindInput() { InputController.Bind("moveX", HandleHorizontalMovement); @@ -131,42 +151,28 @@ namespace SuperPolarity public override void SwitchPolarity() { base.SwitchPolarity(); - SwitchParticleEngine(CurrentPolarity); PolarityChange.Play(); game.Player.ResetMultiplier(); } public override void SetPolarity(Polarity newPolarity) { - base.SetPolarity(newPolarity); - SwitchParticleEngine(newPolarity); - } - - protected void SwitchParticleEngine(Polarity polarity) - { - if (polarity == Polarity.Positive) - { - particleEngine.Color = MainShip.RedColor; - } - else if (polarity == Polarity.Negative) - { - particleEngine.Color = MainShip.BlueColor; - } - else - { - particleEngine.Color = Color.Gray; - } + base.SetPolarity(newPolarity);; } - + public override void Update(GameTime gameTime) { base.Update(gameTime); - particleEngine.EmitterLocation = Position; - particleEngine.Update(); ConstrainToEdges(); UpdateImmortality(gameTime); } + public void ResetEnemyModification() { + for ( int i = 0; i < EnemyModifications.Length; i++ ) { + EnemyModifications[i] = 0; + } + } + public void UpdateImmortality(GameTime gameTime) { if (Immortal) @@ -270,12 +276,131 @@ namespace SuperPolarity } } - public override void Draw(SpriteBatch spriteBatch) + public void UpdateEnemyModification(Ship enemy) { + + var dx = enemy.Position.X - Position.X; + var dy = enemy.Position.Y - Position.Y; + var angleInDegrees = ((360 + Math.Round (Math.Atan2 (dy, dx) * 180 / Math.PI)) % 360); + + for (var i = -EnemyModificationSpread; i < EnemyModificationSpread; i++) { + var strength = MaxEnemyModification - Math.Abs (i * MaxEnemyModification / EnemyModificationSpread); + + var index = (int)((360 + angleInDegrees + i) % 360); + + if (enemy.CurrentPolarity == CurrentPolarity) { + EnemyModifications[index] -= strength; + } else { + EnemyModifications[index] += strength; + } + + if (EnemyModifications[index] > MaxEnemyModification) { + EnemyModifications[index] = MaxEnemyModification; + } + + if (EnemyModifications[index] < -MaxEnemyModification) { + EnemyModifications[index] = -MaxEnemyModification; + } + } + } + + public override void Draw(SpriteBatch spriteBatch) { - particleEngine.Draw(spriteBatch); + DrawCircle (spriteBatch); base.Draw(spriteBatch); - spriteBatch.Draw(BoxTexture, Box, new Color(255, 0, 255, 25)); + //spriteBatch.Draw(BoxTexture, Box, new Color(255, 0, 255, 25)); + } + + protected void DrawCircle(SpriteBatch spriteBatch) { + + var j = AuraWaveSize; + var subWaveRadius = 0.0; + var randomPosition = 0.0; + + for (var i = 0; i < 360; i++) { + var angle = i * Math.PI / 180; + + if (j == AuraWaveSize) { + subWaveRadius = AuraSubAmplitude * Math.Sin (randomPosition + AuraSubPhase); + randomPosition -= (2 * Math.PI / 8); + j = 0; + } + j++; + + var radius = EnemyModifications[i] + subWaveRadius + AuraRadius + AuraAmplitude * Math.Sin (i / AuraFrequency); + var x = Position.X + radius * Math.Cos (angle); + var y = Position.Y + radius * Math.Sin (angle); + + x = Math.Round (x); + y = Math.Round (y); + var pointPosition = new Vector2 ((float)x, (float)y); + + if (CurrentPolarity == Polarity.Positive) { + spriteBatch.Draw (AuraPoint, pointPosition, RedColor); + } else { + spriteBatch.Draw (AuraPoint, pointPosition, BlueColor); + } + } + + AuraSubPhase += AuraSubFrequency; + + /* var r = 50; + var wave = 5; + var frequency = 1.4; + var randomFactor = 5; + var randomAreaSize = 4; + + var j = AuraWaveSize; + var rand = 0; + var randomPosition = 0; + + AuraSubPhase = 0; + + for (var i = 0; i < 360; i++) { + var rad = Math.radians(i); + if (j == AuraWaveSize) { + //rand = Math.random() * 2 * AuraSubAmplitude - AuraSubAmplitude; + rand = AuraSubAmplitude * Math.sin(AuraSubPhase + offset); + AuraSubPhase -= (2 * Math.PI / 8); + j = 0; } + j++; + var radius = polarityModifications[i] + rand + AuraRadius + AuraAmplitude * Math.sin(i / AuraFrequency); + var x = Position.x + radius * Math.cos(rad); + var y = Position.y + radius * Math.sin(rad); + x = Math.round(x); + y = Math.round(y); + + draw + //console.log(i, rad, x, y, dataStart); + }); + + ctx.putImageData(imgData, 0, 0);*/ + } + + protected Texture2D CreateCircle(int radius) + { + int outerRadius = radius * 2 + 2; + Texture2D texture = new Texture2D (game.GraphicsDevice, outerRadius, outerRadius); + + Color[] data = new Color[outerRadius * outerRadius]; + + for (int i = 0; i < data.Length; i++) { + data [i] = Color.Transparent; + } + + double angleStep = 1f / radius; + + for (double angle = 0; angle < Math.PI * 2; angle += angleStep) + { + int x = (int)Math.Round (radius + radius * Math.Cos (angle)); + int y = (int)Math.Round (radius + radius + Math.Sin (angle)); + + data [y * outerRadius + x + 1] = Color.White; + } + + texture.SetData (data); + return texture; + } public override void Collide(Actor other, Rectangle collision) { @@ -305,7 +430,6 @@ namespace SuperPolarity public override void CleanUp() { base.CleanUp(); - particleEngine = null; InputController.Unbind("moveX", HandleHorizontalMovement); InputController.Unbind("moveY", HandleVerticalMovement); InputController.Unbind("changePolarity", HandleChangePolarity); diff --git a/SuperPolarity/Actors/Ship.cs b/SuperPolarity/Actors/Ship.cs index 5a3f6e5..590b446 100644 --- a/SuperPolarity/Actors/Ship.cs +++ b/SuperPolarity/Actors/Ship.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Actors/StandardShip.cs b/SuperPolarity/Actors/StandardShip.cs index ef2fe7f..ff04ea0 100644 --- a/SuperPolarity/Actors/StandardShip.cs +++ b/SuperPolarity/Actors/StandardShip.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -31,9 +31,9 @@ namespace SuperPolarity new RNGCryptoServiceProvider().GetBytes(cryptoResult); ChangeRate = 50; - AngleChangeProbability = 50; + AngleChangeProbability = 50; BouncePadding = 0; - MaxVelocity = 2; + MaxVelocity = 3; CurrentTime = 0; RotationFactor = (float) (3 * Math.PI / 180); Random = new Random(BitConverter.ToInt32(cryptoResult, 0)); diff --git a/SuperPolarity/BasicGenerator.cs b/SuperPolarity/BasicGenerator.cs index ba51742..fa4edeb 100644 --- a/SuperPolarity/BasicGenerator.cs +++ b/SuperPolarity/BasicGenerator.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/GameScreen.cs b/SuperPolarity/GameScreen.cs index 783e3c1..3fe9c92 100644 --- a/SuperPolarity/GameScreen.cs +++ b/SuperPolarity/GameScreen.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -10,6 +10,9 @@ using Microsoft.Xna.Framework.Input; namespace SuperPolarity { + + using MediaPlayer = Microsoft.Xna.Framework.Media.MediaPlayer; + class GameScreen : Screen { public GameScreen(SuperPolarity newGame) : base(newGame) {} @@ -33,15 +36,15 @@ namespace SuperPolarity Generators = new List(); CurrentBombRate = 1; - BombRate = 6000; + BombRate = 10000; - LivesRate = 10000; + LivesRate = 19000; CurrentLivesRate = 1; - InputController.RegisterEventForButton("changePolarity", Buttons.A); + InputController.RegisterEventForButton("changePolarity", Buttons.B); InputController.RegisterEventForKey("changePolarity", Keys.Z); - InputController.RegisterEventForButton("shoot", Buttons.X); + InputController.RegisterEventForButton("shoot", Buttons.A); InputController.RegisterEventForKey("shoot", Keys.X); InputController.Bind("pause", HandlePause); diff --git a/SuperPolarity/InputController.cs b/SuperPolarity/InputController.cs index c92bb9c..2047ef0 100644 --- a/SuperPolarity/InputController.cs +++ b/SuperPolarity/InputController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -55,7 +55,7 @@ namespace SuperPolarity { // OK THIS IS ALL KINDS OF WRONG. THIS IS A PLACEHOLDER BECAUSE DEMO! var keyPressed = false; - if ((InputKeyboardState.IsKeyDown(Keys.Enter) || InputGamePadState.IsButtonDown(Buttons.Start))) { + if ((InputKeyboardState.IsKeyDown(Keys.Enter) || InputGamePadState.IsButtonDown(Buttons.RightStick))) { keyPressed = true; if(!BlockedButtons.Contains("pause") && !BlockedKeys.Contains("pause")) { diff --git a/SuperPolarity/LetterChooseWidget.cs b/SuperPolarity/LetterChooseWidget.cs index e52733f..44ca844 100644 --- a/SuperPolarity/LetterChooseWidget.cs +++ b/SuperPolarity/LetterChooseWidget.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/MenuItem.cs b/SuperPolarity/MenuItem.cs index 8e24c97..f7ac5bd 100644 --- a/SuperPolarity/MenuItem.cs +++ b/SuperPolarity/MenuItem.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/MenuWidget.cs b/SuperPolarity/MenuWidget.cs index 992ef43..96cabe7 100644 --- a/SuperPolarity/MenuWidget.cs +++ b/SuperPolarity/MenuWidget.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/NameChooserWidget.cs b/SuperPolarity/NameChooserWidget.cs index ce7c149..4c7797d 100644 --- a/SuperPolarity/NameChooserWidget.cs +++ b/SuperPolarity/NameChooserWidget.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Particle.cs b/SuperPolarity/Particle.cs index d65bac6..80abb09 100644 --- a/SuperPolarity/Particle.cs +++ b/SuperPolarity/Particle.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/ParticleEffectFactory.cs b/SuperPolarity/ParticleEffectFactory.cs index 0cd9ed3..5efd8d5 100644 --- a/SuperPolarity/ParticleEffectFactory.cs +++ b/SuperPolarity/ParticleEffectFactory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/ParticleEngine.cs b/SuperPolarity/ParticleEngine.cs index 51188ae..8cc17c1 100644 --- a/SuperPolarity/ParticleEngine.cs +++ b/SuperPolarity/ParticleEngine.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Player.cs b/SuperPolarity/Player.cs index 184abdd..ec3842f 100644 --- a/SuperPolarity/Player.cs +++ b/SuperPolarity/Player.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Properties/AssemblyInfo.cs b/SuperPolarity/Properties/AssemblyInfo.cs index daa34e8..1902c12 100644 --- a/SuperPolarity/Properties/AssemblyInfo.cs +++ b/SuperPolarity/Properties/AssemblyInfo.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; diff --git a/SuperPolarity/Renderer.cs b/SuperPolarity/Renderer.cs index 7ca8158..6dfa642 100644 --- a/SuperPolarity/Renderer.cs +++ b/SuperPolarity/Renderer.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/ScoreScreen.cs b/SuperPolarity/ScoreScreen.cs index d879db9..63418d8 100644 --- a/SuperPolarity/ScoreScreen.cs +++ b/SuperPolarity/ScoreScreen.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Screen.cs b/SuperPolarity/Screen.cs index 006b047..df5c0c4 100644 --- a/SuperPolarity/Screen.cs +++ b/SuperPolarity/Screen.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/ScreenManager.cs b/SuperPolarity/ScreenManager.cs index b88741b..e869035 100644 --- a/SuperPolarity/ScreenManager.cs +++ b/SuperPolarity/ScreenManager.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/SuperPolarity.cs b/SuperPolarity/SuperPolarity.cs index 7fa387c..f644fa6 100644 --- a/SuperPolarity/SuperPolarity.cs +++ b/SuperPolarity/SuperPolarity.cs @@ -1,20 +1,18 @@ -#region Using Statements -using System; -using System.Collections.Generic; +#region Using Statements using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Storage; using Microsoft.Xna.Framework.GamerServices; -using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Audio; using SuperPolarity; -using Tao.Sdl; #endregion namespace SuperPolarity { + + using MediaPlayer = Microsoft.Xna.Framework.Media.MediaPlayer; + /// /// This is the main type for your game /// @@ -42,7 +40,7 @@ namespace SuperPolarity graphics.PreferMultiSampling = true; graphics.PreferredBackBufferHeight = 720; graphics.PreferredBackBufferWidth = 1280; - //graphics.ToggleFullScreen(); + //graphics.ToggleFullScreen(); Content.RootDirectory = "Content"; ActorFactory.SetGame(this); diff --git a/SuperPolarity/TitleScreen.cs b/SuperPolarity/TitleScreen.cs index a953f27..f97c19a 100644 --- a/SuperPolarity/TitleScreen.cs +++ b/SuperPolarity/TitleScreen.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/SuperPolarity/Vendor/osx/Tao.Sdl.dll.config b/SuperPolarity/Vendor/osx/Tao.Sdl.dll.config deleted file mode 100644 index ec83f1e..0000000 --- a/SuperPolarity/Vendor/osx/Tao.Sdl.dll.config +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SuperPolarity/Widget.cs b/SuperPolarity/Widget.cs index ea92cfd..3db42d9 100644 --- a/SuperPolarity/Widget.cs +++ b/SuperPolarity/Widget.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text;