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

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