Changeset 610 for 2010/23


Ignore:
Timestamp:
2010-06-09 11:59:55 (13 years ago)
Author:
paaaanro
Message:

Tein Ball Warsia eteenpäin ja lisäsin siihen vihollisen.

Location:
2010/23/elalylon/Ball Wars
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2010/23/elalylon/Ball Wars/Content/Content.contentproj

    r569 r610  
    4747    </Compile> 
    4848  </ItemGroup> 
     49  <ItemGroup> 
     50    <Compile Include="m16_levea.png"> 
     51      <Name>m16_levea</Name> 
     52      <Importer>TextureImporter</Importer> 
     53      <Processor>TextureProcessor</Processor> 
     54    </Compile> 
     55  </ItemGroup> 
     56  <ItemGroup> 
     57    <Compile Include="m16_levea2.png"> 
     58      <Name>m16_levea2</Name> 
     59      <Importer>TextureImporter</Importer> 
     60      <Processor>TextureProcessor</Processor> 
     61    </Compile> 
     62  </ItemGroup> 
     63  <ItemGroup> 
     64    <Compile Include="enemy.png"> 
     65      <Name>enemy</Name> 
     66      <Importer>TextureImporter</Importer> 
     67      <Processor>TextureProcessor</Processor> 
     68    </Compile> 
     69  </ItemGroup> 
     70  <ItemGroup> 
     71    <Compile Include="Glock 17.png"> 
     72      <Name>Glock 17</Name> 
     73      <Importer>TextureImporter</Importer> 
     74      <Processor>TextureProcessor</Processor> 
     75    </Compile> 
     76  </ItemGroup> 
     77  <ItemGroup> 
     78    <Compile Include="Glock 17_2.png"> 
     79      <Name>Glock 17_2</Name> 
     80      <Importer>TextureImporter</Importer> 
     81      <Processor>TextureProcessor</Processor> 
     82    </Compile> 
     83  </ItemGroup> 
    4984  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    5085  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2010/23/elalylon/Ball Wars/Peli.cs

    r569 r610  
    1010    { 
    1111        const double nopeus = 200; 
    12         const double hyppyVoima = 4000; 
     12        const double hyppyVoima = 8000; 
     13        Vector enemyshootvector; 
     14        Vector tahtaa; 
    1315 
    1416        IntMeter pisteLaskuri; 
    1517        ValueDisplay pisteNaytto; 
    16  
     18        ValueDisplay ammoNaytto; 
    1719        PlatformCharacter pelaaja1; 
     20        PlatformCharacter vihollinen; 
     21        AssaultRifle m16; 
     22        AssaultRifle Glock; 
    1823 
    1924        protected override void Begin() 
     
    3338            Add(pisteNaytto);    // lisätään peliin 
    3439 
     40            ammoNaytto = new ValueDisplay(); 
     41            ammoNaytto.Text = "Pisteitä: "; 
     42            ammoNaytto.X = Screen.RightSafe - 250; 
     43            ammoNaytto.Y = Screen.TopSafe - 50; 
     44            Add(ammoNaytto); 
     45 
     46             
     47            // Ajastin, jonka avulla ajastetaan vihollisen toiminta, 
     48            // mm. ampuminen säännöllisin väliajoin 
     49            Timer aly = new Timer(); 
     50            aly.Interval = 0.01; // 0.1 sekuntia 
     51            aly.Trigger += enemyshoot; 
     52            Add(aly); 
     53            aly.Start(); 
     54 
    3555            // Zoomataan lähemmäksi 
    3656            Camera.ZoomFactor = 2.0; 
     
    4262        } 
    4363 
     64        void enemyshoot(Timer t) 
     65        { 
     66            if (pelaaja1.Position.X < 0) 
     67            { 
     68                //Glock laitetaan toisin päin 
     69            } 
     70            enemyshootvector = pelaaja1.Position - vihollinen.Position; 
     71            vihollinen.Weapon.Angle = enemyshootvector.Angle; 
     72            Glock.Use(); 
     73        } 
     74         
     75 
     76                 
    4477        void luoKentta() 
    4578        { 
    4679            Level.CreateBorders(); 
    47             Level.Background.CreateGradient(Color.Black, Color.Red); 
     80            Level.Background.CreateGradient(Color.Blue, Color.Red); 
    4881            Gravity = new Vector(0, -1000); 
    4982             
    5083             
    51             lisaaTaso(-200, -350); 
    52             lisaaTaso(0, -200); 
    53  
     84            lisaaTaso(-200, -400); 
     85            lisaaTaso(0, -300); 
     86            lisaaTaso(-450, -300); 
    5487 
    5588            lisaaPelaajat(); 
     89            LuoVihollinen(); 
    5690            Camera.Follow(pelaaja1); 
    5791            lisaaNappaimet(); 
     
    6195        { 
    6296            PhysicsObject taso = PhysicsObject.CreateStaticObject(100, 30); 
    63             taso.Color = Color.Green; 
     97            taso.Color = Color.Gray; 
    6498            taso.X = x; 
    6599            taso.Y = y; 
     
    69103        void lisaaPelaajat() 
    70104        { 
    71             pelaaja1 = new PlatformCharacter(40, 40); 
     105            pelaaja1 = new PlatformCharacter(50, 50); 
    72106            pelaaja1.Mass = 10.0; 
    73107            pelaaja1.Image = LoadImage("Hero"); 
    74108            pelaaja1.X = 0; 
    75109            pelaaja1.Y = Level.Bottom + 120; 
     110            Add(pelaaja1); 
    76111 
    77             Add(pelaaja1); 
     112            m16 = new AssaultRifle(100, 30); 
     113            m16.Ammo.Value = 60; 
     114            pelaaja1.Weapon = m16; 
     115            m16.Image = LoadImage("m16_levea"); 
     116            m16.TimeBetweenUse = new TimeSpan(1500000); 
     117            // TODO: Panokset lentämään suorempaan 
    78118        } 
     119        void LuoVihollinen() 
     120        { 
     121            vihollinen = new PlatformCharacter(50, 50); 
     122            vihollinen.Mass = 10.0; 
     123            vihollinen.Image = LoadImage("enemy"); 
     124            vihollinen.X = 200; 
     125            vihollinen.Y = Level.Bottom + 120; 
     126            Add(vihollinen); 
     127             
     128            Glock = new AssaultRifle(100, 30); 
     129            Glock.Ammo.Value = 14; 
     130            pelaaja1.Weapon = m16; 
     131            Glock.Image = LoadImage("Glock 17"); 
     132            Glock.TimeBetweenUse = new TimeSpan(3000000); 
     133            vihollinen.Weapon = Glock; 
     134            // TODO: Saako vihollisen ampumia panoksia / omia panoksia häviämään jotenkin? (tuleeko niistä damagea pelaajalle?) 
    79135 
     136        } 
    80137        void lisaaNappaimet() 
    81138        { 
     
    86143            Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1, nopeus); 
    87144            Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1, hyppyVoima); 
     145            Mouse.Listen(MouseButton.Left, ButtonState.Down, shoot, "ammu"); 
     146            Mouse.ListenMovement(0.1, tahtax_, null); 
    88147        } 
    89148 
     149        void tahtax_(AnalogState tila) 
     150        { 
     151            if (Mouse.PositionOnScreen.X  < 0) 
     152            { 
     153                m16.Image = LoadImage("m16_levea"); 
     154            } 
     155            tahtaa = Mouse.PositionOnWorld - pelaaja1.Position; 
     156            pelaaja1.Weapon.Angle = tahtaa.Angle; 
     157        } 
     158 
     159        void shoot() 
     160        { 
     161            pelaaja1.Weapon.Use(); 
     162        } 
    90163 
    91164        void liikuta(PlatformCharacter hahmo, double nopeus) 
Note: See TracChangeset for help on using the changeset viewer.