Changeset 4030


Ignore:
Timestamp:
2013-06-07 13:36:35 (6 years ago)
Author:
jonkurki
Message:
 
Location:
2013/23/JoniK/pp/pp
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2013/23/JoniK/pp/pp/pp/Pong2.cs

    r3985 r4030  
    3838    player2Points = create_calculator(Screen.Right - 100.0, Screen.Top - 100.0); 
    3939    } 
    40  
    4140    IntMeter create_calculator(double x, double y) 
    4241    { 
  • 2013/23/JoniK/pp/pp/pp/pp.cs

    r3985 r4030  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
    8 class enemy : PhysicsObject 
     8class Enemy : PhysicsObject 
    99{ 
    1010    private IntMeter health = new IntMeter(3, 0, 3); 
    1111    public IntMeter Health { get { return health; } } 
    12     public enemy(double leveys, double korkeus) 
     12    public Enemy(double leveys, double korkeus) 
    1313        : base(leveys, korkeus) 
    1414    { 
    1515        Velocity = Vector.Zero; 
     16    } 
     17} 
     18class Turret : PhysicsObject 
     19{ 
     20    private IntMeter health = new IntMeter(20, 0, 20); 
     21    public IntMeter Health { get { return health; } } 
     22    public Turret(double width, double height) 
     23        : base(width, height) 
     24    { 
     25        Velocity = Vector.Zero; 
     26    } 
     27} 
     28class Player : PhysicsObject 
     29{ 
     30    private IntMeter health; 
     31    public IntMeter Health { get { return this.health; } set { this.health = value; } } 
     32    public Player(double width, double height) 
     33        : base(width, height) 
     34    { 
     35        Velocity = Vector.Zero; 
     36        this.health= new IntMeter(20, 0, 20); 
    1637    } 
    1738} 
    1839public class pp : PhysicsGame 
    1940{ 
    20      
     41    //PathFollowerBrain octopusbrain; 
     42    private Image[] turrethitanim = LoadImages("turret", "turret1", "turret2"); 
    2143    int verti = 300; 
    2244    int hori = 300; 
    23     PhysicsObject ball; 
    24     PhysicsObject octopus; 
     45    Player player; 
     46    Enemy octopus; 
     47    Turret turret; 
     48    Turret turret1; 
     49    Turret turret2; 
    2550    PhysicsObject rightborder; 
    2651    PhysicsObject leftborder; 
     
    2954    PhysicsObject followball1; 
    3055    PhysicsObject followball2; 
     56    PhysicsObject ship; 
    3157    Image greenball = LoadImage("ball main"); 
    3258    Image bulletpic = LoadImage("bullet"); 
    3359    Image octopi = LoadImage("octomonster"); 
    34     Vector up = new Vector(0, 300); 
    35     Vector down = new Vector(0, -300); 
    36     Vector right = new Vector(300, 0); 
    37     Vector left = new Vector(-300, 0); 
     60    Image turretpic = LoadImage("turret"); 
     61    Image shippic = LoadImage("up giant ship"); 
     62    Vector up = new Vector(0, 100); 
     63    Vector down = new Vector(0, -100); 
     64    Vector right = new Vector(100, 0); 
     65    Vector left = new Vector(-100, 0); 
    3866    IntMeter bulletdelay = new IntMeter(0); 
    39     //Vector velocity = new Vector (300,300); 
     67    IntMeter turretdelay = new IntMeter(0); 
     68    IntMeter turretspread = new IntMeter(60, -60, 60); 
     69    IntMeter Shipmovement = new IntMeter(100, 0, 100); 
     70    IntMeter delay = new IntMeter(10, 0, 10); 
     71    IntMeter shieldpower = new IntMeter(1000, 0, 1000); 
     72    PhysicsObject shield; 
     73    Image shieldpic = LoadImage("shield"); 
    4074     
    41      
     75 
    4276    public override void Begin() 
    4377    { 
     78        shield = new PhysicsObject (40, 40); 
     79        shield.Image = shieldpic; 
     80        shield.X = 2000; 
     81        shield.Y = 1000; 
     82        shield.Mass = 10; 
     83        shield.AngularVelocity = -100; 
     84        shield.CollisionIgnoreGroup = 1; 
     85        Add(shield); 
     86        AddCollisionHandler(shield, "turret shot", shield_hit); 
     87        ship = new PhysicsObject(1400, 200); 
     88        ship.Image = shippic; 
     89        ship.Top = 500; 
     90        ship.X = -50; 
     91        ship.IgnoresCollisionResponse = true; 
     92        Add(ship, -1); 
     93        player = new Player(25, 25); 
     94        player.Image = greenball; 
     95        player.X = 0; 
     96        player.Y = 0; 
     97        player.CanRotate = false; 
     98        player.CollisionIgnoreGroup = 1; 
     99        Label screen = new Label(); 
     100        screen.BindTo(shieldpower); 
     101        screen.X = -500; 
     102        screen.Y = 100; 
     103        screen.TextColor = Color.Black; 
     104        screen.BorderColor = Level.BackgroundColor; 
     105        screen.Color = Level.BackgroundColor; 
     106        Label health = new Label(); 
     107        health.BindTo(player.Health); 
     108        health.X = -400; 
     109        health.Y = 0; 
     110        health.TextColor = Color.Black; 
     111        health.BorderColor = Level.BackgroundColor; 
     112        health.Color = Level.BackgroundColor; 
     113        Add(health); 
    44114        Mouse.IsCursorVisible = true; 
    45         octopus = new enemy(95, 96); 
     115        octopus = new Enemy(95, 96); 
    46116        octopus.Image = octopi; 
    47         octopus.X = 200; 
     117        octopus.X = 10000; 
    48118        octopus.Y = 200; 
    49119        octopus.Mass = 100; 
    50120        octopus.CanRotate = false; 
    51          
     121        octopus.CollisionIgnoreGroup = 2; 
     122 
     123        turret = new Turret(71.5, 58); 
     124        turret.Image = turretpic; 
     125        turret.X = ship.X - 450; 
     126        turret.Y = ship.Y; 
     127        turret.Mass = 10000000; 
     128        turret.CanRotate = true; 
     129        turret.CollisionIgnoreGroup = 2; 
     130        turret.Animation = new Animation(turrethitanim); 
     131        turret.Animation.FPS = 10; 
     132        Add(turret, 2); 
     133 
     134        turret1 = new Turret(71.5, 58); 
     135        turret1.Image = turretpic; 
     136        turret1.X = ship.X - 10; 
     137        turret1.Y = 400; 
     138        turret1.Mass = 10000000; 
     139        turret1.CanRotate = true; 
     140        turret1.CollisionIgnoreGroup = 2; 
     141        turret1.Animation = new Animation(turrethitanim); 
     142        turret1.Animation.FPS = 10; 
     143        Add(turret1, 2); 
     144 
     145        turret2 = new Turret(71.5, 58); 
     146        turret2.Image = turretpic; 
     147        turret2.X = ship.X + 300; 
     148        turret2.Y = 400; 
     149        turret2.Mass = 10000000; 
     150        turret2.CanRotate = true; 
     151        turret2.CollisionIgnoreGroup = 2; 
     152        turret2.Animation = new Animation(turrethitanim); 
     153        turret2.Animation.FPS = 10; 
     154        Add(turret2, 2); 
     155 
    52156        Add(octopus); 
    53         ball = new PhysicsObject(50,50); 
    54         ball.Image = greenball; 
    55         ball.X = 200; 
    56         ball.Y = 200; 
    57         ball.CanRotate = false; 
    58         ball.CollisionIgnoreGroup = 1; 
    59         followball1 = new PhysicsObject(50, 50); 
     157        
     158 
     159        followball1 = new PhysicsObject(25, 25); 
    60160        followball1.Shape = Shape.Circle; 
    61161        followball1.Color = Color.Blue; 
     
    63163        followball1.Y = 0; 
    64164        followball1.CollisionIgnoreGroup = 1; 
    65          
    66         followball2 = new PhysicsObject(50, 50); 
     165 
     166        followball2 = new PhysicsObject(25, 25); 
    67167        followball2.Shape = Shape.Circle; 
    68168        followball2.Color = Color.Yellow; 
     
    72172        Add(followball2); 
    73173        Add(followball1); 
    74         Add(ball); 
     174        Add(player); 
    75175        creategeneralstuff(); 
    76         Keyboard.Listen(Key.W, ButtonState.Down, set_velocity, "move player 1 up", ball, up); 
    77         Keyboard.Listen(Key.W, ButtonState.Released, set_velocity, null, ball, Vector.Zero); 
    78         Keyboard.Listen(Key.S, ButtonState.Down, set_velocity, "move player 1 down", ball, down); 
    79         Keyboard.Listen(Key.S, ButtonState.Released, set_velocity, null, ball, Vector.Zero); 
    80         Keyboard.Listen(Key.A, ButtonState.Down, set_velocity_x, "move player 1 left", ball, left); 
    81         Keyboard.Listen(Key.A, ButtonState.Released, set_velocity_x, null, ball, Vector.Zero); 
    82         Keyboard.Listen(Key.D, ButtonState.Down, set_velocity_x, "move player 1 right", ball, right); 
    83         Keyboard.Listen(Key.D, ButtonState.Released, set_velocity_x, null, ball, Vector.Zero); 
     176        Keyboard.Listen(Key.W, ButtonState.Down, set_velocity, "move player 1 up", player, up); 
     177        Keyboard.Listen(Key.W, ButtonState.Released, set_velocity, null, player, Vector.Zero); 
     178        Keyboard.Listen(Key.S, ButtonState.Down, set_velocity, "move player 1 down", player, down); 
     179        Keyboard.Listen(Key.S, ButtonState.Released, set_velocity, null, player, Vector.Zero); 
     180        Keyboard.Listen(Key.A, ButtonState.Down, set_velocity_x, "move player 1 left", player, left); 
     181        Keyboard.Listen(Key.A, ButtonState.Released, set_velocity_x, null, player, Vector.Zero); 
     182        Keyboard.Listen(Key.D, ButtonState.Down, set_velocity_x, "move player 1 right", player, right); 
     183        Keyboard.Listen(Key.D, ButtonState.Released, set_velocity_x, null, player, Vector.Zero); 
    84184        Keyboard.Listen(Key.Space, ButtonState.Down, create_bullet, null); 
    85185        Keyboard.Listen(Key.G, ButtonState.Pressed, test_function, null); 
     186        Mouse.Listen(MouseButton.Left, ButtonState.Down, shield_on, null); 
     187        Mouse.Listen(MouseButton.Left, ButtonState.Up, shield_off, null); 
    86188        // TODO: Kirjoita ohjelmakoodisi tähän 
    87189 
    88190        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    89191        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     192    } 
     193    void shield_hit(PhysicsObject shield, PhysicsObject turret_shot) 
     194    { 
     195        turret_shot.Destroy(); 
     196        shieldpower.Value -= 10; 
     197    } 
     198    void shield_on() 
     199    { 
     200        shield.X = player.X; 
     201        shield.Y = player.Y; 
     202    } 
     203    void shield_off() 
     204    { 
     205        shield.X = 2000; 
     206        shield.Y = 1000; 
     207        shieldpower.Value += 1; 
    90208    } 
    91209    void creategeneralstuff() 
     
    126244        Add(rightborder); 
    127245        AddCollisionHandler(rightborder, "bullet", bullet_Destroy); 
     246        AddCollisionHandler(bottomborder, "bullet", bullet_Destroy); 
     247        AddCollisionHandler(topborder, "bullet", bullet_Destroy); 
     248        AddCollisionHandler(leftborder, "bullet", bullet_Destroy); 
     249 
     250        AddCollisionHandler(rightborder, "turret shot", bullet_Destroy); 
     251        AddCollisionHandler(bottomborder, "turret shot", bullet_Destroy); 
     252        AddCollisionHandler(topborder, "turret shot", bullet_Destroy); 
     253        AddCollisionHandler(leftborder, "turret shot", bullet_Destroy); 
     254 
    128255        AddCollisionHandler(octopus, "bullet", octopus_hit); 
     256        AddCollisionHandler(turret, "bullet", turret_hit); 
     257        AddCollisionHandler(turret1, "bullet", turret_hit); 
     258        AddCollisionHandler(turret2, "bullet", turret_hit); 
     259        AddCollisionHandler(player, "turret shot", player_hit); 
     260 
    129261        Level.BackgroundColor = Color.Azure; 
    130262 
    131263    } 
     264    void player_hit(PhysicsObject player, PhysicsObject hit) 
     265    { 
     266        if (!(player is Player)) 
     267            return; 
     268        Player playerr = (Player)player; 
     269        playerr.Health.Value -= 1; 
     270 
     271        hit.Destroy(); 
     272    } 
    132273    void octopus_hit(PhysicsObject octopus, PhysicsObject hit) 
    133274    { 
    134         if (!(octopus is enemy)) 
    135             return; 
    136         enemy octo = (enemy)octopus; 
     275        if (!(octopus is Enemy)) 
     276            return; 
     277        Enemy octo = (Enemy)octopus; 
    137278        octo.Health.Value -= 1; 
    138279        if (octo.Health.Value == 0) 
     
    140281        hit.Destroy(); 
    141282    } 
    142     void set_velocity_x(PhysicsObject ball, Vector speed) 
    143     { 
    144         ball.Velocity = new Vector(speed.X, ball.Velocity.Y); 
    145     } 
    146     void set_velocity(PhysicsObject ball, Vector speed) 
    147     { 
    148  
     283    void turret_hit(PhysicsObject turret, PhysicsObject hit) 
     284    { 
     285        if (!(turret is Turret)) 
     286            return; 
     287 
     288        Turret turrett = (Turret)turret; 
     289        turrett.Animation.Start(1); 
     290        turrett.Health.Value -= 1; 
     291        if (turrett.Health.Value < 1) 
     292            turrett.Destroy(); 
     293        hit.Destroy(); 
     294 
     295    } 
     296    void set_velocity_x(PhysicsObject player, Vector speed) 
     297    { 
     298        player.Velocity = new Vector(speed.X, player.Velocity.Y); 
     299    } 
     300    void set_velocity(PhysicsObject player, Vector speed) 
     301    { 
    149302        //if(!onkoMenossaRajanYli) 
    150              
    151         ball.Velocity = new Vector(ball.Velocity.X, speed.Y); 
    152          
    153  
    154         if ((ball.Top > topborder.Top) && (speed.Y > 0)) 
    155         { 
    156             ball.Velocity = Vector.Zero; 
    157             return; 
    158         } 
    159         if ((ball.Bottom < bottomborder.Bottom) && (speed.Y < 0)) 
    160         { 
    161             ball.Velocity = Vector.Zero; 
    162             return; 
    163         } 
    164         if ((ball.Left < leftborder.Left) && (speed.X < 0)) 
    165         { 
    166             ball.Velocity = Vector.Zero; 
    167             return; 
    168         } 
    169         if ((ball.Right > rightborder.Right) && (speed.X > 0)) 
    170         { 
    171             ball.Velocity = Vector.Zero; 
     303 
     304        player.Velocity = new Vector(player.Velocity.X, speed.Y); 
     305 
     306 
     307        if ((player.Top > topborder.Top) && (speed.Y > 0)) 
     308        { 
     309            player.Velocity = Vector.Zero; 
     310            return; 
     311        } 
     312        if ((player.Bottom < bottomborder.Bottom) && (speed.Y < 0)) 
     313        { 
     314            player.Velocity = Vector.Zero; 
     315            return; 
     316        } 
     317        if ((player.Left < leftborder.Left) && (speed.X < 0)) 
     318        { 
     319            player.Velocity = Vector.Zero; 
     320            return; 
     321        } 
     322        if ((player.Right > rightborder.Right) && (speed.X > 0)) 
     323        { 
     324            player.Velocity = Vector.Zero; 
    172325            return; 
    173326        } 
     
    177330    void bullet_Destroy(PhysicsObject rightborder, PhysicsObject impact) 
    178331    { 
    179             impact.Destroy(); 
    180  
     332        impact.Destroy(); 
    181333    } 
    182334    void create_bullet() 
    183335    { 
    184         Vector suunta = new Vector(Mouse.PositionOnScreen.X - ball.X, Mouse.PositionOnScreen.Y - ball.Y); 
    185  
     336        Vector suunta = new Vector(Mouse.PositionOnScreen.X - player.X, Mouse.PositionOnScreen.Y - player.Y); 
    186337        PhysicsObject bullet = new PhysicsObject(20, 20); 
    187         bullet.X = ball.X; 
    188         bullet.Y = ball.Y; 
     338        bullet.X = player.X; 
     339        bullet.Y = player.Y; 
    189340        bullet.Tag = "bullet"; 
    190341        bullet.Shape = Shape.Circle; 
     
    193344        //bullet.Velocity = new Vector(Mouse.PositionOnScreen.X - bullet.X, Mouse.PositionOnScreen.Y - bullet.Y); 
    194345        bullet.Velocity = Vector.FromLengthAndAngle(1000, suunta.Angle); 
    195         bullet.CollisionIgnoreGroup = 1; 
    196          
    197          
     346        bullet.CollisionIgnoreGroup = 1 & 3; 
     347 
    198348        if (bulletdelay == 10) 
    199349        { 
     
    204354    void test_function() 
    205355    { 
    206         octopus = new enemy(95, 96); 
     356        octopus = new Enemy(95, 96); 
    207357        octopus.Image = octopi; 
    208358        octopus.Mass = 100; 
     359        List<Vector> polku; 
     360        polku = new List<Vector>(); 
     361        polku.Add(new Vector(-50, -100)); 
     362        polku.Add(new Vector(-100, 50)); 
     363        polku.Add(new Vector(-250, -200)); 
     364 
     365        PathFollowerBrain octopusbrain = new PathFollowerBrain(100); 
     366        octopusbrain.Path = polku; 
     367        octopusbrain.Speed = 100; 
     368        octopusbrain.Loop = true; 
     369        octopusbrain.Active = true; 
     370        octopusbrain.ReverseReturn = true; 
    209371        octopus.X = hori; 
    210372        octopus.Y = verti; 
    211373        octopus.CanRotate = false; 
     374        octopus.CollisionIgnoreGroup = 2; 
     375        octopus.Brain = octopusbrain; 
    212376        AddCollisionHandler(octopus, "bullet", octopus_hit); 
    213  
    214377        Add(octopus); 
    215378    } 
    216379    protected override void Update(Time time) 
    217380    { 
     381        if (delay.Value == 0) 
     382            delay.Value = 10; 
     383        if (delay.Value > 0) 
     384            delay.Value -= 1; 
     385        turret_shoot(); 
     386        if (turretdelay.Value < 50) 
     387            turretdelay.Value += 1; 
    218388        if (bulletdelay < 10) 
    219389            bulletdelay.Value += 1; 
    220  
     390        if (Shipmovement.Value > 0 && delay.Value > 5) 
     391            Shipmovement.Value -= 1; 
     392        if (Shipmovement.Value == 0 && delay.Value > 5) 
     393            Shipmovement.Value = 100; 
     394        if (Shipmovement.Value > 0 && Shipmovement.Value < 50 && delay.Value > 5) 
     395            ship.X -= 1; 
     396        turret.X = ship.X - 450; 
     397        turret1.X = ship.X - 10; 
     398        turret2.X = ship.X + 300; 
     399        if (Shipmovement.Value > 50 && Shipmovement.Value < 100 && delay.Value > 5) 
     400            ship.X += 1; 
     401        turret.X = ship.X - 450; 
     402        turret1.X = ship.X - 25; 
     403        turret2.X = ship.X + 300; 
     404        shield.AngularVelocity = -100; 
     405        Vector turretangle = new Vector(turret.X - player.X, turret.Y - player.Y); 
     406        turret.Angle = turretangle.Angle + Angle.FromDegrees(-90); 
     407        Vector turret1angle = new Vector(turret1.X - player.X, turret1.Y - player.Y); 
     408        turret1.Angle = turret1angle.Angle + Angle.FromDegrees(-90); 
     409        Vector turret2angle = new Vector(turret2.X - player.X, turret2.Y - player.Y); 
     410        turret2.Angle = turret2angle.Angle + Angle.FromDegrees(-90); 
    221411        base.Update(time); 
    222         followball1.Velocity = new Vector((ball.X - followball1.X) * 10, (ball.Y - followball1.Y) * 10); 
    223         followball2.Velocity = new Vector((followball1.X- followball2.X) * 10, (followball1.Y - followball2.Y) * 10); 
    224          
     412        followball1.Velocity = new Vector((player.X - followball1.X) * 20, (player.Y - followball1.Y) * 20); 
     413        followball2.Velocity = new Vector((followball1.X - followball2.X) * 40, (followball1.Y - followball2.Y) * 40); 
     414 
     415        octopus_shoot(octopus); 
     416 
     417        if (turretspread.Value > -60) 
     418        { 
     419            turretspread.Value -= 5; 
     420        } 
     421        if (turretspread.Value == -60) 
     422        { 
     423            turretspread.Value = 60; 
     424        } 
     425 
     426    } 
     427    void octopus_shoot(PhysicsObject octopus) 
     428    { 
     429        Vector octoaim = new Vector(octopus.X - player.X ,octopus.X -player.X); 
     430 
     431        PhysicsObject turret_shot = new PhysicsObject(20, 20); 
     432        turret_shot.X = octopus.X; 
     433        turret_shot.Y = octopus.Y; 
     434        turret_shot.Tag = "turret shot"; 
     435        turret_shot.Shape = Shape.Circle; 
     436        turret_shot.Color = Color.Green; 
     437        turret_shot.Restitution = 1; 
     438        turret_shot.Mass = 1; 
     439        turret_shot.LifetimeLeft = TimeSpan.FromMilliseconds(10000); 
     440        turret_shot.Velocity = Vector.FromLengthAndAngle(100, octoaim.Angle); 
     441        turret_shot.CollisionIgnoreGroup = 2 & 3; 
     442 
     443 
     444    } 
     445 
     446    void turret_shoot() 
     447    { 
     448        Vector turret_aim = new Vector(0, -10); 
     449        Vector turret1_aim = new Vector(0, -10); 
     450        Vector turret2_aim = new Vector(0, -10); 
     451 
     452 
     453        PhysicsObject turret_shot = MakeTurretShot(ref turret_aim); 
     454        PhysicsObject turret1_shot = MakeTurret1Shot(ref turret1_aim); 
     455        PhysicsObject turret2_shot = MakeTurret2Shot(ref turret2_aim); 
     456        if (turretdelay == 50) 
     457        { 
     458            if (turret.Health.Value > 0) 
     459            { 
     460                Add(turret_shot, 1); 
     461                turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret_aim.Angle + Angle.FromDegrees(15) + Angle.FromDegrees(turretspread.Value)); 
     462                turret_shot = MakeTurretShot(ref turret_aim); 
     463                Add(turret_shot, 1); 
     464                turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret_aim.Angle + Angle.FromDegrees(-15) + Angle.FromDegrees(turretspread.Value)); 
     465                turret_shot = MakeTurretShot(ref turret_aim); 
     466                Add(turret_shot, 1); 
     467                turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret_aim.Angle + Angle.FromDegrees(30) + Angle.FromDegrees(turretspread.Value)); 
     468                turret_shot = MakeTurretShot(ref turret_aim); 
     469                Add(turret_shot, 1); 
     470                turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret_aim.Angle + Angle.FromDegrees(-30) + Angle.FromDegrees(turretspread.Value)); 
     471                turret_shot = MakeTurretShot(ref turret_aim); 
     472                Add(turret_shot, 1); 
     473            } 
     474            if (turret1.Health.Value > 0) 
     475            { 
     476                Add(turret1_shot, 1); 
     477                turret1_shot.Velocity = Vector.FromLengthAndAngle(100, turret1_aim.Angle + Angle.FromDegrees(15) + Angle.FromDegrees(turretspread.Value)); 
     478                turret1_shot = MakeTurret1Shot(ref turret1_aim); 
     479                Add(turret1_shot, 1); 
     480                turret1_shot.Velocity = Vector.FromLengthAndAngle(100, turret1_aim.Angle + Angle.FromDegrees(-15) + Angle.FromDegrees(turretspread.Value)); 
     481                turret1_shot = MakeTurret1Shot(ref turret1_aim); 
     482                Add(turret1_shot, 1); 
     483                turret1_shot.Velocity = Vector.FromLengthAndAngle(100, turret1_aim.Angle + Angle.FromDegrees(30) + Angle.FromDegrees(turretspread.Value)); 
     484                turret1_shot = MakeTurret1Shot(ref turret1_aim); 
     485                Add(turret1_shot, 1); 
     486                turret1_shot.Velocity = Vector.FromLengthAndAngle(100, turret1_aim.Angle + Angle.FromDegrees(-30) + Angle.FromDegrees(turretspread.Value)); 
     487                turret1_shot = MakeTurret1Shot(ref turret1_aim); 
     488                Add(turret1_shot, 1); 
     489            } 
     490            if (turret2.Health.Value > 0) 
     491            { 
     492                Add(turret2_shot, 1); 
     493                turret2_shot.Velocity = Vector.FromLengthAndAngle(100, turret2_aim.Angle + Angle.FromDegrees(15) + Angle.FromDegrees(turretspread.Value)); 
     494                turret2_shot = MakeTurret2Shot(ref turret2_aim); 
     495                Add(turret2_shot, 1); 
     496                turret2_shot.Velocity = Vector.FromLengthAndAngle(100, turret2_aim.Angle + Angle.FromDegrees(-15) + Angle.FromDegrees(turretspread.Value)); 
     497                turret2_shot = MakeTurret2Shot(ref turret2_aim); 
     498                Add(turret2_shot, 1); 
     499                turret2_shot.Velocity = Vector.FromLengthAndAngle(100, turret2_aim.Angle + Angle.FromDegrees(30) + Angle.FromDegrees(turretspread.Value)); 
     500                turret2_shot = MakeTurret2Shot(ref turret2_aim); 
     501                Add(turret2_shot, 1); 
     502                turret2_shot.Velocity = Vector.FromLengthAndAngle(100, turret2_aim.Angle + Angle.FromDegrees(-30) + Angle.FromDegrees(turretspread.Value)); 
     503                turret2_shot = MakeTurret2Shot(ref turret2_aim); 
     504                Add(turret2_shot, 1); 
     505            } 
     506 
     507            turretdelay.Value = 0; 
     508 
     509        } 
     510    } 
     511    private PhysicsObject MakeTurretShot(ref Vector turret_aim) 
     512    { 
     513        PhysicsObject turret_shot = new PhysicsObject(20, 20); 
     514        turret_shot.X = turret.X; 
     515        turret_shot.Y = turret.Y; 
     516        turret_shot.Tag = "turret shot"; 
     517        turret_shot.Shape = Shape.Circle; 
     518        turret_shot.Color = Color.LimeGreen; 
     519        turret_shot.Restitution = 1; 
     520        turret_shot.Mass = 1; 
     521        turret_shot.LifetimeLeft = TimeSpan.FromMilliseconds(10000); 
     522        turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret_aim.Angle + Angle.FromDegrees(turretspread.Value)); 
     523        turret_shot.CollisionIgnoreGroup = 2 & 3; 
     524        return turret_shot; 
     525    } 
     526    private PhysicsObject MakeTurret1Shot(ref Vector turret1_aim) 
     527    { 
     528        PhysicsObject turret_shot = new PhysicsObject(20, 20); 
     529        turret_shot.X = turret1.X; 
     530        turret_shot.Y = turret1.Y; 
     531        turret_shot.Tag = "turret shot"; 
     532        turret_shot.Shape = Shape.Circle; 
     533        turret_shot.Color = Color.LimeGreen; 
     534        turret_shot.Restitution = 1; 
     535        turret_shot.Mass = 1; 
     536        turret_shot.LifetimeLeft = TimeSpan.FromMilliseconds(10000); 
     537        turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret1_aim.Angle + Angle.FromDegrees(turretspread.Value)); 
     538        turret_shot.CollisionIgnoreGroup = 2 & 3; 
     539        return turret_shot; 
     540    } 
     541    private PhysicsObject MakeTurret2Shot(ref Vector turret1_aim) 
     542    { 
     543        PhysicsObject turret_shot = new PhysicsObject(20, 20); 
     544        turret_shot.X = turret2.X; 
     545        turret_shot.Y = turret2.Y; 
     546        turret_shot.Tag = "turret shot"; 
     547        turret_shot.Shape = Shape.Circle; 
     548        turret_shot.Color = Color.LimeGreen; 
     549        turret_shot.Restitution = 1; 
     550        turret_shot.Mass = 1; 
     551        turret_shot.LifetimeLeft = TimeSpan.FromMilliseconds(10000); 
     552        turret_shot.Velocity = Vector.FromLengthAndAngle(100, turret1_aim.Angle + Angle.FromDegrees(turretspread.Value)); 
     553        turret_shot.CollisionIgnoreGroup = 2 & 3; 
     554        return turret_shot; 
    225555    } 
    226556} 
  • 2013/23/JoniK/pp/pp/ppContent/ppContent.contentproj

    r3985 r4030  
    6666    </Compile> 
    6767  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="turret.png"> 
     70      <Name>turret</Name> 
     71      <Importer>TextureImporter</Importer> 
     72      <Processor>TextureProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="up giant ship.png"> 
     77      <Name>up giant ship</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81  </ItemGroup> 
     82  <ItemGroup> 
     83    <Compile Include="turret1.png"> 
     84      <Name>turret1</Name> 
     85      <Importer>TextureImporter</Importer> 
     86      <Processor>TextureProcessor</Processor> 
     87    </Compile> 
     88    <Compile Include="turret2.png"> 
     89      <Name>turret2</Name> 
     90      <Importer>TextureImporter</Importer> 
     91      <Processor>TextureProcessor</Processor> 
     92    </Compile> 
     93  </ItemGroup> 
     94  <ItemGroup> 
     95    <Compile Include="shield.png"> 
     96      <Name>shield</Name> 
     97      <Importer>TextureImporter</Importer> 
     98      <Processor>TextureProcessor</Processor> 
     99    </Compile> 
     100  </ItemGroup> 
    68101  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    69102  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
Note: See TracChangeset for help on using the changeset viewer.