Skip to content
Snippets Groups Projects
Commit 6f1bb1c6 authored by Lehtinen Anni Henriikka's avatar Lehtinen Anni Henriikka
Browse files

Barkov asetettu seuraamaan pelaajaa

parent c4effa1f
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ using Jypeli.Widgets;
namespace Escape;
/// @author annilehtinen
/// @version 30.03.2025 / 2
/// @version 30.03.2025 / 3
/// <summary>
/// Peli, jossa pelaajaan tavoitteena on vältellä vastustajaa (Barkov) ja kerätä kiekkoja saadakseen pisteitä.
/// </summary>
......@@ -22,7 +22,7 @@ public class Escape : PhysicsGame
PhysicsObject player = AddPlayer(this);
SetControls(player);
PhysicsObject barkov = AddBarkov(this);
PhysicsObject barkov = AddBarkov(this, player);
AddCollisionHandler(player, barkov, Tackle);
AddCollisionHandler(player, "puck", CollectPuck);
......@@ -34,6 +34,7 @@ public class Escape : PhysicsGame
/// <summary>
/// Peliohjainten asettaminen pelaajalle
/// </summary>
/// <param name="player">Hahmo, jolle ohjainkomennot lisätään</param>
void SetControls(PhysicsObject player)
{
Keyboard.Listen(Key.Up, ButtonState.Down, MovePlayer, "Liikuta pelaajaa eteenpäin", player);
......@@ -55,6 +56,8 @@ public class Escape : PhysicsGame
{
PhysicsObject player = new PhysicsObject(40, 40);
player.Image = LoadImage("player.png");
player.X = -450;
player.Y = 0;
player.CanRotate = false;
player.LinearDamping = 0.95;
......@@ -67,13 +70,22 @@ public class Escape : PhysicsGame
/// Lisää "vihollisen" eli Barkovin pelikentälle
/// </summary>
/// <param name="game">Peli, johon hahmo lisätään</param>
/// <param name="target">Kohde, jota Barkov seuraa (pelaajan hahmo)</param>
/// <returns>Barkov</returns>
static PhysicsObject AddBarkov(PhysicsGame game)
static PhysicsObject AddBarkov(PhysicsGame game, PhysicsObject target)
{
PhysicsObject barkov = new PhysicsObject(50, 50);
barkov.Image = LoadImage("Barkov.png");
barkov.X = 60;
barkov.Y = -60;
barkov.X = 450;
barkov.Y = 0;
FollowerBrain barkovBrain = new FollowerBrain(target);
barkovBrain.DistanceFar = 600;
barkovBrain.Speed = 50;
barkovBrain.Active = true;
barkovBrain.TurnWhileMoving = true;
barkov.Brain = barkovBrain;
game.Add(barkov);
return barkov;
}
......@@ -105,6 +117,7 @@ public class Escape : PhysicsGame
/// <summary>
/// Pelaajan liikuttaminen eteenpäin (myöhemmin animaation kanssa)
/// </summary>
/// <param name="player">Hahmo, jota liikutetaan</param>
void MovePlayer(PhysicsObject player)
{
int playerSpeed = 10;
......
......@@ -41,6 +41,9 @@
<None Update="Content\puck3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Content\Barkov_peili.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
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