source: 2016/30/AleksiN/name/name/name/name.cs @ 8133

Revision 8133, 1.9 KB checked in by almajono, 3 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 name : PhysicsGame
10{
11
12    Image tire = LoadImage("tire");
13    PhysicsStructure tires = new PhysicsStructure();
14    public override void Begin()
15
16    {
17
18        IsFullScreen = true;
19
20        spawnTires();
21        points();
22        keys();
23       
24
25        Surface level = Surface.CreateBottom(Level, 30, 100, 10, 100);
26        Add(level);
27        Gravity = new Vector(0.0, -800.0);
28
29    }
30
31    void spawnTires()
32    {
33        PhysicsObject leftTire = new PhysicsObject(50.0, 50.0, Shape.Circle);
34        PhysicsObject rightTire = new PhysicsObject(50.0, 50.0, Shape.Circle);
35        leftTire.X = -65.0;
36        leftTire.Y = -250.0;
37        rightTire.X = 65.0;
38        rightTire.Y = -250.0;
39        tires = new PhysicsStructure(leftTire, rightTire);
40        Add(tires);
41    }
42    void keys()
43    {
44        Keyboard.Listen(Key.Left, ButtonState.Down, movement, null, new Vector(-2000, 0));
45        Keyboard.Listen(Key.Right, ButtonState.Down, movement, null, new Vector(2000, 0));
46        Keyboard.Listen(Key.Up, ButtonState.Down, angle, null, new Vector(-500, 0));
47        Keyboard.Listen(Key.Down, ButtonState.Down, angle, null, new Vector(500, 0));
48        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
49    }
50    void movement(Vector movement)
51    {
52        tires.Push(movement);
53    }
54    void angle(Vector angle)
55    {
56
57    }
58    IntMeter pointCounter;
59    void points()
60    {
61        pointCounter = new IntMeter(0);
62        Label pointLabel = new Label();
63        pointLabel.X = Screen.Left + 100;
64        pointLabel.Y = Screen.Top - 100;
65        pointLabel.TextColor = Color.Black;
66        pointLabel.Color = Color.White;
67        pointLabel.BindTo(pointCounter);
68        Add(pointLabel);
69    }
70
71}
Note: See TracBrowser for help on using the repository browser.