Changeset 2497


Ignore:
Timestamp:
2011-08-02 14:57:09 (8 years ago)
Author:
jemapalm
Message:

Talletus.

Location:
2011/31/JesseP
Files:
13 added
11 edited

Legend:

Unmodified
Added
Removed
  • 2011/31/JesseP/Pong/Pong/Pong/Peli.cs

    r2476 r2497  
    88 
    99public class Peli : PhysicsGame 
    10 {  Vector nopeusYlos = new Vector (0, 200 ); 
    11     Vector nopeusAlas = new Vector (0, 200 ); 
     10{ 
     11 
     12    Vector nopeusYlos = new Vector(0, 200); 
     13    Vector nopeusAlas = new Vector(0, -200); 
    1214    PhysicsObject pallo; 
     15 
    1316    PhysicsObject maila1; 
    1417    PhysicsObject maila2; 
     18    IntMeter pelaajan1Pisteet; 
     19    IntMeter pelaajan2Pisteet; 
     20    PhysicsObject vasenReuna; 
     21    PhysicsObject oikeaReuna; 
    1522    public override void Begin() 
    1623    { 
     24 
    1725        LuoKentta(); 
    1826        asetaohjaimet(); 
     27        Lisaalaskurit(); 
    1928        aloitapeli(); 
    2029    } 
     
    2534    { 
    2635        pallo = new PhysicsObject(40.0, 40.0); 
    27         pallo.Shape = Shape.Circle; 
     36        //pallo.Shape = Shape.Circle; 
    2837        pallo.X = -200.0; 
    2938        pallo.Y = 0.0; 
    3039        Add(pallo); 
    3140 
    32         Level.CreateBorders(1.0, false); 
    33         pallo.Restitution = 1.0; 
     41        vasenReuna = Level.CreateLeftBorder(); 
     42        vasenReuna.Restitution = 1.0; 
     43        vasenReuna.IsVisible = false; 
     44        oikeaReuna = Level.CreateRightBorder(); 
     45        oikeaReuna.Restitution = 1.0; 
     46        oikeaReuna.IsVisible = false; 
     47        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     48        alaReuna.Restitution = 1.0; 
     49        alaReuna.IsVisible = false; 
     50        PhysicsObject yläReuna = Level.CreateTopBorder(); 
     51        yläReuna.Restitution = 1.0; 
     52        yläReuna.IsVisible = false; 
     53        pallo.Restitution = 50; 
    3454        Level.BackgroundColor = Color.Black; 
    3555        Camera.ZoomToLevel(); 
    36  
    37        maila1 = LuoMaila(Level.Left + 20.0, 0.0 ); 
    38        maila2 = LuoMaila(Level.Right - 20.0, 0.0 ); 
     56        AddCollisionHandler(pallo, KasittelePallonTormays); 
     57        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     58        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     59        MessageDisplay.TextColor = Color.White; 
    3960    } 
    4061 
     
    4566        Vector impulssi = new Vector(500.0, 0.0); 
    4667        pallo.Hit(impulssi); 
    47          
    48     }   
    49     PhysicsObject LuoMaila (double x, double y ) 
     68 
     69    } 
     70    PhysicsObject LuoMaila(double x, double y) 
    5071    { 
    51 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     72        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
    5273        maila.Shape = Shape.Rectangle; 
    5374        maila.X = x; 
     
    6081    void asetaohjaimet() 
    6182    { 
    62     Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu"); 
    63     Keyboard.Listen(Key.A, ButtonState.Down,AsetaNopeus LiikutaMailaaYlos, "pelaaja 1: 
    64     Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null ); 
    65      
     83        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 
     84        Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     85        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "poistu"); 
     86        Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     87        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     88        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     89        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     90        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
     91        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     92        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     93        ControllerOne.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila1, nopeusYlos); 
     94        ControllerOne.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     95        ControllerOne.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila1, nopeusAlas); 
     96        ControllerOne.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     97        ControllerTwo.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila2, nopeusYlos); 
     98        ControllerTwo.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     99        ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila2, nopeusAlas); 
     100        ControllerTwo.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     101 
     102        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu"); 
     103        ControllerTwo.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu"); 
     104 
    66105    } 
    67     voidAsetaNopeus( PhysicsObject maila,Vector nopeus) 
    68 {maila.Velocity = nopeus;} 
     106    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
     107    { 
     108        if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 
     109        { 
     110            maila.Velocity = Vector.Zero; 
     111            return; 
     112        } 
    69113 
     114        if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 
     115        { 
     116            maila.Velocity = Vector.Zero; 
     117            return; 
     118 
     119        } 
     120 
     121        maila.Velocity = nopeus; 
     122 
     123    } 
     124    void Lisaalaskurit() 
     125    { 
     126        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
     127        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
     128    } 
     129 
     130    IntMeter LuoPisteLaskuri(double x, double y) 
     131    { 
     132        IntMeter laskuri = new IntMeter(0); 
     133        laskuri.MaxValue = 100000; 
     134        Label naytto = new Label(); 
     135        naytto.BindTo(laskuri); 
     136        naytto.X = x; 
     137        naytto.Y = y; 
     138        naytto.TextColor = Color.White; 
     139        naytto.BorderColor = Level.BackgroundColor; 
     140        naytto.Color = Level.BackgroundColor; 
     141        Add(naytto); 
     142 
     143        return laskuri; 
     144    } 
     145    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     146    { 
     147        if (kohde == oikeaReuna) 
     148        { 
     149            pelaajan1Pisteet.Value += 1; 
     150        } 
     151        else if (kohde == vasenReuna) 
     152        { 
     153            pelaajan2Pisteet.Value += 1; 
     154        } 
     155    }  
     156 
     157      
    70158} 
    71  
  • 2011/31/JesseP/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt

    r2476 r2497  
    77c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 
    88c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 
     9C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\ResolveAssemblyReference.cache 
     10C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 
     11C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 
     12C:\MyTemp\JesseP\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 
     13C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Pong.exe 
     14C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Pong.pdb 
     15C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Jypeli4.dll 
     16C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Jypeli4.xml 
  • 2011/31/JesseP/Pong/Pong/PongContent/obj/x86/Debug/ContentPipeline.xml

    r2476 r2497  
    88      <BuildConfiguration>Debug</BuildConfiguration> 
    99      <CompressContent>false</CompressContent> 
    10       <RootDirectory>c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\PongContent\</RootDirectory> 
    11       <LoggerRootDirectory>c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\</LoggerRootDirectory> 
    12       <IntermediateDirectory>c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\PongContent\obj\x86\Debug\</IntermediateDirectory> 
    13       <OutputDirectory>c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory> 
     10      <RootDirectory>C:\MyTemp\JesseP\Pong\Pong\PongContent\</RootDirectory> 
     11      <LoggerRootDirectory>C:\MyTemp\JesseP\Pong\Pong\Pong\</LoggerRootDirectory> 
     12      <IntermediateDirectory>C:\MyTemp\JesseP\Pong\Pong\PongContent\obj\x86\Debug\</IntermediateDirectory> 
     13      <OutputDirectory>C:\MyTemp\JesseP\Pong\Pong\Pong\bin\x86\Debug\Content\</OutputDirectory> 
    1414    </Settings> 
    1515    <Assemblies> 
  • 2011/31/JesseP/Pong/Pong/PongContent/obj/x86/Debug/PongContent.contentproj.FileListAbsolute.txt

    r2476 r2497  
    11c:\documents and settings\jemapalm\my documents\visual studio 2010\Projects\Pong\Pong\PongContent\obj\x86\Debug\ResolveAssemblyReference.cache 
     2C:\MyTemp\JesseP\Pong\Pong\PongContent\obj\x86\Debug\ResolveAssemblyReference.cache 
Note: See TracChangeset for help on using the changeset viewer.