Changeset 9133 for 2017/utsjoki/ÁndeN


Ignore:
Timestamp:
2017-07-26 14:45:38 (6 years ago)
Author:
otosjahn
Message:
 
Location:
2017/utsjoki/ÁndeN/msPaint
Files:
10 added
2 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • 2017/utsjoki/ÁndeN/msPaint/msPaint/msPaint/msPaint.cs

    r9094 r9133  
    1313    Image taustaKuva = LoadImage("tausta"); 
    1414 
    15     Vector nopeusYlos = new Vector(0, 0); 
    16     Vector nopeusAlas = new Vector(0, 0); 
    17     Vector nopeusVasen = new Vector(0, 0); 
    18     Vector nopeusOikea = new Vector(0, 0); 
     15    Vector nopeusYlos = new Vector(0, 7500); 
     16    Vector nopeusAlas = new Vector(0, -7500); 
     17    Vector nopeusVasen = new Vector(-7500, 0); 
     18    Vector nopeusOikea = new Vector(7500, 0); 
    1919 
    2020    PhysicsObject pelaaja1; 
     
    2525    PhysicsObject ylaReuna; 
    2626    PhysicsObject alaReuna; 
     27     
    2728 
    2829    public override void Begin() 
     
    3031        LuoKentta(); 
    3132        AsetaOhjaimet(); 
     33 
     34        
     35    } 
     36 
     37    void LuoRuutu(Vector paikka, double leveys, double korkeus) 
     38    { 
     39        GameObject ruutu = new GameObject(leveys, korkeus); 
     40        ruutu.Position = paikka; 
     41        ruutu.Color = Color.Transparent; 
     42        Add(ruutu); 
    3243    } 
    3344 
    3445    void LuoKentta() 
    3546    { 
     47        TileMap kentta = TileMap.FromLevelAsset("kentta"); 
     48        kentta.SetTileMethod('x', LuoRuutu); 
     49        kentta.Execute(50, 50); 
    3650 
    37         pelaaja1 = LuoPelaaja(Level.Left + 20.0, 0.0); 
    38         pelaaja2 = LuoPelaaja(Level.Right - 20.0, 0.0); 
     51        pelaaja1 = LuoPelaaja1(Level.Left + 20.0, 0.0); 
     52        pelaaja2 = LuoPelaaja2(Level.Right - 20.0, 0.0); 
    3953 
    4054        vasenReuna = Level.CreateLeftBorder(); 
     
    5064        alaReuna.IsVisible = false; 
    5165 
     66        Level.Background.Image = taustaKuva; 
    5267        Level.Background.TileToLevel(); 
    5368 
     
    5570    } 
    5671 
    57     PhysicsObject LuoPelaaja(double x, double y) 
     72    PhysicsObject LuoPelaaja1(double x, double y) 
    5873    { 
    59         PhysicsObject pelaaja = new PhysicsObject(20.0, 20.0); 
    60         pelaaja.Shape = Shape.Rectangle; 
    61         pelaaja.X = x; 
    62         pelaaja.Y = y; 
    63         Add(pelaaja); 
    64         pelaaja.Image = LoadImage("pelaaja"); 
    65         return pelaaja; 
     74        PhysicsObject pelaaja1 = new PhysicsObject(60.0, 100.0); 
     75        pelaaja1.Shape = Shape.Rectangle; 
     76        pelaaja1.X = x; 
     77        pelaaja1.Y = y; 
     78        pelaaja1.LinearDamping = 0.4; 
     79        Add(pelaaja1); 
     80        pelaaja1.Image = LoadImage("pelaaja1"); 
     81        pelaaja1.CanRotate = false; 
     82         
     83 
     84        Timer ajastin = new Timer(); 
     85        ajastin.Interval = 0.1; 
     86        ajastin.Timeout += delegate { Maalaa(pelaaja1); }; 
     87        ajastin.Start(); 
     88 
     89        return pelaaja1; 
     90    } 
     91 
     92    PhysicsObject LuoPelaaja2(double x, double y) 
     93    { 
     94        PhysicsObject pelaaja2 = new PhysicsObject(60.0, 100.0); 
     95        pelaaja2.Shape = Shape.Rectangle; 
     96        pelaaja2.X = x; 
     97        pelaaja2.Y = y; 
     98        pelaaja2.LinearDamping = 0.4; 
     99        Add(pelaaja2); 
     100        pelaaja2.Image = LoadImage("pelaaja2"); 
     101        pelaaja2.CanRotate = false; 
     102 
     103        Timer ajastin = new Timer(); 
     104        ajastin.Interval = 0.1; 
     105        ajastin.Timeout += delegate { Maalaa(pelaaja2); }; 
     106        ajastin.Start(); 
     107 
     108        return pelaaja2; 
     109    } 
     110 
     111    void Maalaa(PhysicsObject pelaaja) 
     112    { 
     113        GameObject ruutu = GetObjectAt(pelaaja.Position); 
     114        ruutu.Angle = pelaaja.Angle; 
     115         
     116        if(pelaaja==pelaaja1) 
     117        { 
     118            ruutu.Image = LoadImage("splat1"); 
     119        } 
     120        if (pelaaja == pelaaja2) 
     121        { 
     122            ruutu.Image = LoadImage("splat2"); 
     123        } 
    66124    } 
    67125 
    68126    void AsetaOhjaimet() 
    69127    { 
    70         Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusYlos); 
    71         Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusAlas); 
    72         Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusVasen); 
    73         Keyboard.Listen(Key.D, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusOikea); 
     128        Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusYlos, Angle.FromDegrees(0)); 
     129        Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusAlas, Angle.FromDegrees(180)); 
     130        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusVasen, Angle.FromDegrees(90)); 
     131        Keyboard.Listen(Key.D, ButtonState.Down, AsetaNopeus, null, pelaaja1, nopeusOikea, Angle.FromDegrees(270)); 
    74132 
    75         Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusYlos); 
    76         Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusAlas); 
    77         Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusVasen); 
    78         Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusOikea); 
     133        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusYlos, Angle.FromDegrees(0)); 
     134        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusAlas, Angle.FromDegrees(180)); 
     135        Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusVasen, Angle.FromDegrees(90)); 
     136        Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, null, pelaaja2, nopeusOikea, Angle.FromDegrees(270)); 
    79137 
    80138        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    81139        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    82  
     140         
    83141    } 
    84142 
    85     void AsetaNopeus(PhysicsObject pelaaja, Vector nopeus) 
     143    void AsetaNopeus(PhysicsObject pelaaja, Vector nopeus, Angle kulma) 
    86144    { 
    87145        pelaaja.Push(nopeus); 
     146        pelaaja.Angle = kulma; 
    88147    } 
    89148} 
  • 2017/utsjoki/ÁndeN/msPaint/msPaint/msPaint/msPaint.csproj.Debug.cachefile

    r9094 r9133  
    11Content\tausta.xnb 
    2 Content\pelaaja.xnb 
     2Content\pelaaja1.xnb 
     3Content\pelaaja2.xnb 
     4Content\splat1.xnb 
     5Content\splat2.xnb 
     6Content\kentta.xnb 
  • 2017/utsjoki/ÁndeN/msPaint/msPaint/msPaint/obj/x86/Debug/ContentPipeline-{62FA8DE1-8CD3-4372-AEDC-37B1B391D730}.xml

    r9094 r9133  
    99      <Options>None</Options> 
    1010      <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\tausta.xnb</Output> 
    11       <Time>2017-07-25T13:02:44.6112123+03:00</Time> 
     11      <Time>2017-07-26T10:38:21.3275551+03:00</Time> 
    1212    </Item> 
    1313    <Item> 
    14       <Source>pelaaja.png</Source> 
    15       <Name>pelaaja</Name> 
     14      <Source>pelaaja1.png</Source> 
     15      <Name>pelaaja1</Name> 
    1616      <Importer>TextureImporter</Importer> 
    1717      <Processor>TextureProcessor</Processor> 
    1818      <Options>None</Options> 
    19       <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\pelaaja.xnb</Output> 
    20       <Time>2017-07-25T14:40:47.6534292+03:00</Time> 
     19      <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\pelaaja1.xnb</Output> 
     20      <Time>2017-07-26T10:14:49.3680514+03:00</Time> 
     21    </Item> 
     22    <Item> 
     23      <Source>pelaaja2.png</Source> 
     24      <Name>pelaaja2</Name> 
     25      <Importer>TextureImporter</Importer> 
     26      <Processor>TextureProcessor</Processor> 
     27      <Options>None</Options> 
     28      <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\pelaaja2.xnb</Output> 
     29      <Time>2017-07-26T10:14:49.3680514+03:00</Time> 
     30    </Item> 
     31    <Item> 
     32      <Source>splat1.png</Source> 
     33      <Name>splat1</Name> 
     34      <Importer>TextureImporter</Importer> 
     35      <Processor>TextureProcessor</Processor> 
     36      <Options>None</Options> 
     37      <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\splat1.xnb</Output> 
     38      <Time>2017-07-26T13:36:03.0934577+03:00</Time> 
     39    </Item> 
     40    <Item> 
     41      <Source>splat2.png</Source> 
     42      <Name>splat2</Name> 
     43      <Importer>TextureImporter</Importer> 
     44      <Processor>TextureProcessor</Processor> 
     45      <Options>None</Options> 
     46      <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\splat2.xnb</Output> 
     47      <Time>2017-07-26T13:36:03.1090578+03:00</Time> 
     48    </Item> 
     49    <Item> 
     50      <Source>kentta.txt</Source> 
     51      <Name>kentta</Name> 
     52      <Importer>TextFileImporter</Importer> 
     53      <Processor>TextFileContentProcessor</Processor> 
     54      <Options>None</Options> 
     55      <Output>C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\kentta.xnb</Output> 
     56      <Time>2017-07-26T14:14:36.2586002+03:00</Time> 
    2157    </Item> 
    2258    <BuildSuccessful>true</BuildSuccessful> 
  • 2017/utsjoki/ÁndeN/msPaint/msPaint/msPaint/obj/x86/Debug/cachefile-{62FA8DE1-8CD3-4372-AEDC-37B1B391D730}-targetpath.txt

    r9094 r9133  
    11Content\tausta.xnb 
    2 Content\pelaaja.xnb 
     2Content\pelaaja1.xnb 
     3Content\pelaaja2.xnb 
     4Content\splat1.xnb 
     5Content\splat2.xnb 
     6Content\kentta.xnb 
  • 2017/utsjoki/ÁndeN/msPaint/msPaint/msPaint/obj/x86/Debug/msPaint.csproj.FileListAbsolute.txt

    r9094 r9133  
    88C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\tausta.xnb 
    99C:\MyTemp\msPaint\msPaint\msPaint\obj\x86\Debug\msPaint.csprojResolveAssemblyReference.cache 
    10 C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\pelaaja.xnb 
     10C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\pelaaja1.xnb 
     11C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\pelaaja2.xnb 
     12C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\splat1.xnb 
     13C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\splat2.xnb 
     14C:\MyTemp\msPaint\msPaint\msPaint\bin\x86\Debug\Content\kentta.xnb 
  • 2017/utsjoki/ÁndeN/msPaint/msPaint/msPaintContent/msPaintContent.contentproj

    r9094 r9133  
    4646  </ItemGroup> 
    4747  <ItemGroup> 
     48    <Compile Include="pelaaja1.png"> 
     49      <Name>pelaaja1</Name> 
     50      <Importer>TextureImporter</Importer> 
     51      <Processor>TextureProcessor</Processor> 
     52    </Compile> 
     53    <Compile Include="pelaaja2.png"> 
     54      <Name>pelaaja2</Name> 
     55      <Importer>TextureImporter</Importer> 
     56      <Processor>TextureProcessor</Processor> 
     57    </Compile> 
     58  </ItemGroup> 
     59  <ItemGroup> 
    4860    <Compile Include="tausta.png"> 
    4961      <Name>tausta</Name> 
     
    5365  </ItemGroup> 
    5466  <ItemGroup> 
    55     <Compile Include="pelaaja.png"> 
    56       <Name>pelaaja</Name> 
     67    <Compile Include="kentta.txt"> 
     68      <Name>kentta</Name> 
     69      <Importer>TextFileImporter</Importer> 
     70      <Processor>TextFileContentProcessor</Processor> 
     71    </Compile> 
     72  </ItemGroup> 
     73  <ItemGroup> 
     74    <Compile Include="splat1.png"> 
     75      <Name>splat1</Name> 
     76      <Importer>TextureImporter</Importer> 
     77      <Processor>TextureProcessor</Processor> 
     78    </Compile> 
     79    <Compile Include="splat2.png"> 
     80      <Name>splat2</Name> 
    5781      <Importer>TextureImporter</Importer> 
    5882      <Processor>TextureProcessor</Processor> 
Note: See TracChangeset for help on using the changeset viewer.