source: 2012/30/JereK/FysiikkaPeli4/FysiikkaPeli4/FysiikkaPeli4/FysiikkaPeli4.cs @ 3702

Revision 3702, 2.1 KB checked in by anlakane, 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 FysiikkaPeli4 : PhysicsGame
10{
11    PhysicsObject pelaaja;
12    PhysicsObject pelaaja2;
13    Image ukeli1 = LoadImage("pelaaja1");
14    Image taustakuva = LoadImage("tausta");
15    Image ukeli2 = LoadImage("pelaaja2");
16    public override void Begin()
17    {
18        PhysicsObject pallo = new PhysicsObject(40, 40);
19        Add(pallo);
20        pallo.Shape = Shape.Circle;
21
22        pelaaja = new PhysicsObject(50, 50);
23        Add(pelaaja);
24        pelaaja.Image = ukeli1;
25        pelaaja2 = new PhysicsObject(50, 50);
26        Add(pelaaja2);
27        pelaaja2.Image = ukeli2;
28
29        pelaaja.X = -200.0;
30        pelaaja.Y = 0.0;
31
32        pelaaja2.X = 200.0;
33        pelaaja2.Y = 0.0;
34
35
36        Keyboard.Listen(Key.Left, ButtonState.Down,
37  LiikutaPelaajaa, null, new Vector(-300, 0));
38        Keyboard.Listen(Key.Right, ButtonState.Down,
39          LiikutaPelaajaa, null, new Vector(300, 0));
40        Keyboard.Listen(Key.Up, ButtonState.Down,
41          LiikutaPelaajaa, null, new Vector(0, 300));
42        Keyboard.Listen(Key.Down, ButtonState.Down,
43          LiikutaPelaajaa, null, new Vector(0, -300));
44
45        Keyboard.Listen(Key.A, ButtonState.Down,
46LiikutaPelaaja2, null, new Vector(-300, 0));
47        Keyboard.Listen(Key.D, ButtonState.Down,
48          LiikutaPelaaja2, null, new Vector(300, 0));
49        Keyboard.Listen(Key.W, ButtonState.Down,
50          LiikutaPelaaja2, null, new Vector(0, 300));
51        Keyboard.Listen(Key.S, ButtonState.Down,
52          LiikutaPelaaja2, null, new Vector(0, -300));
53
54        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu");
55
56        Level.CreateBorders(false);
57        Level.Background.Image = taustakuva;
58        Camera.ZoomToLevel();
59
60        pelaaja.CanRotate = false;
61        pelaaja2.CanRotate = false;
62
63    }
64    void LiikutaPelaajaa(Vector vektori)
65    {
66        pelaaja.Push(vektori);
67    }
68    void LiikutaPelaaja2(Vector vektori)
69    {
70        pelaaja2.Push(vektori);
71    }
72}
73
74
Note: See TracBrowser for help on using the repository browser.