Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.

Do you like Battleship?
Yes
 83%  [ 10 ]
No
 16%  [ 2 ]
Total Votes : 12

I am currently working on a battleship game. Any suggestions and/or question, just put it here. I will be using just BASIC programming language. It will be written for both the TI-83,83+, 83+CSE, and the 82.
No sprites. It will have a practice and 1-player mode. Working on 2-player mode.
http://i.imgur.com/JnEiCeA.jpg
There is no such thing as a 83+CSE
Are you using the graphscreen or homescreen?
Whats your plan of attack?
What will the interface look like?
Also, if a tree falls in a forest and nobody heard it, then it will have fallen if no one heard it. Imagine a deaf person who saw the tree fall...
My bad. I am using a 82+ CSE. As for the interface... what exactly do you mean?
I will be using the graphscreen.
Right now, i am coding to try and whenever you put in a coordinate, like 1,1, it will convert that to pixels and pixel-test for that certain spot. But that is where I am having problems.
caleb1997 wrote:
I will be using the graphscreen.
Right now, i am coding to try and whenever you put in a coordinate, like 1,1, it will convert that to pixels and pixel-test for that certain spot. But that is where I am having problems.


Why don't you use a friendly graphing window? This will make drawing graphics and testing things many times easier. Smile Also, please note that double posting within 24 hours is generally frowned upon, so just use the [EDIT] button to change your post. Thanks! Smile
caleb1997 wrote:
My bad. I am using a 82+ CSE. As for the interface... what exactly do you mean?


There is no 82+CSE either Wink (inb4 85+CSE)



Joking aside, good luck with this project Smile
I am having trouble with this bit:

Code:
Lbl 1A
Input "ROW:",R
Input "COLUMN:",C
R+0.5->R
C+0.5->C
(150+(C*-13))->A
(23+(R*22))->B
round(A,0)->A
round(B,0)->B
If pxl-Test(A,B)=1
Then
Goto 2B
Else:Goto 2C
End
Lbl 2B
11->K
Pt-On(C,R,K)
Pause
Goto 1A
Lbl 2C
10->K
Pt-On(C,R,K)
Pause
Goto 1A


What I am trying to do is get the point that you entered (for example, (1,1)) and then convert it to pixel format. That works.... But it then puts a blue dot instead of a red dot for a hit, and it isn't detecting the pixels that are there, even though i put the numbers through the algorithm that I created. The algorithms that I use follows: (150+(C*-13))→A for the column, and (23+(R*22))→B for the rows. It works, but the pixel-Test() command is not detecting the pixels are there, but for some reason, when I run the command on the homescreen instead of the graphscreen, it will say that it detected the pixel on the graphscreen, but not in the program. Help, anyone?
Okay, so I think I see your problem, but I am going to point out some things that are good practices to get into before I post it and explain it better. Smile
1) You don't want to use a goto within an if-then statement. This causes a memory leak, which can crash your program if you run it too many times. (Uh oh) Smile
2)Ending parenthesis and quotes can generally be left off; this helps to preserve space in your program.
3)"If pxl-Test(A,B)=1" can simply be "If pxl-Test(A,B", because If executes if the condition is true, so you don't have to check if it is true. Razz
4)So for example, instead of this:

Code:
If pxl-Test(A,B)=1
Then
Goto 2B
Else:Goto 2C
End

Could be:

Code:
If pxl-Test(A,B
Goto 2B
Goto 2C

5) Generally though, you want to avoid the use of goto, and use nicer loops such as a While or a Repeat
6) R+0.5->R can simply be R+.5->R to save space.
Ok. Thanks! Smile . Will work on that on sourcecoder 3. . And by the way, what does Repeat do, and how would I use it?
caleb1997 wrote:
Ok. Thanks! Smile . Will work on that on sourcecoder 3. . And by the way, what does Repeat do, and how would I use it?

So the Repeat command repeats a condition if something is not true, such as a 0. Smile

So here's the code that I might use for this, as reading from the graphscreen becomes a little easier if your coordinates match up with what you are trying to index. If you have any questions about it; feel free to ask! Smile


Code:
0->Xmin
~240->Ymin
320->Xmax:0->Ymax
ClrDraw
AxesOff
For(X,0,10
For(X,0,10
Line(0,~13X,120,~13X
Line(12X,0,12X,~130
End:End
Repeat 0
Input "ROW:",R
Input "COLUMN:",C
3+10(R-1->R
3+9(C-1->C
10+pxl-Test(C,R->K
For(X,0,3
For(Z,0,3
Pxl-On(C+X,R+Z,Ans
End:End
Pause
End
caleb1997 wrote:
I am currently working on a battleship game. Any suggestions and/or question, just put it here. I will be using just BASIC programming language. It will be written for both the TI-83,83+, 83+CSE, and the 82.


83+CSE

lel
Do you have any questions on Mateo's code, Caleb? Anything there that doesn't make sense to you, from individual commands to the overall structure of the code? Don't hesitate to ask, because we're more than happy to answer.
Now I have to put in a pixel for each of the hitpoints on the ships. My plan of attack(pun intended) is to put a pixel for each hitpoint of each ship. For example, if someone went in and put in (1,1), and their was a pixel there, I want a point to show up, with the color as red. If there is no pixel(i.e. no ship), i want it to show up as blue. This is where it gets complicated. Anyone willing to help?

For an example, 5 pixels in a row would be a carrier, 3 would be a sub/battleship, and so on.
Sure, I believe that my code above actually already does that as long as you draw the ships before you allow the player to input the coordinates. You can do this by selecting the row and column that you want, and just looping through the routine until the ship is fully displayed. Or do you mean something else?
I mean to put pixels for ships. Like five pixels in a row, one in each box, to signify a carrier(which has five hitpoints), and then 3 pixels somewhere else to signify a submarine, and so on and so forth. The only problem with this is.... How can I get the pxl-Test( command to detect the pixels that are, and aren't, there?

Would take a lot of pixels, though. At least 17 Pixel-on( commands.
Ah, okay. That makes sense then. To do that, you can modify the code a little bit like this:


Code:
Input "ROW:",R
Input "COLUMN:",C
For(J,0,4
3+10(R+J-1->R
3+9(C-1->C
10+pxl-Test(C,R->K
For(X,0,3
For(Z,0,3
Pxl-On(C+X,R+Z,Ans
End:End
End



Code:
For(J,0,4
3+10(R+J-1->R


This part tells it to loop 5 times, the size of the aircraft carrier, in the X, or Row direction. If you want, you can add another option asking the player if they want it vertical or horizontal.
Great! I can use this to place the ships. Smile. But what about detecting them?
I tried the code that Mateo suggested.... But when I hit enter, and put in (1,1), it gives me a error and shows me this:
Code:
10+pxl-Test(C,R)→K


What should I do?
caleb1997 wrote:
I tried the code that Mateo suggested.... But when I hit enter, and put in (1,1), it gives me a error and shows me this:
Code:
10+pxl-Test(C,R)→K


What should I do?
What error? And what are the values of C and R? Chances are that C and R are off-screen.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 4
» All times are GMT - 5 Hours
 
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
You cannot vote in polls in this forum

 

Advertisement