source: 2015/24/ValtteriV/Happy Balloon Jump/Happy Balloon Jump/Happy Balloon Jump/Happy_Balloon_Jump.cs @ 5988

Revision 5988, 2.6 KB checked in by vasaenvi, 6 years ago (diff)

Happy balloon jump.

Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8using Jypeli.WP7;
9
10public class Happy_Balloon_Jump : PhysicsGame
11{
12    public override void Begin()
13    {
14        CreateLevel();
15        Borders();
16        Player();
17        Player2();
18
19        // Kirjoita ohjelmakoodisi tähän
20
21        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
22    }
23    void Player()
24    {
25        PhysicsObject player = new PhysicsObject(120.0, 110.0);
26        Add(player);
27        player.Image = LoadImage("ThePlayer");
28        player.Shape = Shape.Circle;
29        player.Position = new Vector(Level.Left + Screen.Width, 0.0);
30
31        TouchPanel.Listen(ButtonState.Down, MovePlayer, "Moves the balloon", player);
32        Camera.Position = player.Position;
33        Camera.Follow(player);
34        Camera.FollowsY = false;
35    }
36
37    void CreateLevel()
38    {
39        /*PhysicsObject grass = PhysicsObject.CreateStaticObject(410.0, 260.0);
40        Add(grass);
41        grass.Image = LoadImage("Grass");*/
42        Level.Size = new Vector(Screen.Size.Y, Screen.Size.X);
43        Level.Width *= 5;
44        //Camera.ZoomTo(new Vector(Level.Left, Level.Bottom - 40), new Vector(Screen.Right, Screen.Top));
45
46        //Camera.ZoomFactor = 0.3;
47
48        Surface alaReuna = Surface.CreateBottom(Level, 20, 40, 20);
49        // alaReuna.Position += new Vector(0.0, alaReuna.Height);
50        Add(alaReuna);
51        Surface vasenReuna = Surface.CreateLeft(Level, 1, 1, 2);
52        vasenReuna.Color = Color.Transparent;
53        Add(vasenReuna);
54
55        Gravity = new Vector(0, -100);
56
57        Camera.ZoomTo(Level.Left, Level.Bottom, Camera.ScreenToWorld(new Vector(Screen.Right, 0.0)).X, Camera.ScreenToWorld(new Vector(0.0, Screen.Top)).Y);
58
59        GameObject background = new GameObject(LoadImage("BlueSky"));
60        background.Width = Level.Width * 1.2;
61        background.Height = Level.Height * 1.2;
62        background.Position = new Vector(Level.Left + Screen.Width, 0.0);
63        Layers[-3].RelativeTransition = new Vector(0.0, 0.0);
64        Add(background, -3);
65    }
66    void MovePlayer(Touch kosketus, PhysicsObject player)
67    {
68        player.Push(kosketus.MovementOnWorld * 10);
69    }
70    void Borders()
71    {
72        Surface oikeaReuna = Surface.CreateRight(Level, 1, 1, 2);
73        oikeaReuna.Color = Color.Transparent;
74        Add(oikeaReuna);
75    }
76    void Player2()
77    {
78        PhysicsObject player2 = new PhysicsObject(120.0, 110);
79        Add(player2);
80
81    }
82
83}
Note: See TracBrowser for help on using the repository browser.