source: 2010/24/timisahe/Ympyroita/Peli.cs @ 10337

Revision 898, 1.6 KB checked in by timisahe, 13 years ago (diff)
Line 
1using System;
2using Jypeli;
3using Jypeli.ScreenObjects;
4using Jypeli.Assets;
5
6public class Peli : PhysicsGame
7{
8
9    protected override void Begin()
10    {
11
12        Gravity = new Vector(0.0, -8.0);
13        for (int i = 0; i < 500; i++)
14        {
15         PiirraYmpyra();
16        }
17
18        Level.CreateBorders(0.5, false);
19        Level.BackgroundColor = Color.SkyBlue;
20
21        LisaaNappaimet();
22    }
23
24    void PiirraYmpyra()
25    {
26        PhysicsObject pallo = new PhysicsObject(20.0,20.0, Shapes.Circle);
27        pallo.X = RandomGen.NextInt( -300,300 );
28        pallo.Y = RandomGen.NextInt(-300, 300);
29        pallo.Color  = RandomGen.NextColor();
30
31        Add(pallo);
32        Vector impulssi = new Vector(900.0, 0.0);
33        pallo.Hit(impulssi);
34        pallo.Restitution = 0.5;
35
36    }
37    void PiirraUhri(double x,double y)
38    {
39        PhysicsObject uhri = PhysicsObject.CreateStaticObject(20.0, 20.0,Shapes.Circle);
40        uhri.Color = Color.DarkRed;
41        uhri.Restitution = 1.0;
42        uhri.X =x;
43        uhri.Y =y;
44        Add(uhri);
45    }
46
47    void LisaaNappaimet()
48    {
49        Keyboard.Listen(Key.Left, ButtonState.Pressed, VaihdaPainovoimaa, null, new Vector(-1000,0));
50        Keyboard.Listen(Key.Right, ButtonState.Pressed, VaihdaPainovoimaa, null, new Vector(1000, 0));
51        Keyboard.Listen(Key.Down, ButtonState.Pressed, VaihdaPainovoimaa, null, new Vector(0, -1000));
52        Keyboard.Listen(Key.Up, ButtonState.Pressed, VaihdaPainovoimaa, null, new Vector(0, 1000));
53    }
54
55    void VaihdaPainovoimaa(Vector suunta)
56    {
57        Gravity = suunta;
58    }
59
60   
61   
62    }
63
64
65
66
67
68
69   
70
71
Note: See TracBrowser for help on using the repository browser.