Skip to content

Commit

Permalink
Gameengine hinzugefügt
Browse files Browse the repository at this point in the history
  • Loading branch information
janekf committed Apr 18, 2012
1 parent 30be6dd commit bc27ccc
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
99 changes: 99 additions & 0 deletions Kata Pacman/Source/Pacman.Engine/Game.cs
@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pacman.Engine
{
class Game
{
readonly IControllerDevice _controllerDevice;
Pacman _pacman;
bool isRunning = true;

public Game(IControllerDevice controllerDevice)
{
_controllerDevice = controllerDevice;

InitializeGame();
}

void InitializeGame()
{
_pacman = new Pacman();
_controllerDevice.Hoch = () => _pacman.Blickrichtung = Blickrichtungen.NachOben;
_controllerDevice.Runter = () => _pacman.Blickrichtung = Blickrichtungen.NachUnten;
_controllerDevice.Links = () => _pacman.Blickrichtung = Blickrichtungen.NachLinks;
_controllerDevice.Rechts = () => _pacman.Blickrichtung = Blickrichtungen.NachRechts;
}

public void Run()
{
while (isRunning)
{
// Magic um Position zu ermitteln
var currentPacmanPosition = _pacman.Position;

var newPacmanPosition = MoveEngine.ComputeNextPacmanPosition(currentPacmanPosition);

_pacman.BewegeNach(newPacmanPosition);
_pacman.Blickrichtung = Spielsteuerung.AktuelleRichtung;
}
}

internal class Spielsteuerung
{
public Spielsteuerung()
{
}

public static Blickrichtungen AktuelleRichtung { get; private set; }
}
}

internal class MoveEngine
{
public static Position ComputeNextPacmanPosition(Position currentPacmanPosition)
{
throw new NotImplementedException();
}
}

internal interface IControllerDevice
{
Action Hoch { get; set; }
Action Runter { get; set; }
Action Links { get; set; }
Action Rechts { get; set; }
}

internal class Pacman
{
public Pacman()
{

}

public void BewegeNach(Position position)
{
Position = position;
}

public Position Position { get; private set; }
public Blickrichtungen Blickrichtung { get; set; }
}

internal enum Blickrichtungen
{
NachOben,
NachUnten,
NachLinks,
NachRechts
}

internal class Position
{
public int X { get; set; }
public int Y { get; set; }
}
}
1 change: 1 addition & 0 deletions Kata Pacman/Source/Pacman.Engine/Pacman.Engine.csproj
Expand Up @@ -40,6 +40,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Game.cs" />
<Compile Include="IPlayerInfo.cs" />
<Compile Include="PlayerInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down

0 comments on commit bc27ccc

Please sign in to comment.