Jump to content

Battle ships!

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Bongobeater

Bongobeater

    Newbie

  • Members
  • Pip
  • 1 posts
Hello,

I have to make this battleships games for an assignment and can't seem to figure out what i need to place ten random 'Ships' which are only 1's and the 'sea' is 0's so if the co-ordinates the user enters = 1 its a hit.

So how do I get these ten ships which are just one in size? help is appreciated!!

DMK

#2
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
Well I've never made a BattleShip game before, but couldn't you use an array? You could store the 1s and 0s to know where each hit was. Then when you make a guess a scan the array and see if it hits.

~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#3
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
You would probably need a random () function, or something similar.

* * *

Why 1's and 0's? Can't there just be (ASCII) 32's and (ASCII) 2's?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users