Anyone studying C# programming?

Discussion in 'General Chat' started by Emperor, Feb 17, 2007.

  1. #1
    I have a small problem that would require some help from someone with C# programming skills. The problem is that for my course which I’m currently attending I need to program a Game called Sokoban. If that isn’t enough the program would have to include the Algorithm to explain how it works. Has anyone here ever done this as their course work? Can someone help me with this??? Would really appreciate it :D
     
    Emperor, Feb 17, 2007 IP
  2. JZY

    JZY Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try to view Sokoban YASC project
    at the sourceforge * net
    but their open source code is marked as Delphi/Kylix
    or view
    Sokoban Tux on Java
     
    JZY, Feb 17, 2007 IP
  3. Emperor

    Emperor Guest

    Messages:
    4,821
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The problem is that I need to write the program in C# and have little experience with that language. Trying to port from other languages will be virtually impossible to me.
     
    Emperor, Feb 17, 2007 IP
  4. Mirage

    Mirage Active Member

    Messages:
    204
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    58
    #4
    If you know C++ or Java, there are a lot of similarities...especially with Java. Not identical, mind you...but similar. If that helps at all...maybe a Java guru can give you a hand.
     
    Mirage, Feb 17, 2007 IP
  5. kashem

    kashem Banned

    Messages:
    1,250
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I did some programming in vc#. Not sure about the game. I feel for you if you reaseach and try yourself it will be good for you as there will be somany things you will learn when you will try ,

    try to do yourself , ask for specific problem , then you will get right kind of suggestions
     
    kashem, Feb 17, 2007 IP
  6. Emperor

    Emperor Guest

    Messages:
    4,821
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The problem is that I don’t even know where to start. I don’t have a lot of time since I work and study at the same time so was looking for someone that might have some experience with this sort of thing…
     
    Emperor, Feb 17, 2007 IP
  7. Emperor

    Emperor Guest

    Messages:
    4,821
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I’ve been searching all over the net but haven’t found anything that could help me…. I really don’t know what to do now… Does anyone know of any good programming forums??? Maybe I’ll try that…
     
    Emperor, Feb 17, 2007 IP
  8. Anita

    Anita Peon

    Messages:
    1,142
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Are you looking for someone to write this for you, or someone to help? To me, it sounds like you've skipped over a few (or many) lectures, since you're asking where to start.

    You need to do a high-level design first, then if you're very unfamiliar with programming do a detaled design (e.g. an outline) of the code structure.

    Once you have the design, filling in the code isn't that difficult. But for an inexperienced programmer, you'll need at least a day to code the backend and another day to code the graphics (assuming VERY simple windows GUI images/buttons/etc will do). Depending on the teachers requirements, your time involved could be more.

    If you don't have that amount of time, you should just be upfront and ask someone to code it for you, but don't mention it's for a class. On rentacoder.com, some people will code things like this for under $100 (if you go with the cheapest bid, don't expect the best code in return though).

    Anita :)
     
    Anita, Feb 17, 2007 IP
  9. Emperor

    Emperor Guest

    Messages:
    4,821
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #9
    What I’m actually looking for is for some help or guidance on where to start and where to find information. The game would be text based so there’s no need for graphics and such, but for me it’s still quite a task. Since there are so many Computer Science students on this forum I thought some could help me since this game is commonly used as training for beginners.
     
    Emperor, Feb 17, 2007 IP
  10. Anita

    Anita Peon

    Messages:
    1,142
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    0
    #10
    How much information has the teacher provided for you? I think the problem is that you are looking at this as a C# problem, and not a programming problem. This is how I would tackle the problem:

    1) Define the high level requirements
    2) Determine the algorithms required for controlling gameplay (paper and pencil it, no programming yet)
    3) Define classes and memory structures for storing game state
    4) Hash out any remaining details
    5) Program it

    For a beginner, your best friend is a piece of paper or a whiteboard when first designing a program. That way you don't get too bogged down in the language (which is really immaterial).

    Anita :)
     
    Anita, Feb 17, 2007 IP
  11. kashem

    kashem Banned

    Messages:
    1,250
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #11
    My suggestion is rather than doing to whole project , you try to build somthing that does small things.

    If the project seems to you duanting , you could take it later , not sure it will hurt your course. Try to do small things first


    Some programmer forums

    vbforums.com
    vbcity.com
    codeproject.com
     
    kashem, Feb 18, 2007 IP
  12. Emperor

    Emperor Guest

    Messages:
    4,821
    Likes Received:
    180
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Well this is what I got so far :confused:


    #include <stdio.h>
    
    void moverEsquerda(int areaJogo[19][19], int coluna, int linha);
    void moverDireita(int areaJogo[19][19], int coluna, int linha);
    void moverCima(int areaJogo[19][19], int coluna, int linha);
    void moverBaixo(int areaJogo[19][19], int coluna, int linha);
    void apresentarAreaJogo(int areaJogo[19][19]);
    int obterNumeroCaixas(int areaJogo[19][19]);
    
    int obterNumeroCaixas(int areaJogo[19][19])
    {
    	int numeroCaixas = 0;
    	int i,j; 
    	for(i=0; i < 19; i=i++)
    	{
    		for(j=0; j<19; j++)
    		{
    			if(areaJogo[j][i] == 2)numeroCaixas++;
    		}
    	}
    	return(numeroCaixas);
    }
    
    void apresentarAreaJogo(int areaJogo[19][19])
    {
    	int i,j; 
    	for(i=0; i < 19; i=i++)
    	{
    		for(j=0; j<19; j++)
    		{
    			printf("%d", areaJogo[j][i]);
    		}
    		printf("%\n");
    	}
    }
    
    void moverEsquerda(int areaJogo[19][19], int coluna, int linha)
    {
    	if(areaJogo[coluna-1][linha] == 0)
    	{
    		areaJogo[coluna-1][linha] = 1;
    		areaJogo[coluna][linha] = 0;
    	}
    }
    
    void moverDireita(int areaJogo[19][19], int coluna, int linha)
    {
    	if(areaJogo[coluna+1][linha] == 0)
    	{
    		areaJogo[coluna+1][linha] = 1;
    		areaJogo[coluna][linha] = 0;
    	}
    }
    
    void moverCima(int areaJogo[19][19], int coluna, int linha)
    {
    	if(areaJogo[coluna][linha-1] == 0)
    	{
    		areaJogo[coluna][linha-1] = 1;
    		areaJogo[coluna][linha] = 0;
    	}
    }
    
    void moverBaixo(int areaJogo[19][19], int coluna, int linha)
    {
    	if(areaJogo[coluna][linha+1] == 0)
    	{
    		areaJogo[coluna][linha+1] = 1;
    		areaJogo[coluna][linha] = 0;
    	}
    }
    
    int main(int argc, char *argv[])
    {
    	int areaJogo[19][19] = {
    	{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,},
    	{9,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,2,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9},
    	{9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9},
    	};
    	
    	int coluna = 1;
    	int linha = 1;
    
    	int caixas = obterNumeroCaixas(areaJogo);
    	
    	int opcao = -1;
    	
    	do
    	{
    		if(opcao == 0)
    		{
    			return;
    		}
    		else if(opcao == 1)
    		{
    			moverEsquerda(areaJogo, coluna, linha);
    			coluna = coluna-1;
    		}
    		else if(opcao == 2)
    		{
    			moverDireita(areaJogo, coluna, linha);
    			coluna = coluna+1;
    		}
    		else if(opcao == 3)
    		{
    			moverCima(areaJogo, coluna, linha);
    			linha = linha-1;
    		}
    		else if(opcao == 4)
    		{
    			moverBaixo(areaJogo, coluna, linha);
    			linha = linha+1;
    		}
    		
    		apresentarAreaJogo(areaJogo);
    
    		printf("1 - Mover Esquerda\n");
    		printf("2 - Mover Direita\n");
    		printf("3 - Mover Cima\n");
    		printf("4 - Mover Baixo\n");
    		printf("0 - Sair\n");
    		
    		fflush(stdin);
    		scanf("%d", &opcao);
    
    	}while(caixas > 0);
    }
    Code (markup):

    Can someone help me with a few problems I'm having?
     
    Emperor, Feb 24, 2007 IP