Hunt The Wumpus/CSharp: Difference between revisions

Content added Content deleted
(added c#)
 
m (small changes)
Line 96: Line 96:


// don't place hazards close to the starting room
// don't place hazards close to the starting room
bool TooClose(int room)
private bool TooClose(int room)
{
{
if (currRoom == room)
if (currRoom == room)
Line 245: Line 245:
}
}


void DrawPlayer(Graphics g)
private void DrawPlayer(Graphics g)
{
{
int x = rooms[currRoom, 0] + (roomSize - playerSize) / 2;
int x = rooms[currRoom, 0] + (roomSize - playerSize) / 2;
Line 259: Line 259:
}
}


void DrawStartScreen(Graphics g)
private void DrawStartScreen(Graphics g)
{
{
var brush = new SolidBrush(Color.FromArgb(0xDD, Color.White));
var brush = new SolidBrush(Color.FromArgb(0xDD, Color.White));
Line 270: Line 270:
}
}


void DrawRooms(Graphics g)
private void DrawRooms(Graphics g)
{
{
var fatLine = new Pen(Color.DarkGray, 2);
var fatLine = new Pen(Color.DarkGray, 2);
Line 307: Line 307:
}
}


void DrawMessage(Graphics g)
private void DrawMessage(Graphics g)
{
{
if (!gameOver)
if (!gameOver)
Line 324: Line 324:
if (messages.Count > 3)
if (messages.Count > 3)
{
{
g.DrawString("& " + messages[3], font, Brushes.Black, 20, Height - 57);
g.DrawString("& " + messages[3], font, Brushes.Black, 20, Height - 60);
}
}


Line 331: Line 331:
}
}


int[,] rooms = {{334, 20}, {609, 220}, {499, 540}, {169, 540}, {62, 220},
private int[,] rooms = {{334, 20}, {609, 220}, {499, 540}, {169, 540}, {62, 220},
{169, 255}, {232, 168}, {334, 136}, {435, 168}, {499, 255}, {499, 361},
{169, 255}, {232, 168}, {334, 136}, {435, 168}, {499, 255}, {499, 361},
{435, 447}, {334, 480}, {232, 447}, {169, 361}, {254, 336}, {285, 238},
{435, 447}, {334, 480}, {232, 447}, {169, 361}, {254, 336}, {285, 238},
{387, 238}, {418, 336}, {334, 393}};
{387, 238}, {418, 336}, {334, 393}};


int[,] links = {{4, 7, 1}, {0, 9, 2}, {1, 11, 3}, {4, 13, 2}, {0, 5, 3},
private int[,] links = {{4, 7, 1}, {0, 9, 2}, {1, 11, 3}, {4, 13, 2}, {0, 5, 3},
{4, 6, 14}, {7, 16, 5}, {6, 0, 8}, {7, 17, 9}, {8, 1, 10}, {9, 18, 11},
{4, 6, 14}, {7, 16, 5}, {6, 0, 8}, {7, 17, 9}, {8, 1, 10}, {9, 18, 11},
{10, 2, 12}, {13, 19, 11}, {14, 3, 12}, {5, 15, 13}, {14, 16, 19},
{10, 2, 12}, {13, 19, 11}, {14, 3, 12}, {5, 15, 13}, {14, 16, 19},