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

Revision 1723, 2.0 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        Maila1(Level.Left + 200.0, 0.0);
46        Maila2(Level.Right - 200.0, 0.0);
47
48
49        pallo.Restitution = 1.0;
50        Level.CreateBorders(1.0, false);
51        Level.BackgroundColor = Color.Black;
52        ;
53
54        Camera.ZoomToLevel();
55
56
57
58
59    }
60    void Aloitapeli()
61    {
62        Vector impulssi = new Vector(1000.0, 00);
63        pallo.Hit(impulssi);
64        PhysicsObject maila2 = PhysicsObject.CreateStaticObject(20.0, 100.0);
65     
66        PhysicsObject LuoMaila( double x, double y )
67    }
68    void LuoMaila(double X, double y)
69    {
70        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0);
71        maila.Shape = Shape.Rectangle;
72        maila.X = X;
73        maila.Y = y;
74        maila.Restitution = 1.0;
75        Add(maila);
76        return maila;
77
78
79    }
80    void AsetaOhjaimet()
81    {
82        Keyboard.Listen(Key.A, ButtonState.Down, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös");
83        Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null);
84        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu");
85
86
87    }
88
89    void AsetaNopeus(PhysicsObject maila, Vector nopeus)
90    {
91        maila.Velocity = nopeus;
92    }
93}
94
95
Note: See TracBrowser for help on using the repository browser.