Page 1 of 2

Trying to get a Battleship Program ASAP

Posted: Sat Dec 01, 2007 8:54 pm
by Raffa
Hey there guys, new to the forums. I am currentyl in High School, and taking a computer programming class, where we use qbasic. I have been working with it for almost 2 months now, and starting to get it.

The thing is though, I have a battleship program due in like three days, and all my assignments are stacking up!

If somebody could write a qbasic program that has battleship, I would be so appreciative! All it needs to include is three ships, and end when the battleship is sunk. Shiplengths are 2, 3, 4 (the battleship being 4)

Thanks again if anybody takes this up, and if they do ,I would gladly write them a program also, just not for like a week!

~Raff

Sorry kiddo

Posted: Sun Dec 02, 2007 12:09 am
by burger2227
Most people will not do homework FOR you. Why?

1) Because your classmates outnumber you and they would probably beat the crap out of you if you got caught

2) You WILL get caught! Your teacher is no fool.

3) Many of us use much more advanced programming methods! Your program would be obvious to others.

4) You should give it a try and see what you come up with. If you have some problems, post the code and ask for help on specific things that you are having problems with.

OK, so far the ships are 2,3 and 4 WHAT? Pixels, inches, text places?
If you don't try, ALL of your ships are sunk!

Ted

Posted: Sun Dec 02, 2007 6:04 am
by Codemss
I think you can better start to code fast and hand in some code that is full of bugs, than hand in nothing or hand in someone elses code and get caught.
You can better do your best yourself(that's the only way you'll learn something) or admit to your teacher that you don't got got the time.
Now if you have some problems(in the code, or just things that you don't understand) you can post them here and I'm suree you'll get some good help.

Posted: Sun Dec 02, 2007 12:33 pm
by Mentat
I won't give you the code, but I'll give you some hints.
A) Use a matrix for the board
B) Use different numbers for different states (ex: 0 is unhit water, 1 is unhit ship square ...)

The rest should fall together.

Now if you have specific questions about certian parts of code and technique, and if your teacher permits, then we may help give hints to debug or optimize some parts of code you have already written.

Posted: Sun Dec 02, 2007 1:48 pm
by Sinuvoid
And try using SCREEN 7 :P

Posted: Sun Dec 02, 2007 9:05 pm
by Raffa
Not sure what Screen 7 is, but I'll play around. I'll post what I come up with tomorrow in this post. Thanks for all the help guys :-)

Re: Sorry kiddo

Posted: Sun Dec 02, 2007 9:10 pm
by BDZ
burger2227 wrote:3) Many of us use much more advanced programming methods! Your program would be obvious to others.
burger2227, no offense to you at all, but that just cracked me up...I got a picture of Raffa turning in some FreeBASIC source that uses pointers, inline assembly, and function overloading... :lol:

Posted: Sun Dec 02, 2007 9:40 pm
by BadMrBox
OK, so far the ships are 2,3 and 4 WHAT? Pixels, inches, text places?
pieces of course. 2 hit's for an 2pieced ship to go down etc.

@Raffa I can't believe that you guys is supposed to do a battleship game without knowledge of the different SCREEN modes. Have your teacher told you to use LINE, PSET and such or just plain ASCII?

Posted: Mon Dec 03, 2007 4:13 am
by burger2227
It's probably an ASCII text game.

Posted: Mon Dec 03, 2007 10:11 am
by Raffa
He's taught us nothing about screens -.-
And I know the line statement, but nothing about "PSET and such or just plain ASCII?"
My teacher is an idiot, I'm screwed =P

You guys are really great, awesome community.

Posted: Mon Dec 03, 2007 2:33 pm
by burger2227
Well, ASCII is just text really and you can make a crude boat just using a forward slash and a backslash with some dashes between. That could be done without knowing any ASCII codes!

Instead of all of this bantering and complaining about the teacher, you ought to start doing something. Your description of the game lacks a lot of information. We don't even have a decent idea of the assignment and you have wasted 3 days!

I could have written 3 harder programs in that amount of time! Full speed ahead! Damn the torpedo's!

Posted: Mon Dec 03, 2007 5:18 pm
by Mentat
Have you checked the tutorials section here? There's all kinds of tutorials that will help. I wouldn't bother with the ones in the magaizines yet, but the begginers section should be very good for you.

But you don't know about Pset? :shock: I learned Pset before Print (I kept on typing Disp, before I figured out the command was Print).

Posted: Mon Dec 03, 2007 8:00 pm
by Raffa
Haha, ok ok. I'm on it.

Posted: Tue Dec 04, 2007 5:16 pm
by Raffa
You can delete this, I give up

Posted: Wed Dec 05, 2007 3:45 am
by burger2227
Another one bites the dust! Try C or Cobal programming. It is a lot easier LOL. Thanks for giving up. Now you can look forward to being a Walmart stocker 24 hours a day! But they use computers too!

If you really want to learn, come back. Telling a computer to do something is kinda neat. Once you get the hang of it, you will find that it is the ONLY thing you can control wthout an argument. Errors perhaps, but no divorce settlement LOL.

Ted

Posted: Wed Dec 05, 2007 10:08 am
by BadMrBox
@burger I'm not sure if you noticed it yourself but I personally think that you are a bit rude :roll:

@Raffa Dont give up.
Line, Print and input is the only commands you need to get this done. And preferable arrays too. Have you learned anything about arrays?

Posted: Wed Dec 05, 2007 10:19 am
by MystikShadows
Ted Rude? NAHHHHHH !!!

IT's that time of the month for him, you know, PMS (Programmer's Madness Syndrome) ROFLMAO

Graphics

Posted: Wed Dec 05, 2007 12:28 pm
by Mac
We seem to be stuck on advanced graphics.

What are the specs of this game?

My thought would be to use no SCREEN command but simply use
PRINT "sss" to be an ordinary ship and "BBB" to be a battle ship.

And use LOCATE to place them, and an Array to keep track of where they are.

Are you supposed to fire missiles?

Mac

Sorry if I got carried away

Posted: Wed Dec 05, 2007 4:02 pm
by burger2227
I am just disappointed that he will not try a little harder! Programming isn't for everyone. But trying anything that is hard will make the person more able to deal with bigger problems down the road. Anybody can just throw up their hands and Quit!

I have run into programming problems too! If I just gave up, then I wasted a lot of time. I think we all have had stumbling blocks to get over.

I really think that he was looking for somebody to write it for him. Now that is rude and not fair to the other people in his class.

Mr Bad Box, what does your name connotate to the average person? It does not sound real friendly to me.

Ted

Posted: Thu Dec 06, 2007 10:46 am
by Raffa
At first, I was looking for somebody to help me write it, now after meeting you Burger, you completely turn me away from it. If learning QB ever turns me into somebody like you, it's not worth it :-)

PS - I finally got it to work, thanks to everybody else :-)