Changeset 7309 for 2016/24


Ignore:
Timestamp:
2016-06-14 15:03:01 (3 years ago)
Author:
jetopont
Message:

Tein laser peliä ja bongia

Location:
2016/24/JereP/Bong
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • 2016/24/JereP/Bong/Bong/Bong/Bong.cs

    r7271 r7309  
    99public class Bong : PhysicsGame 
    1010{ 
    11     Vector nopeusYlos = new Vector(0, 200); 
    12     Vector nopeusAlas = new Vector(0, -200); 
     11    Vector nopeusYlos = new Vector(0,300); 
     12    Vector nopeusAlas = new Vector(0,-300); 
    1313 
    1414    PhysicsObject pallo; 
    1515    PhysicsObject maila1; 
    1616    PhysicsObject maila2; 
     17 
     18    PhysicsObject vasenReuna; 
     19    PhysicsObject oikeaReuna; 
     20 
     21    IntMeter Pelaajan1Pisteet; 
     22    IntMeter Pelaajan2Pisteet; 
    1723    public override void Begin() 
    1824    { 
     
    2935        pallo.X = -500.0; 
    3036        pallo.Y = 100.0; 
    31         Level.CreateBorders(1.0, true); 
     37 
     38        vasenReuna = Level.CreateLeftBorder(); 
     39        vasenReuna.Restitution = 1.0; 
     40        vasenReuna.IsVisible = false; 
     41        oikeaReuna = Level.CreateRightBorder(); 
     42        oikeaReuna.Restitution = 1.0; 
     43        oikeaReuna.IsVisible = false; 
     44        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     45        alaReuna.Restitution = 1.0; 
     46        alaReuna.IsVisible = false; 
     47        PhysicsObject ylaReuna = Level.CreateTopBorder(); 
     48        ylaReuna.Restitution = 1.0; 
     49        ylaReuna.IsVisible = false; 
     50 
    3251        pallo.Restitution = 1.0; 
    33         Level.Background.Color = Color.Pink; 
     52        pallo.KineticFriction = 1.0; 
     53 
     54        Level.Background.Color = Color.Black; 
     55        Camera.ZoomToLevel(); 
    3456 
    3557        Add(pallo); 
    3658 
    37         maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
    38         maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     59        AddCollisionHandler(pallo, KasittelePallonTormays); 
    3960 
    40      
     61        maila1 = LuoMaila(Level.Left + 40.0, 0.0); 
     62        maila2 = LuoMaila(Level.Right - 40.0, 0.0); 
     63   
    4164 
    4265 
     
    6285    void AsetaOhjaimet() 
    6386    { 
    64         Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 
    65         Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     87        Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos); 
     88        Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    6689 
    67         Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
    68         Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     90        Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     91        Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    6992 
    7093        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     
    101124            return; 
    102125        } 
    103  
     126         
    104127        maila.Velocity = nopeus; 
    105128    } 
    106129    void LisaaLaskurit() 
    107130    { 
    108         /// laskuri 
     131        Pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
     132        Pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
    109133    } 
    110     IntMeter LuoPisteLaskuri() 
     134    IntMeter LuoPisteLaskuri(double x, double y) 
    111135    { 
     136    
    112137        IntMeter laskuri = new IntMeter(0); 
    113         laskuri.MaxValue = 10; 
    114  
     138        laskuri.MaxValue = 300000000; 
    115139        Label naytto = new Label(); 
    116140        naytto.BindTo(laskuri); 
    117141        naytto.X = x; 
    118142        naytto.Y = y; 
    119         naytto.TextColor = Color.Black; 
     143        naytto.TextColor = Color.White; 
    120144        naytto.BorderColor = Level.Background.Color; 
    121145        naytto.Color = Level.Background.Color; 
    122146        Add(naytto); 
    123147 
     148         
     149 
    124150        return laskuri; 
    125151    } 
     152    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     153    { 
     154        if (kohde == oikeaReuna) 
     155        { 
     156            Pelaajan1Pisteet.Value += 1; 
     157        } 
     158        else if (kohde == vasenReuna) 
     159        { 
     160            Pelaajan2Pisteet.Value += 1; 
     161        } 
     162    } 
     163    const double PALLON_MIN_NOPEUS = 500; 
     164    protected override void Update(Time time) 
     165    { 
     166        if (pallo != null && Math.Abs(pallo.Velocity.X) < PALLON_MIN_NOPEUS) 
     167        { 
     168            pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); 
     169        } 
     170        base.Update(time); 
     171    } 
     172     
    126173} 
  • 2016/24/JereP/Bong/Bong/Bong/obj/x86/Debug/Bong.csproj.FileListAbsolute.txt

    r7271 r7309  
    77C:\MyTemp\JerePöntynen\Bong\Bong\Bong\obj\x86\Debug\Bong.exe 
    88C:\MyTemp\JerePöntynen\Bong\Bong\Bong\obj\x86\Debug\Bong.pdb 
     9C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Bong.exe 
     10C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Bong.pdb 
     11C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Jypeli.dll 
     12C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Jypeli.xml 
     13C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Bong.csprojResolveAssemblyReference.cache 
     14C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 
     15C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Bong.exe 
     16C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\Bong.pdb 
  • 2016/24/JereP/Bong/Bong/Bong/obj/x86/Debug/ContentPipeline-{D693B282-540A-4A65-8EE0-577FDC978B51}.xml

    r7271 r7309  
    99      <BuildConfiguration>Debug</BuildConfiguration> 
    1010      <CompressContent>false</CompressContent> 
    11       <RootDirectory>C:\MyTemp\JerePöntynen\Bong\Bong\BongContent\</RootDirectory> 
    12       <LoggerRootDirectory>C:\MyTemp\JerePöntynen\Bong\Bong\Bong\</LoggerRootDirectory> 
    13       <IntermediateDirectory>C:\MyTemp\JerePöntynen\Bong\Bong\Bong\obj\x86\Debug\</IntermediateDirectory> 
    14       <OutputDirectory>C:\MyTemp\JerePöntynen\Bong\Bong\Bong\bin\x86\Debug\Content\</OutputDirectory> 
     11      <RootDirectory>C:\MyTemp\Jere2\Bong\Bong\BongContent\</RootDirectory> 
     12      <LoggerRootDirectory>C:\MyTemp\Jere2\Bong\Bong\Bong\</LoggerRootDirectory> 
     13      <IntermediateDirectory>C:\MyTemp\Jere2\Bong\Bong\Bong\obj\x86\Debug\</IntermediateDirectory> 
     14      <OutputDirectory>C:\MyTemp\Jere2\Bong\Bong\Bong\bin\x86\Debug\Content\</OutputDirectory> 
    1515    </Settings> 
    1616    <Assemblies> 
  • 2016/24/JereP/Bong/Bong/BongContent/obj/x86/Debug/BongContent.contentproj.FileListAbsolute.txt

    r7271 r7309  
    11C:\MyTemp\JerePöntynen\Bong\Bong\BongContent\obj\x86\Debug\BongContent.contentprojResolveAssemblyReference.cache 
     2C:\MyTemp\Jere2\Bong\Bong\BongContent\obj\x86\Debug\BongContent.contentprojResolveAssemblyReference.cache 
Note: See TracChangeset for help on using the changeset viewer.