GPWiki.org
GPWiki.org
It is currently Thu May 23, 2013 6:04 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: stratego like game
PostPosted: Thu Feb 26, 2009 10:31 pm 
Me and 3 otheer people are making game for a programming class at school, and are trying to make a game like stratego, any help would be aprecheated.


Top
  
 
 Post subject:
PostPosted: Thu Feb 26, 2009 10:47 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Good to hear it. (I always wish there were these sorts of assignments back when I was in school ... but, no -- we were busy learning how to chisel rocks into these new-fangled roundish things that made it easier to move goods around. ;))

Once you've got your design figured out and run into some specific troubles with coding it, give us bump and let us know where you could use a push in the right direction.

Cheers,
-Bryk

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 1:55 am 
thats a bit of an issue, im in high school and most of us in the class, including myself, knew nothing about programming beforehand, since this class was just implemented this year.


Top
  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 2:07 am 
and i belive we are using VB 2008, we have already gotten a layout done, whiich is a 10 by 10 grid, between the 4 of us, we have very little knowlegde of coding beyond the basics(although we have made some progress in researching).


Top
  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 2:40 am 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Here's where I'll give the obligatory "we won't be doing your homework for you" ... but some of us will help you in your research if it looks like you're making something of an effort.

So, what sort of class is it? Is it a beginning computer programming class? How many weeks into it are you?

-Bryk

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 2:47 am 
yeah, its a beginning programming class, we are in our second semester right now, and were using visual basic 2008 in it


Top
  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 3:01 am 
Dexterous Droid
User avatar

Joined: Fri Dec 24, 2004 8:13 pm
Posts: 3769
Location: Michigan, 'US' of 'A'. Below Canada.
Making even a simple game like stratego assumes you know how to program first and know the basic concepts. The best part of programming is tackling the problem first so you can try it your own way before reading the rest of this. If you get stuck look at the rest of what I've written for some ideas.

I'm going to take a long shot and assume that you haven't learned object oriented programming? If you have then this will be much easier.

If you do this via the console I'd use a multidimensional array (meaning a 2D array). "Dim gameBoard(10, 10) As Cell" (where Cell is a class). In this way you can represent all the units in the game as character symbols on the board.

You can even set the color of the console text! So each player would either be red or blue.
http://addressof.com/blog/articles/227.aspx
Someone at codeproject wrote a wrapper for it.
http://www.codeproject.com/KB/vb/color_console.aspx

The game would begin by asking the player where to place the pieces and the player would respond with an x and y value in the grid map for each unit. Then the same would be asked for the other player (unless there's an AI). Rendering the grid map would be easy. You'd use a nested for loop like:
(C# code)
Code:
using System;
using System.Text;

namespace Stratego
{
    class Program
    {
        // W = water
        static Cell[,] gameBoard = new Cell[10, 10];

        static void Main(string[] args)
        {
            ResetGameBoard();
            DrawBoard();
            Console.ReadKey();
        }

        public struct Cell
        {
            public char character;
            int playerNumber;
        }

        static void ResetGameBoard()
        {
            for (int y = 0; y < 10; ++y)
            {
                for (int x = 0; x < 10; ++x)
                {
                    gameBoard[x, y].character = ' ';
                }
            }
            gameBoard[2, 4].character = 'W';
            gameBoard[3, 4].character = 'W';
            gameBoard[2, 5].character = 'W';
            gameBoard[3, 5].character = 'W';

            gameBoard[6, 4].character = 'W';
            gameBoard[7, 4].character = 'W';
            gameBoard[6, 5].character = 'W';
            gameBoard[7, 5].character = 'W';
        }

        static void DrawBoard()
        {
            for (int y = -1; y <= 10; ++y)
            {
                for (int x = -1; x <= 10; ++x)
                {
                    if ((x + 1) % 11 == 0 && (y + 1) % 11 == 0)
                    {
                        Console.Write(" ");
                    }
                    else if ((y + 1) % 11 == 0)
                    {
                        Console.Write(x.ToString());
                    }
                    else if ((x + 1) % 11 == 0)
                    {
                        Console.Write(y.ToString());
                    }
                    else
                    {
                        Console.Write(gameBoard[x, y].character);
                    }
                }
                System.Console.Write("\n");
            }
        }
    }
}

That code outputs:
Code:
 0123456789
0          0
1          1
2          2
3          3
4  WW  WW  4
5  WW  WW  5
6          6
7          7
8          7
9          8
 0123456789


If you get stuck with something specific feel free to ask. I wrote this in C# so that you can't copy and paste. :yeah

_________________
/\/////////// \\\\\\\\\\\/\S
/\/////////\\ //\\\\\\\\\/\I - Assault Wars
/\///////\\//|\\//\\\\\\\/\R - - Work in Progress
/\/////\\////|\\\\//\\\\\/\I
/\///\\/////\|/\\\\\//\\\/\S


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 3:07 am 
Technomaniac
User avatar

Joined: Mon Aug 23, 2004 12:24 am
Posts: 3096
Location: Washington , USA
Sirisian wrote:

If you get stuck with something specific feel free to ask. I wrote this in C# so that you can't copy and paste. :yeah


Tricky >:D

_________________
GMan
Black Ninja Games
Imagine ASCII art here!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group