Do you like Battleship? |
Yes |
|
83% |
[ 10 ] |
No |
|
16% |
[ 2 ] |
|
Total Votes : 12 |
|
caleb1997 wrote:
What do they do?
Tell you what, let me challenge you to impress us. How about you read those four functions, and the description of CALCnet, and tell us what they do.
It would seem that Cn2Send would store a variable in theta, or gets a variable ready for delivery and then puts it in CalcNet. Cn2Get retrieves the variable and displays it to the recipient. Cn2Ctrl sets up CalcNet, and Cn2Status just tells you the status of what you sent, whether or not it is received. But what is FlagBytes?
I am now almost done with the Battleship program. Just have to put in a few more commands. As for CalcNet.... If I decide to do that, I will make a version for that. As of right now, though... I will not include it. But I am almost done!
I am now done! It now has one- and two-player! It also works beautifully! I will upload it to Cemetech sometime today or tomorrow. Many thanks to Iambian, KermM, and most of all, MateoConLechuga!
Nice! Do you have any screenshots of it in action?
No... Unfortunately. What do you guys think of me putting in something that would allow you to create your own ships on the board and play with that?
Yes, this sounds like a great idea! You could have the user select which ship they wanted to place by using the Menu( command, or write your own custom menu, and then use that to figure out what ship to place when the user enters in the coordinates.
One of my ideas is to create a For( loop for each of the ships. It would go like this :
Code:
Disp "PLACE CARRIER"
6→A
Input "ROW:",W
Input "COLUMN:",H
For(J,0,A)
3+10(W+J-1)->R
3+9(H-1)->C
End
Something like that.
caleb1997 wrote:
It would seem that Cn2Send would store a variable in theta, or gets a variable ready for delivery and then puts it in CalcNet. Cn2Get retrieves the variable and displays it to the recipient. Cn2Ctrl sets up CalcNet, and Cn2Status just tells you the status of what you sent, whether or not it is received. But what is FlagBytes?
Theta is the address of the calculator that you're sending to. Cn2Send sends a list or a string to the calculator specified by the address in theta. Cn2Get checks if this calculator was sent a list or string, and if so, gives it to your program. Cn2Ctrl does indeed set up or tear down CALCnet on this calculator. Cn2Status tells you if you finished sending something, and/or if you have a received message waiting for your program.
caleb1997 wrote:
I am now almost done with the Battleship program. Just have to put in a few more commands. As for CalcNet.... If I decide to do that, I will make a version for that. As of right now, though... I will not include it. But I am almost done!
How are you doing multiplayer for now, then? Have both users use the same calculator? By the way, please remember that double-posting (replying to yourself in less than 24 hours) is against Cemetech rules except in extreme circumstances.
You wouldn't want to use that, as your program would become massive.
Since the A variable is all you really have to change, just write a Menu command, and use the labels to store the value in
Code: 0:Menu("Menu","One",1,"Two",2,"Three",3,"Four",4
Lbl 4:1
Lbl 3:Ans+1
Lbl 2:Ans+1
Lbl 1:Ans+1->A
Then just loop this by however many ships you have. You'll want to keep track of which ships have already been placed and take care of that accordingly.
Ok. Thanks! Here's the code so far:
Code: 6→A
While M≠1
Disp "CARRIER COORDINATES:"
Input "COLUMN:",L
Input "ROW:",W
3+10(W-1)->R
3+9(L-1)->V
Pxl-On(V,R)
M-1→M
If M=1:Goto B
End
This does work! Now all i have to do is finalize and test it, and I should be good.
While this code does work, I have a problem. Instead of retyping all the code needed to place the ships, I just store -2→Z. When I get to the end, it adds 2 to Z. Like this:
Code: -2→Z
Then a lot of code........
3→Q
While Q≠1
Disp "PLACE SPEEDBOAT:"
Input "COLUMN:",L
Input "ROW:",W
3+10(W-1)->R
3+9(L-1)->V
Pxl-On(V,R)
Q-1→Q
If Q=1
StorePic 3
Z+1→Z
If Q=1:Goto F
End
End
Lbl F
If Z≥1:Goto G
Goto A
End
Lbl G
But I can't figure out when to put a ClrDraw and StorePic command here so that the second time around, it stores the pic in pic4 and not pic3.
Can anyone pls help?
What is your first guess as to how you could store to Pic4 instead of Pic3 on the second loop? What have you tried so far? What worked or didn't work about it?
Would StorePic X work? Because then I could just add a # to X, and store it that way. What do you think?
caleb1997 wrote:
Would StorePic X work? Because then I could just add a # to X, and store it that way. What do you think?
Don't think that is possible in basic....
Hint: What does an 'If' statement do?
I know what an "If" statement does. Hmmmmm......................................
Maybe I could..... Scratching head........ Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking...... Thinking......
Aha!
Maybe something like this:
Code:
1→X
If X=1:StorePic 3:ClrDraw
StorePic 4
End
This way, I can store a pic in pic3, and then add 1 to X (which is already 1), and then, when the If statement is false, the picture would be stored in 4. Bingo!
And ClrDraw will be run every time.
Any way to make that only run once?
caleb1997 wrote:
Any way to make that only run once?
What do you think? There's at least two ways you could modify your code fragment there to do it: what can you come up with?
Maybe I could put the Clrdraw after the storepic 4 command... Actually, i could just put it at the very beginning of all the code. Yeah! That would work! Problem solved.
Glad you got that figured out!
Also, there seems to be a major flaw that needs to be addressed, unless that is how it is supposed to work. Here it is:
Code: If A=0:ClrDraw:End
I've noticed you've been doing this in your code... But a single 'If" statement does not require an 'End'
For example, when you did this:
Code: 1→X
If X=1:StorePic 3:ClrDraw
StorePic 4
End
I think that End was not supposed to be there... If you want to do an If-Then-Else-End chain, set it up like this:
Code: 1→X
If X=1:Then
StorePic 3
Else
ClrDraw
StorePic 4
End
Unless I'm mistaken, but something seems a little off. Hope this helps!