Skip to content
Snippets Groups Projects
Commit a603fcab authored by Ranta Veeti's avatar Ranta Veeti
Browse files

ekoja tekemisiä peliin

parent 422e8dd8
No related branches found
No related tags found
No related merge requests found
using System;
using System.Collections.Generic;
using System.Drawing;
using Jypeli;
using Jypeli.Assets;
using Jypeli.Controls;
using Jypeli.Widgets;
using Color = Jypeli.Color;
namespace HT;
public class HT : PhysicsGame
public class Ht : PhysicsGame
{
PhysicsObject broidi;
public override void Begin()
{
// Kirjoita ohjelmakoodisi tähän
LuoKentta();
AsetaOhjaimet();
void LuoKentta()
{
broidi = new PhysicsObject(50, 50);
broidi.Shape = Shape.Rectangle;
broidi.Color = Color.Red;
Add(broidi);
}
void AsetaOhjaimet()
{
Keyboard.Listen(Key.W, ButtonState.Down, Liikuttaa, "Pelaaja 1: Liikuta Broidia ylös", new Vector (0.0, 300.0));
Keyboard.Listen(Key.W, ButtonState.Released, Liikuttaa, null, Vector.Zero);
Keyboard.Listen(Key.S, ButtonState.Down, Liikuttaa, "Pelaaja 1: Liikuta Broidia alas", new Vector (0.0, -300.0));
Keyboard.Listen(Key.S, ButtonState.Released, Liikuttaa, null, Vector.Zero);
Keyboard.Listen(Key.D, ButtonState.Down, Liikuttaa, "pelaaja 2: Liikuta Broidia ylös", new Vector(300.0, 0.0));
Keyboard.Listen(Key.D, ButtonState.Released, Liikuttaa, null, Vector.Zero);
Keyboard.Listen(Key.A, ButtonState.Down, Liikuttaa, "Pelaaja 2: Liikuta Broidia alas", new Vector(-300, 0.0));
Keyboard.Listen(Key.A, ButtonState.Released, Liikuttaa, null, Vector.Zero);
}
void Liikuttaa(Vector nopeus)
{
broidi.Velocity = nopeus;
}
Level.Background.Color = new Color(189, 183, 107);
PhoneBackButton.Listen(ConfirmExit, "Lopeta peli");
Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");
}
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ namespace HT
[STAThread]
static void Main()
{
using var game = new HT();
using var game = new Ht();
game.Run();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment