Results 1 to 10 of 10

Thread: Some suggestions please.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    27

    Some suggestions please.

    Hey guys i am doing a big final project and i would like some suggestions. We are not allowed to work on the actual code over the winter break but we can figure out where and how the code will start. The porject is to make a game, such as battle ship, concentration, 3-D tic Tac Toe,and mine sweeper. I have decided to go with the Battle ship game but i have a few Qs on how to start it.

    to do the game would i make two 2D Arrays? 1 for each player? so if one is modified i can make the necessary changes to the other. Also how would i make a grid? would i just make it out of the line tool then fill each space with alable box to represent a grid number? or is there a better way. And finally how in the World do i make the actuall ship lol how would placements of the ships work?


    I dont want the actual code im just asking for some help on how to start =\.I have only been learning it for 5 months so im still new to it. Help will be appreciated. Thankyou
    Last edited by cruisx; Dec 22nd, 2007 at 10:55 PM.

  2. #2
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    Re: Some suggestions please.

    You can create a control array of the battle ships on the form. Also you can also randomise the ship placements for the enemy, if you are playing against the computer that is.

    BTW: In which very or VB are you using? I had a look at VB3, but I am now using VB6 Pro and I am very much till a learner but am trying my bit to do as much as I can.

  3. #3
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Some suggestions please.

    Well, this sounds interesting. I've never created a Game but ....

    To create the Grid you could use an array of Label controls. Draw a label on a Form which would represent the top left hand element of the Grid and set it's Index property to 0. This establishes the label as a Control Array. In your program, perhaps in the Form_Load event, you can dynamically create the rest of the grid by Loading each element and placing it in the appropriate position.

    As for 'drawing' the ships, if you use a Label control the only thing you could do is to set the Caption property to a letter (or other character) (eg B = Battleship, C=Cruiser etc). If you wanted to really 'spice' it up, you could use an array of PictureBox'es and load graphics representing the parts of the ships - it depends upon how complex / how much work you want to put into it.

    If I remember the game correctly, you can position the ships vertically, horizontally or diagonally. I think I'd create a random number between 0 and 3 with 0 = Vertical, 1 = Horizontal, 2 = Diagonal (top left to bottom right) 3 = Diagonal (top right to bottom left). Then I'd create a couple of random numbers, based upon the number of squares the ship wll occupy, which defines it's starting location (Row, & Column) and then 'draw' the ship. Repeating for all the ships.

    This part might get a bit complicated as you have to consider things like, if you're drawing something which occupies 4 squares, and it's going to be horizontal, the starting Column has to be four less than the maximum column, so in an N X N Grid, the random number for the Column has to be between 1 and N-4, if drawing it vertically, the Row has to be between 1 and N - 4, if drawing diagonally, (top left to bottom right) the row has to be between 1 and N-4 and the Column has to be between 1 and N-4 and finally if drawing the other diagonal the row and column has to be between N and 4. (I might have got that wrong, it's early in the morning here, but, hopefully, you can see what I mean

    You can set the limits with a simple Select Case statement once you've decided which direction you're going to draw. You will also have to check that any square the ship will occupy is not already occupied, but again, once you've established which direction you're going to draw it, it's quite a simple matter to check the surrounding squares.

    There may be other 'niftier' ways but that is the approach I'd start with.

    Good luck.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Some suggestions please.

    Moved

  5. #5
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Some suggestions please.

    Oh dear god what a horrid way to create a game.

    You shouldn't have any controls on the form.. draw everything to the form.

    chem

    Visual Studio 6, Visual Studio.NET 2005, MASM

  6. #6
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Some suggestions please.

    Well, I did say I'd never created a Game

    Without wishing to hi-jack the thread. Perhaps you could educate me a little. (and perhaps, cruisx, as they're looking for ideas)

    My suggestion was to draw a single control (ie the first element of a Control Array) on the Form. If I wanted to follow your route, how would I create such an array and be able to expose all the events for that array?

    As far as I know, whilst I can use, Dim WithEvents and Controls.Add for a single control, I can't do it for a Control Array and expose the events of all the elements. Or would you not use a Control Array at all ?
    Last edited by Doogle; Dec 24th, 2007 at 01:37 AM.

  7. #7
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    Re: Some suggestions please.

    Well you could try to make the controls into the form and then make them visible or something like that when the need for the arises.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Dec 2007
    Posts
    27

    Re: Some suggestions please.

    ....This seems hard i have no idea what to do. If i dont think of anything by the end of this week, i might just do concentration instead of battle ship lol.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Some suggestions please.

    Also, if you are going to get into game programming, you should probably check out DirectX

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Some suggestions please.

    I stay away from graphics, because I know I totally suck at them. However, here are my suggestions:

    Easy: Make an array of pictureboxes or panels, show whatever you want in each one. The problem would arise when a ship extends across multiple panels.

    Slightly Harder: Have some canned images of the ships, draw them where they should be (maybe have each one in a picturebox and move and show the picturebox at the right place). Draw grids ontop of everything else (drawing lines like that is easy enough that even I can do it).

    Even Harder: Come up with a game that isn't Battleships so you don't get sued by whoever owns the copyright if the copyright still exists. The advantage to this would be that you could think about it during break, you could avoid some of the graphics issues because you wouldn't be trying for a known look and feel, and it would be waaaaaay cooler.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width