Do you like Battleship? |
Yes |
|
83% |
[ 10 ] |
No |
|
16% |
[ 2 ] |
|
Total Votes : 12 |
|
If you are at (1,1), then the code should give these as the results in R and C:
Code: 3+10(R-1->R
3+9(C-1->C
Therefore, R=3 and C=3. I'm not exactly sure how it could go offcreen... Let me test it real fast.
In the (1,1) example, C is 1 and R is 1. they are the coord. for gameplay.
C is column, and R is row.
caleb1997 wrote:
In the (1,1) example, C is 1 and R is 1. they are the coord. for gameplay.
C is column, and R is row.
I mean, double-check what the values of C and R are when the error occurs. Checking the values of variables is one of the key debugging skills for understand why your TI-BASIC code isn't working. there are at least three ways to do this:
1) Add a Disp C,R statement right before the command that doesn't work
2) In the program, insert a new line when the error occurs and you choose 2:Goto, then on that line, press [2nd][STO>] for Rcl, and type C [ENTER] to see the value of C
3) When the error occurs, quit to the homescreen and press C [ENTER] and R [ENTER] to see the values of the variables.
Ok. I will try that. Thanks!
Oh, I just got the same error too. It's because I was dumb and forgot to save the original values. D'uh. Let me fix that.
Aha! first the values are 1,1 , then 3,3 then 21,33, then 183,343, then it displays Error:Domain.
caleb1997 wrote:
Aha! first the values are 1,1 , then 3,3 then 21,33, then 183,343, then it displays Error:Domain.
Nice work debugging! Now you know why that Domain error is occuring, and you can work on figuring out how to fix it.
Nice work; I done messed up.
This should work better as it saves the values you entered.
Code: Input "ROW:",W
Input "COLUMN:",H
For(J,0,4
3+10(W+J-1->R
3+9(H-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
caleb1997 wrote:
Why W and H?
Because they aren't being used for anything, and that way the varibles are maintained. R and C are changed in the routine, so you can't really use them multiple times.
BINGO!!!!!! It works!!!
It now puts in just five dots, all in a row!
caleb1997 wrote:
But now.... How can we put in all the other ships?
Just do the same thing, but change the value in this for loop:
Code: For(J,0,SizeOfShip-1
EDIT: Also, you are going to want to check if the end of the ship goes out of bounds, which I am not going to give you, but a hint is that just add the length of the ship and see if that amount is over the width of the map. For vertical ships, it's the same thing. Good luck, and hope this helps!
I have a question. Are you thinking of eventually making it so that two people can play it with two calculators? (using send or something)
For 2-player, I think that I can make it so that every time you put in a coordinate, it shows it, then switches over to another board, which would be the opposing player.Whenever one of the players reach a score of 17, the game would display "PLAYER 1(or 2) WINS!". Player 1 could have his board as Pic1, and Player 2 could have Pic2. Every time the player enters a coordinate, it displays it, then stores what the board looks like as Pic1 (for player 1) or Pic2 (for player 2). Then it can ClrDraw, and then RecallPic # . After that, it all repeats.
What do you guys think?
Unfortunately, I don't think that 2 calcs could do this. Not without hacking them to interconnect. Sorry, Unicorn!
caleb1997 wrote:
For 2-player, I think that I can make it so that every time you put in a coordinate, it shows it, then switches over to another board, which would be the opposing player.Whenever one of the players reach a score of 17, the game would display "PLAYER 1(or 2) WINS!". Player 1 could have his board as Pic1, and Player 2 could have Pic2. Every time the player enters a coordinate, it displays it, then stores what the board looks like as Pic1 (for player 1) or Pic2 (for player 2). Then it can ClrDraw, and then RecallPic # . After that, it all repeats.
What do you guys think?
Unfortunately, I don't think that 2 calcs could do this. Not without hacking them to interconnect. Sorry, Unicorn!
Well, 2 calcs might work.... but the two calculators would have to be compatible with each other so that they could send pic vars back and forth.
Would take a while, though.
If you make a two-player mode, may I recommend using the BASIC CALCnet libraries? You can easily make two calculators communicate using the built-in GetCalc() command, which we'd be happy to tell you more about if you're interested. However, it's limited: you can only GetCalc() a variable from the receiving calculator when the sending calculator is at a Menu() or Pause or not running a program. With CALCnet, you can send and receive regardless of what the other calculator(s) in the network are doing. The downside is that you can only send and receive strings and lists, not things like pictures. Since you want to send and receive two coordinates or so, CALCnet would work well.
How do I do CalcNet? Is it something that I have to download?
Ivoah wrote:
Indeed! Specifically, take a look at the last four functions on the DCSB Libs page:
http://dcs.cemetech.net/index.php/DCSB_Libs