ID:36721
 
Link: http://members.byond.com/DDSR/files/maplib.exe

I had some time before my "Doctor Appointment" was over and I had to go back to work. I just fired this up because I had the itch to code something. it isn't that good, the arrays could be better laid out, and the wall detection more sophisticated, but then again. I'm lazy.

EDIT: I suppose the input could be handled much better too, now that I look back on it.

using System;

namespace maplib
{
class main
{
public static void Main(string[] args){
loopClass loop = new loopClass();
loop.gameLoop();
}
}


class loopClass{

string[,] map = new string[20,20];
int playaX=0;
int playaY=0;
bool playing = true;
int[] prevloc = new int[2];
int[] loc = new int[2];

public void gameLoop(){
makeMap();
while(playing==true){
drawMap();
getInput();
validate();
}
}

public void makeMap(){
for(int a=0;a<20;a++){
for(int i=0;i<20;i++){
map[a,i]="#";
}
}
}

public void drawMap(){
Console.Clear();
Console.WriteLine("X: " + playaX);
Console.WriteLine("Y: " + playaY);
for(int a=0;a<20;a++){
if(a<=20){
Console.WriteLine("");
}
for(int i=0;i<20;i++){
if((a==playaX)&&(i==playaY)){
Console.Write("@");
}
else{
Console.Write(map[a,i]);
}
}
}
}

public void getInput(){
Console.Write("\n\ndir (n,e,s,w): ");
string input = Console.ReadLine();
prevloc[0]=playaY;
prevloc[1]=playaX;
if(input=="n"){
playaX--;
}
else if(input=="e"){
playaY++;
}
else if(input=="s"){
playaX++;
}
else if(input=="w"){
playaY--;
}
loc[0]=playaY;
loc[1]=playaX;
}

public void validate(){
if((loc[0]<0||loc[0]>19)||(loc[1]<0||loc[1]>20)){
playaY=prevloc[0];
playaX=prevloc[1];
}
}
}
}
It is in C#, by the way.

Total code time was about an hour, and thats because I was looking up stuff for console.keydown, but it doesnt exist. =(.
"playa"? :P

Funnily enough I made something similar to this in VB (=/) in my programming class.
Elation wrote:
"playa"? :P

Funnily enough I made something similar to this in VB (=/) in my programming class.

ahe@VBprogrammingClass