Trying to get a Battleship Program ASAP

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Raffa
Newbie
Posts: 8
Joined: Sat Dec 01, 2007 8:50 pm
Contact:

Trying to get a Battleship Program ASAP

Post by Raffa » Sat Dec 01, 2007 8:54 pm

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

User avatar
burger2227
Veteran
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Sorry kiddo

Post by burger2227 » Sun Dec 02, 2007 12:09 am

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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
Codemss
Veteran
Posts: 124
Joined: Sun Jun 24, 2007 6:49 am
Location: Utrecht, The Netherlands
Contact:

Post by Codemss » Sun Dec 02, 2007 6:04 am

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.
Check out my site: <a href="http://members.lycos.nl/rubynl">Click here</a>
Hope you like it. Send some feedback if you want: <a href="mailto:basicallybest@live.nl">Mail me</a>
Codemss, before known as RubyNL

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat » Sun Dec 02, 2007 12:33 pm

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.

Sinuvoid
Veteran
Posts: 155
Joined: Wed Jul 25, 2007 8:20 am

Post by Sinuvoid » Sun Dec 02, 2007 1:48 pm

And try using SCREEN 7 :P

Raffa
Newbie
Posts: 8
Joined: Sat Dec 01, 2007 8:50 pm
Contact:

Post by Raffa » Sun Dec 02, 2007 9:05 pm

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 :-)

BDZ
Coder
Posts: 49
Joined: Sun Nov 20, 2005 5:41 pm
Location: Wisconsin
Contact:

Re: Sorry kiddo

Post by BDZ » Sun Dec 02, 2007 9:10 pm

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:

User avatar
BadMrBox
Veteran
Posts: 86
Joined: Tue Feb 28, 2006 12:19 pm

Post by BadMrBox » Sun Dec 02, 2007 9:40 pm

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?

User avatar
burger2227
Veteran
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Mon Dec 03, 2007 4:13 am

It's probably an ASCII text game.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Raffa
Newbie
Posts: 8
Joined: Sat Dec 01, 2007 8:50 pm
Contact:

Post by Raffa » Mon Dec 03, 2007 10:11 am

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.

User avatar
burger2227
Veteran
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Mon Dec 03, 2007 2:33 pm

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!
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
Mentat
Veteran
Posts: 409
Joined: Tue Aug 07, 2007 3:39 pm
Location: NC, US

Post by Mentat » Mon Dec 03, 2007 5:18 pm

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).
For any grievances posted above, I blame whoever is in charge . . .

Raffa
Newbie
Posts: 8
Joined: Sat Dec 01, 2007 8:50 pm
Contact:

Post by Raffa » Mon Dec 03, 2007 8:00 pm

Haha, ok ok. I'm on it.

Raffa
Newbie
Posts: 8
Joined: Sat Dec 01, 2007 8:50 pm
Contact:

Post by Raffa » Tue Dec 04, 2007 5:16 pm

You can delete this, I give up

User avatar
burger2227
Veteran
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 » Wed Dec 05, 2007 3:45 am

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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

User avatar
BadMrBox
Veteran
Posts: 86
Joined: Tue Feb 28, 2006 12:19 pm

Post by BadMrBox » Wed Dec 05, 2007 10:08 am

@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?

MystikShadows
Veteran
Posts: 703
Joined: Sun Nov 14, 2004 7:36 am
Contact:

Post by MystikShadows » Wed Dec 05, 2007 10:19 am

Ted Rude? NAHHHHHH !!!

IT's that time of the month for him, you know, PMS (Programmer's Madness Syndrome) ROFLMAO
When God created light, so too was born, the first Shadow!

MystikShadows

Need hosting? http://www.jc-hosting.net

Interested in Text & ASCII development? Look no further!
http://www.ascii-world.com

Mac
Veteran
Posts: 151
Joined: Mon Aug 06, 2007 2:00 pm

Graphics

Post by Mac » Wed Dec 05, 2007 12:28 pm

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

User avatar
burger2227
Veteran
Posts: 2396
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Sorry if I got carried away

Post by burger2227 » Wed Dec 05, 2007 4:02 pm

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
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0

Raffa
Newbie
Posts: 8
Joined: Sat Dec 01, 2007 8:50 pm
Contact:

Post by Raffa » Thu Dec 06, 2007 10:46 am

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 :-)

Post Reply