source: 2012/26/AleksanteriV/Water wey/Water wey/Water wey/Water_wey.cs @ 3699

Revision 3699, 2.8 KB checked in by alvirmas, 11 years ago (diff)

Talletus.

Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
9public class Water_wey : PhysicsGame
10{
11    //------------------------------------------------------------- PhysicsObject
12    PhysicsObject vesi;
13        PhysicsObject pelaaja;
14        double voima = 100000;
15
16    public override void Begin()
17    {
18        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
19        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
20        // Keyboard.Listen(Key.Right, ButtonState.Pressed, Gravity, new Vector(-100, 0);
21       
22       
23       
24        luopelaaja();
25        lisaaohjaimet();
26
27        Gravity = new Vector(0, -100);
28        Level.CreateBorders();
29        int i = 0;
30
31        while (i < 1000)
32       {
33           vesi = new PhysicsObject(10, 10);
34           vesi.Shape = Shape.Circle;
35           vesi.Color = Color.Blue;
36           vesi.Mass = 0.5;
37           vesi.X = RandomGen.NextDouble(Level.Left, Level.Right);
38           vesi.Y = RandomGen.NextDouble(Level.Bottom, Level.Top);
39          Add(vesi);
40          i++;
41        }
42    }
43    //-----------------------------------------------------------------------Aliohjelmat
44        void luopelaaja()//Vector paikka, double leveys, double korkeus
45    {
46        pelaaja = new PhysicsObject(50, 50);
47        //pelaaja.Shape = Shape.;
48        //pelaaja.Position = paikka;
49        pelaaja.Mass = 100;
50        pelaaja.Image = LoadImage("Untitled");
51        //(pelaaja.Tag = "";)
52        Add(pelaaja);
53       
54
55        // AddCollisionHandler(pelaaja, "palikka", PysaytaPelaaja);
56    }
57        void lisaaohjaimet()
58        {
59            Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-voima, 0));
60            Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(voima, 0));
61            Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, voima));
62            Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -voima));
63
64            //Keyboard.Listen(Key.Left, ButtonState.Released, PysaytaPelaajaX, null);
65            //Keyboard.Listen(Key.Right, ButtonState.Released, PysaytaPelaajaX, null);
66            //Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaPelaajaY, null);
67            //Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaPelaajaY, null);
68        }
69    void LiikutaPelaajaa(Vector liikuttaja)
70    {
71        //if (pelaajia > 2)
72        //{
73        //    liikuttaja = liikuttaja + Vector.FromLengthAndAngle(20, liikuttaja.Angle);
74        //}
75        pelaaja.Push(liikuttaja);
76        pelaaja.Angle = liikuttaja.Angle + Angle.FromDegrees(90);
77    }
78}
Note: See TracBrowser for help on using the repository browser.