Changeset 9782


Ignore:
Timestamp:
2018-06-15 12:00:40 (17 months ago)
Author:
otkoskin
Message:
 
Location:
2018/24/OTTOK/PalloPeli
Files:
5 added
8 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • 2018/24/OTTOK/PalloPeli/PalloPeli/Content/Content.mgcb

    r9745 r9782  
    3939/build:Player2.png 
    4040 
    41 #begin Player3.png 
     41#begin Spark.png 
    4242/importer:TextureImporter 
    4343/processor:TextureProcessor 
     
    4949/processorParam:MakeSquare=False 
    5050/processorParam:TextureFormat=Color 
    51 /build:Player3.png 
     51/build:Spark.png 
    5252 
    53 #begin Player4.png 
    54 /importer:TextureImporter 
    55 /processor:TextureProcessor 
    56 /processorParam:ColorKeyColor=255,0,255,255 
    57 /processorParam:ColorKeyEnabled=True 
    58 /processorParam:GenerateMipmaps=False 
    59 /processorParam:PremultiplyAlpha=True 
    60 /processorParam:ResizeToPowerOfTwo=False 
    61 /processorParam:MakeSquare=False 
    62 /processorParam:TextureFormat=Color 
    63 /build:Player4.png 
    64  
  • 2018/24/OTTOK/PalloPeli/PalloPeli/Content/obj/Windows/.mgcontent

    r9750 r9782  
    77    <File>C:/MyTemp/OttoK/OttoK/PalloPeli/PalloPeli/Content/Player1.png</File> 
    88    <File>C:/MyTemp/OttoK/OttoK/PalloPeli/PalloPeli/Content/Player2.png</File> 
    9     <File>C:/MyTemp/OttoK/OttoK/PalloPeli/PalloPeli/Content/Player3.png</File> 
    10     <File>C:/MyTemp/OttoK/OttoK/PalloPeli/PalloPeli/Content/Player4.png</File> 
     9    <File>C:/MyTemp/OttoK/OttoK/PalloPeli/PalloPeli/Content/Spark.png</File> 
    1110  </SourceFiles> 
    1211</SourceFileCollection> 
  • 2018/24/OTTOK/PalloPeli/PalloPeli/PalloPeli.cs

    r9750 r9782  
    55using Jypeli.Controls; 
    66using Jypeli.Widgets; 
     7using Jypeli.Effects; 
    78 
    89public class PalloPeli : PhysicsGame 
     
    1314    Image P1image = LoadImage("Player1"); 
    1415    Image P2image = LoadImage("Player2"); 
     16    bool saaLiikkua = true; 
     17    bool justBoosted = false; 
    1518 
    1619    Key[,] pelaajienNappaimet; 
     
    1821    IntMeter P1Points; 
    1922    IntMeter P2Points; 
     23    IntMeter P1BoostMeter; 
     24    IntMeter P2BoostMeter; 
     25    ExplosionSystem Plosion; 
     26    Label PlayerWins; 
    2027    public override void Begin() 
    2128    { 
    2229        SetWindowSize(1920, 1080, false); 
    23         IsFullScreen = true; 
     30        //IsFullScreen = true; 
    2431        Level.BackgroundColor = Color.Black; 
    25         P1Points = LuoPistelaskuri(new Vector(100, 0)); 
    26         P2Points = LuoPistelaskuri(new Vector(0, 100)); 
    27  
     32        P1Points = LuoPistelaskuri(new Vector(-400, 475)); 
     33        P2Points = LuoPistelaskuri(new Vector(400, 475)); 
     34         
    2835        laskurit = new IntMeter[] 
    2936        { 
    30             Mittari(Screen.Left + 25, Level.Top, new Color(229, 0, 0)), 
    31             Mittari(Screen.Right - 24, Level.Top, new Color(0, 115, 229)) 
     37            P1BoostMeter = Mittari(Screen.Left + 250, Level.Top + 80, new Color(229, 0, 0)), 
     38            P2BoostMeter = Mittari(Screen.Right - 250, Level.Top + 80, new Color(0, 115, 229)) 
    3239        }; 
    3340        LuoPelaajienNappaimet(); 
    34         Player1 = LuoPelaaja(P1image, 1, new Vector(-200, 0), "Player1"); 
    35         Player2 = LuoPelaaja(P2image, 2, Vector.Zero, "Player2"); 
    36          
    37         Timer.CreateAndStart(0.1, LisaaMittarinArvoa); 
     41        Player1 = LuoPelaaja(P1image, 1, new Vector(-400, 0), "Player1"); 
     42        Player2 = LuoPelaaja(P2image, 2, new Vector(400, 0), "Player2"); 
     43        AddCollisionHandler(Player1, Player2, Xplode); 
     44 
     45        PlayerWins = new Label(500, 100, "Test"); 
     46         
     47 
     48        Plosion = new ExplosionSystem(LoadImage("Spark"), 100) 
     49        { 
     50            MaxLifetime = 0.2, 
     51            MinLifetime = 0.05 
     52        }; 
     53        Plosion.MinScale = 30; 
     54        Plosion.MaxScale = 30; 
     55        Add(Plosion); 
     56 
     57        Timer.CreateAndStart(0.0125, LisaaMittarinArvoa); 
    3858        LuoReunat(); 
    3959    } 
     
    5070        Add(Player); 
    5171        AddCollisionHandler(Player, "seina", PelaajaTormasiSeinaan); 
     72         
    5273        LisaaPelaajanNappaimet(pelaajaNumero, Player); 
    5374        return Player; 
    5475    } 
     76    void Xplode(PhysicsObject peruna, PhysicsObject kana) 
     77    { 
     78        double nopeus = Player1.Velocity.Magnitude; 
     79        Plosion.AddEffect((Player1.X + Player2.X) / 2, (Player1.Y + Player2.Y) / 2, (int)nopeus); 
     80        if(justBoosted) 
     81        { 
     82            saaLiikkua = false; 
     83            Timer.SingleShot(0.5, delegate { saaLiikkua = true; } ); 
     84        } 
     85         
     86    } 
    5587    IntMeter LuoPistelaskuri(Vector paikka) 
    5688    { 
     
    6092            Position = paikka, 
    6193            TextColor = Color.White, 
    62             Color = Color.Blue, 
     94            Color = Color.Transparent, 
     95            Font = Font.DefaultLargeBold 
    6396        }; 
    6497        pisteNaytto.BindTo(PelaajanPisteet); 
    6598        Add(pisteNaytto); 
    6699        return PelaajanPisteet; 
     100    } 
     101 
     102    void ProcessInput(InputWindow ikkuna) 
     103    { 
     104        string vastaus = ikkuna.InputBox.Text; 
     105         
    67106    } 
    68107 
     
    99138            P1Points.AddValue(1); 
    100139        } 
     140 
     141        if(P1Points.Value == 10) 
     142        { 
     143            saaLiikkua = false; 
     144            Add(PlayerWins); 
     145            PlayerWins.TextScale = new Vector(4, 4); 
     146            PlayerWins.Text = "Player 2 Wins"; 
     147            PlayerWins.Color = Color.Transparent; 
     148            PlayerWins.TextColor = Color.Red; 
     149            PlayerWins.BorderColor = Color.Transparent; 
     150        } 
     151        if (P2Points.Value == 10) 
     152        { 
     153            saaLiikkua = false; 
     154            Add(PlayerWins); 
     155            PlayerWins.TextScale = new Vector(4, 4); 
     156            PlayerWins.Text = "Player 1 Wins"; 
     157            PlayerWins.Color = Color.Transparent; 
     158            PlayerWins.TextColor = Color.Blue; 
     159            PlayerWins.BorderColor = Color.Transparent; 
     160        } 
     161 
     162        Player1.Position = new Vector(-400, 0); 
     163        Player2.Position = new Vector(400, 0); 
     164        Player1.Velocity = new Vector(0, 0); 
     165        Player2.Velocity = new Vector(0, 0); 
     166        P1BoostMeter.Value = 0; 
     167        P2BoostMeter.Value = 0; 
    101168    } 
    102169 
     
    106173        boost = new IntMeter(0) 
    107174        { 
    108             MaxValue = 30 
     175            MaxValue = 160 
    109176        }; 
    110177        ProgressBar BoostMeter; 
    111         BoostMeter = new ProgressBar(300, 50) 
     178        BoostMeter = new ProgressBar(450, 75) 
    112179        { 
    113180            X = x, 
     
    116183         
    117184        BoostMeter.BindTo(boost); 
    118         BoostMeter.Angle = Angle.RightAngle; 
    119185        BoostMeter.BarColor = vari; 
    120186        BoostMeter.BorderColor = Color.Gray; 
     
    122188        return boost; 
    123189    } 
    124      
     190 
    125191    void LuoPelaajienNappaimet() 
    126192    { 
     
    136202        laskurit[0].AddValue(1); 
    137203        laskurit[1].AddValue(1); 
     204    } 
     205    void CreateConsole() 
     206    { 
     207        InputWindow Console = new InputWindow("Console"); 
     208        Console.TextEntered += ProcessInput; 
     209        Add(Console); 
    138210    } 
    139211 
     
    146218        Keyboard.Listen(pelaajienNappaimet[pelaajaNumero - 1, 3], ButtonState.Up, MovePlayer, null, new Vector(0, -1500), Player); 
    147219        Keyboard.Listen(pelaajienNappaimet[pelaajaNumero - 1, 4], ButtonState.Pressed, BoostPlayer, null, Player, laskurit[pelaajaNumero - 1]); 
    148          
     220        Keyboard.Listen(Key.F1, ButtonState.Pressed, CreateConsole, null); 
    149221    } 
    150222     
    151223    void BoostPlayer(PhysicsObject Player, IntMeter laskuri) 
    152224    { 
     225          
    153226        if (laskuri.Value != laskuri.MaxValue) return; 
    154         Player.Velocity = 3 * Player.Velocity; 
     227        justBoosted = true; 
     228        Timer.SingleShot(0.5, delegate { justBoosted = false; } ); 
     229        Player.Velocity = 3.5 * Player.Velocity; 
    155230        laskuri.Reset(); 
    156231    } 
     232 
    157233    void MovePlayer(Vector vektori, PhysicsObject Player) 
    158234    { 
    159         Player.Push(vektori); 
    160     } 
    161  
     235        if(saaLiikkua) 
     236        { 
     237            Player.Push(vektori); 
     238        } 
     239    } 
    162240} 
  • 2018/24/OTTOK/PalloPeli/PalloPeli/obj/x86/Debug/PalloPeli.csproj.FileListAbsolute.txt

    r9750 r9782  
    3333C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\Content\Player1.xnb 
    3434C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\Content\Player2.xnb 
    35 C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\Content\Player3.xnb 
    36 C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\Content\Player4.xnb 
    3735C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\PalloPeli.exe 
    3836C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\PalloPeli.pdb 
     
    6361C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\obj\x86\Debug\PalloPeli.exe 
    6462C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\obj\x86\Debug\PalloPeli.pdb 
     63C:\MyTemp\OttoK\OttoK\PalloPeli\PalloPeli\bin\Windows\Debug\Content\Spark.xnb 
Note: See TracChangeset for help on using the changeset viewer.