I'm a beginner with C# (and programming in general) and decided I wanted to overhaul my Dungeon Crawler project for school and instead of using a predetermined map generate a random one, as I have some Java experience and I'm pretty fresh to c# I thought it would be smart to use the Java code I already understand to write something in C# based on the Java code but I've ran into a problem.
Currently I'm trying to write this code: http://rosettacode.org/wiki/Maze_generation#Java In c# which is going pretty well
Only the
private void generateMaze(int cx, int cy) {
And
private enum DIR {
parts don't work at all, it already creates a fully filled map now, but it still has to add the paths, after some searching I found that C# Enums simply don't have the same functionality as Java ones, how do I "convert" the Enum Dir part and generateMaze to c# code?
Currently I have this: Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DungeonCrawler
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Wide?");
int x = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Height?");
int y = Convert.ToInt32(Console.ReadLine());
MazeGen maze = new MazeGen(x, y);
maze.display();
Console.ReadKey();
}
}
}
MazeGen.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DungeonCrawler
{
public class MazeGen
{
private int x;
private int y;
private int[,] maze;
public MazeGen(int x, int y)
{
this.x = x;
this.y = y;
maze = new int[this.x, this.y];
generateMaze(0, 0);
}
public void display()
{
for (int i = 0; i < y; i++)
{
//Bovenkant
for (int j = 0; j < x; j++)
{
Console.Write((maze[j, i] & 1) == 0 ? "+---" : "+ ");
}
Console.WriteLine("+");
//Linkerkant
for (int j = 0; j < x; j++)
{
Console.Write((maze[j, i] & 8) == 0 ? "| " : " ");
}
Console.WriteLine("|");
}
//Onderkant
for (int j = 0; j < x; j++)
{
Console.Write("+---");
}
Console.WriteLine("+");
}
private void generateMaze(int cx, int cy)
{
}
private static Boolean between(int v, int upper)
{
return (v >= 0) && (v < upper);
}
private enum DIR
{
}
}
}