Alice Community  

Go Back   Alice Community > Alice 2 > Works-In-Progress

Reply
 
Thread Tools Display Modes
Battleship
Old
Leo
Guest
 
Status:
Posts: n/a
Default Battleship - 03-27-2007, 11:00 AM

Hello.

I have been working on this for quite some time, and have run into a slight issue with my lists.

The name of the game is Battleship. Most people know how to play it. In this Alice version of mine, The grid appears, and the player clicks a square to select a possible space. After the selection is made the square will turn 1 of 2 colors, depending on if the enemies "ship" is there. If it's a hit on the enemy, the square should turn red. If it's a miss, it turns green. Afterwards, the grid blanks out, the player cannot click, and the enemy fires randomly on your ships. After the enemy's turn, the player is able to see the grid and click it. The proccess repeats. Your ships are fully sinkable, though, I haven't coded the Enemy Ships sinking.

My problem is this: When the player is choosing the square to fire upon, it does not register a "hit" on the enemy. The squares will only turn green, not red. The way the spaces were designed, a random setup is selected from 5 different options. However, the squares will only turn green. The code for my entire game is below, feel free to tinker with it, and use it as you can.

Thank you!

Ryan S.
Attached Files
File Type: a2w Battleship.a2w (2.22 MB, 859 views)
   
Reply With Quote
More questions than help, unfortunately.
Old
DrJim
Guest
 
Status:
Posts: n/a
Red face More questions than help, unfortunately. - 03-29-2007, 12:22 PM

Just a start! More problems than I could find with a quick look - but maybe the ones I did find/suspect will give you a place to start.

One problem is that you haven't made sure what the mouse clicks on is one of the grid squares (based on a quick test, it often isn't) - see the Zeus example in Dunn, et al for more on this. A question for the forum - am I correct that if there are two or three objects at the point the mouse clicks, the one whose center is closest to the point will be the one selected?

Second, although it's legal (since the full names are different?) the fact that you have two "squares" is confusing for debug - I'd suggest changing one or both names. (I got quite a few error messages in the brief time I played with the game - suspect there may be a deeper error here but didn't find it.)

Third, I suspect that there is something wrong with the "If Square = = Item from Grid1" statement in the hit detection method. I haven't personally used the "Item from ---" command outside of a "For All Together" or "For All In Order" block so not sure what the restrictions are (again - can anyone else help ) but this particular command gave me a lot of trouble (and crashes) when I messed with it.

Finally, try to develop this type of program incrementally. While it's a good idea to have the overall program outline in hand (like you do) before you start - trying to then debug everything at the same time is difficult. My suggestion is to get the outline together like you have - then break it into pieces and get each working individually.
   
Reply With Quote
Old
Leo
Guest
 
Status:
Posts: n/a
Default 04-02-2007, 10:50 AM

I acutally got the part of clicking on only the squares down, so, that's been taken care of, and yes, I changed both "Squares". It works fine now, so, I have to finish up the main core of the programming, such as the different sides winning.

Thanks you for your input, I'll post up a finished version of the game when it is available.

Ryan S.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.