Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
janekf
committed
Apr 18, 2012
1 parent
30be6dd
commit bc27ccc
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters