Changeset 2955 for 2012/24


Ignore:
Timestamp:
2012-06-12 14:39:31 (7 years ago)
Author:
jaollipa
Message:

Talletus.

Location:
2012/24/JaakkoL/Crisis Fire
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • 2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/Crisis Fire.csproj

    r2908 r2955  
    111111  </ItemGroup> 
    112112  <ItemGroup> 
    113     <Compile Include="Bullets.cs" /> 
    114113    <Compile Include="Ohjelma.cs" /> 
    115114    <Compile Include="Peli.cs" /> 
  • 2012/24/JaakkoL/Crisis Fire/FysiikkaPeli1/FysiikkaPeli1/Peli.cs

    r2936 r2955  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
     8 
     9class Player : PhysicsObject 
     10{ 
     11    public int HPP = 1; 
     12 
     13    public Player(double height, double width) 
     14        : base(height, width) 
     15    { 
     16    } 
     17} 
     18 
     19class Enemy : PhysicsObject 
     20{ 
     21    public int HP; 
     22    public int SaatavatPisteet; 
     23 
     24    public Enemy(double height, double width) 
     25        : base(height, width) 
     26    { 
     27    } 
     28} 
    829 
    930class CrisisFire : PhysicsGame 
     
    1738    Vector VelocityRight = new Vector(250.0, 0.0); 
    1839    Vector FocusedVelocityRight = new Vector(125.0, 0.0); 
    19     PhysicsObject Player; 
    20     PhysicsObject SmallEnemy; 
    21     PhysicsObject Enemy; 
    22     PhysicsObject LargeEnemy; 
    23     PhysicsObject Boss; 
     40    Player Player; 
     41    Enemy SmallEnemy; 
     42    Enemy Enemy; 
     43    Enemy LargeEnemy; 
     44    Enemy Boss; 
    2445    PhysicsObject BorderTop; 
    2546    PhysicsObject BorderBottom; 
     47    PhysicsObject BorderLeft; 
    2648    IntMeter PowerGauge; 
     49    IntMeter ScoreGauge; 
    2750 
    2851    public override void Begin() 
     
    3154        SetControls(); 
    3255        CreatePowerGauge(); 
     56        CreateScoreGauge(); 
    3357    } 
    3458 
    3559    void Field() 
    3660    { 
    37         Level.CreateBorders(false); 
    3861        Level.BackgroundColor = Color.Gray; 
    3962        Camera.ZoomToLevel(); 
    4063 
    41         BorderTop = new PhysicsObject(1000.0, 150.0, Shape.Rectangle); 
     64        BorderTop = new PhysicsObject(20000.0, 150.0, Shape.Rectangle); 
    4265        BorderTop.Y = Screen.Top - 150.0; 
    4366        BorderTop.X = 0.0; 
     67        BorderTop.Mass = 99999999999999999999999999999.0; 
     68        BorderTop.Restitution = 0.0; 
    4469        BorderTop.Color = Color.Black; 
    45         BorderTop.Restitution = 0.0; 
    46         BorderTop.Mass = 9999999999999.0; 
     70        BorderTop.IgnoresGravity = true; 
    4771        Add(BorderTop); 
    4872 
    49         BorderBottom = new PhysicsObject(1000.0, 150.0, Shape.Rectangle); 
     73        BorderBottom = new PhysicsObject(20000.0, 150.0, Shape.Rectangle); 
    5074        BorderBottom.Y = Screen.Bottom + 150.0; 
    5175        BorderBottom.X = 0.0; 
     76        BorderBottom.Mass = 9999999999999999999999999999999.0; 
     77        BorderBottom.Restitution = 0.0; 
    5278        BorderBottom.Color = Color.Black; 
    53         BorderBottom.Restitution = 0.0; 
    54         BorderBottom.Mass = 99999999999999.0; 
     79        BorderBottom.IgnoresGravity = true; 
    5580        Add(BorderBottom); 
    5681 
    57         Player = new PhysicsObject(10.0, 10.0, Shape.Circle); 
     82        BorderLeft = new PhysicsObject(100.0, 800.0, Shape.Rectangle); 
     83        BorderLeft.Y = 0; 
     84        BorderLeft.X = Screen.Left + 90.0; 
     85        BorderLeft.Mass = 9999999999999999999999999999999.0; 
     86        BorderLeft.Restitution = 0.0; 
     87        BorderLeft.Color = Color.Black; 
     88        BorderLeft.IgnoresGravity = true; 
     89        Add(BorderLeft); 
     90 
     91        Player = new Player(10.0, 10.0); 
    5892        double massP1 = 10.0; 
    5993        Player.Mass = massP1; 
     94        Player.Shape = Shape.Circle; 
    6095        Player.Color = Color.Red; 
    6196        Player.X = -400.0; 
    6297        Player.Y = 0.0; 
    63  
     98        Player.IgnoresGravity = true; 
    6499        Add(Player); 
     100 
     101        Gravity = new Vector(-200.0, 0.0); 
     102        // Creates the level's borders and player. 
     103        // Note that you have 0 lives, the game is over if you are hit. But that's kind of a score attack SHMUP's idea. 
     104    } 
     105 
     106    void EnemySpawns() 
     107    { 
     108 
    65109    } 
    66110 
     
    77121        ControllerOne.Listen(Button.DPadRight, ButtonState.Released, SetVelocity, null, Player, Vector.Zero); 
    78122        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, null); 
    79         ControllerOne.Listen(Button.RightTrigger, ButtonState.Pressed, FirePrimary, null, Player, 10.0, 5.0, Shape.Rectangle); 
     123        ControllerOne.Listen(Button.RightTrigger, ButtonState.Pressed, FirePrimary, null, Player, 10.0, 2.5, Shape.Rectangle); 
    80124        ControllerOne.Listen(Button.LeftTrigger, ButtonState.Pressed, FireSecondary, null, Player, 25.0, 10.0, Shape.Diamond); 
     125        // Sets controls. Focused movement is currently not implemented 
    81126    } 
    82127     
    83128    void FirePrimary(PhysicsObject Player, double ShotWidth, double ShotHeight, Shape ShotShape) 
    84129    { 
    85         PhysicsObject Primary1 = new PhysicsObject(ShotWidth, ShotHeight, ShotShape); 
    86         Primary1.X = Player.X + 15; 
    87         Primary1.Y = Player.Y + 5; 
    88         PhysicsObject Primary2 = new PhysicsObject(ShotWidth, ShotHeight, ShotShape); 
    89         Primary2.X = Player.X + 15; 
    90         Primary2.Y = Player.Y - 5; 
    91         Add(Primary1); 
    92         Add(Primary2); 
    93         Primary1.Hit(new Vector(1200.0, 0.0)); 
    94         Primary2.Hit(new Vector(1200.0, 0.0)); 
     130        CreatePrimary(Player.X + 20, Player.Y + 10, 12.0, 3.0, new Vector(750.0, 25.0), 10); 
     131        CreatePrimary(Player.X + 20, Player.Y + 4, 12.0, 3.0, new Vector(750.0, -25.0), 10); 
     132        CreatePrimary(Player.X + 10, Player.Y + 17, 8.0, 2.0, new Vector(750.0, 100.0), 5); 
     133        CreatePrimary(Player.X + 10, Player.Y - 3, 8.0, 2.0, new Vector(750.0, -100.0), 5); 
     134        // Fires a wide, relatively slow shotgun-like 4 bullet spread from the top gun 
     135    } 
     136 
     137    void CreatePrimary(double x, double y, double sizeX, double sizeY, Vector PrimaryImpulse, int DamagePrimary) 
     138    { 
     139        PhysicsObject Primary = new PhysicsObject(sizeX, sizeY); 
     140        Primary.Color = Color.White; 
     141        Primary.X = x; 
     142        Primary.Y = y; 
     143        Primary.IgnoresGravity = true; 
     144        Add(Primary); 
     145        Primary.Hit(PrimaryImpulse); 
    95146    } 
    96147 
    97148    void FireSecondary(PhysicsObject Player, double ShotWidth, double ShotHeight, Shape ShotShape) 
    98149    { 
    99         PhysicsObject Secondary = new PhysicsObject(ShotWidth, ShotHeight, ShotShape); 
    100         Secondary.X = Player.X + 15; 
    101         Secondary.Y = Player.Y; 
     150        CreateSecondary(Player.X + 20, Player.Y - 4, 15.0, 5.0, new Vector(1200.0, 0.0), 20); 
     151        CreateSecondary(Player.X + 20, Player.Y - 10, 15.0, 5.0, new Vector(1200.0, 0.0), 20); 
     152        // Fires a fast and powerful double-barrel shot from the bottom gun 
     153    } 
     154 
     155    void CreateSecondary(double X, double Y, double SizeX, double SizeY, Vector SecondaryImpulse, int DamageSecondary) 
     156    { 
     157        PhysicsObject Secondary = new PhysicsObject(SizeX, SizeY); 
     158        Secondary.Shape = Shape.Diamond; 
     159        Secondary.Color = Color.White; 
     160        Secondary.X = X; 
     161        Secondary.Y = Y; 
     162        Secondary.IgnoresGravity = true; 
    102163        Add(Secondary); 
    103         Secondary.Hit(new Vector(500.0, 0.0)); 
     164        Secondary.Hit(SecondaryImpulse); 
    104165    } 
    105166 
     
    123184 
    124185        Label PowerText = new Label("Power: "); 
    125         PowerText.X = Screen.Left + 100; 
     186        PowerText.X = Screen.Left + 108; 
    126187        PowerText.Y = Screen.Top - 100; 
    127188        PowerText.TextColor = Color.White; 
     
    129190        Add(PowerText); 
    130191    } 
     192 
     193    void CreateScoreGauge() 
     194    { 
     195        ScoreGauge = new IntMeter(0); 
     196 
     197        Label ScoreMeter = new Label(); 
     198        ScoreMeter.X = Screen.Right - 150; 
     199        ScoreMeter.Y = Screen.Top - 100; 
     200        ScoreMeter.TextColor = Color.White; 
     201        ScoreMeter.Color = Color.DarkGreen; 
     202 
     203        ScoreMeter.BindTo(ScoreGauge); 
     204        Add(ScoreMeter); 
     205 
     206        Label ScoreText = new Label("Score: "); 
     207        ScoreText.X = Screen.Right - 190; 
     208        ScoreText.Y = Screen.Top - 100; 
     209        ScoreText.TextColor = Color.White; 
     210        ScoreText.Color = Color.DarkGreen; 
     211        Add(ScoreText); 
     212    } 
    131213} 
    132  
Note: See TracChangeset for help on using the changeset viewer.