source: 2011/23/jovijoen/pong/pong/pong/Peli.cs @ 1911

Revision 1911, 1.9 KB checked in by jovijoen, 12 years ago (diff)
Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
9public class Peli : PhysicsGame
10{
11    Vector nopeusYlos = new Vector(0, 800);
12    Vector nopeusAlas = new Vector(0, -800);
13
14
15    PhysicsObject pallo;
16
17    PhysicsObject maila1;
18    PhysicsObject maila2;
19
20
21    public override void Begin()
22    {
23        LuoKentta();
24
25
26        Aloitapeli();
27
28        // TODO: Kirjoita ohjelmakoodisi tähän
29
30
31
32
33
34
35    }
36    void LuoKentta()
37    {
38        pallo = new PhysicsObject(50.0, 50.0);
39        pallo.Shape = Shape.Circle;
40        pallo.Color = Color.YellowGreen;
41        pallo.X = -200.0;
42        pallo.Y = 0;
43        Add(pallo);
44
45        LuoMaila
46        Maila1(Level.Left + 200.0, 0.0);
47        Maila2(Level.Right - 200.0, 0.0);
48
49
50        pallo.Restitution = 1.0;
51        Level.CreateBorders(1.0, false);
52        Level.BackgroundColor = Color.Black;
53        ;
54
55        Camera.ZoomToLevel();
56
57
58
59
60    }
61    void Aloitapeli()
62    {
63        Vector impulssi = new Vector(1000.0, 00);
64        pallo.Hit(impulssi);
65        PhysicsObject maila2 = PhysicsObject.CreateStaticObject(20.0, 100.0);
66     
67       
68    }
69        PhysicsObject LuoMaila(double x, double y)
70    {
71        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);
72        maila.Shape = Shape.Rectangle;
73        maila.X = X;
74        maila.Y = y;
75        maila.Restitution = 1.0;
76        Add(maila);
77        return maila;
78
79
80    }
81    void AsetaOhjaimet()
82    {
83        Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös");
84        Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null);
85        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu");
86
87
88    }
89
90    void AsetaNopeus(PhysicsObject maila, Vector nopeus)
91    {
92        maila.Velocity = nopeus;
93    }
94}
95
96
Note: See TracBrowser for help on using the repository browser.