Alice Community

Alice Community (http://www.alice.org/community/index.php)
-   How do I...? (http://www.alice.org/community/forumdisplay.php?f=16)
-   -   Battleship game (http://www.alice.org/community/showthread.php?t=6546)

boondocks 05-16-2011 05:57 PM

Battleship game
 
ive been working on trying to design the game battleship, my experience with this program is mediocre and i can't figure out a few things


my world consist of a 72 squares facing down with walls separating two 36(6x6) square grids

13 14..............
7 8 9 10 11 12
1 2 3 4 5 6


So...
PLayer 1
C4=square 16
B5=square 11
Player2
C4=square 52
B5= square 47

I can't figure out how to ask user to place the ships to certain squares
I have had some ideas like type in the coordinates, or clicking on squares and enabling only the next logical boxes to be clicked next but can't get anything to work properly. I also thought about grouping (say the motorboat to two invisible squares) to the users two selected squares, but trying to orient the group to a certain position isn't working.

If anybody has some tips or ideas on how to ask the user to place ships so that they show on their grid I would be very appreciative.
Thamks

reuben2011 05-17-2011 05:30 PM

You could use the event "let user move object with mouse" and then let the user drag the ship into position and then test its position and have it "snap" to corresponding squares. This seems very complicated though.

boondocks 05-25-2011 03:48 PM

is there any way that i can move the ship with the arrow keys and make it only move within the grid... like stopping when the ship moves left at last square where the wall is. when i mess around with the camera it won't move through these walls. I was wondering if this same concept could be applied here.

reuben2011 05-25-2011 04:14 PM

How about this: Click the ship to select it. Then the ship gets placed at (1,1) on the grid and you use the "when a key is pressed" to make the ship move one tile at a time. You're going to need to keep counters and use alot of if/else statements to make sure the ship is in bounds. I would rather use coordinates to keep track of the position rather than testing for proximity. Then you can have <SPACE> rotate the ship. If the ship can be placed, color it green; if it can't be placed, color the ship red. Then have the user press <ENTER> to have the ship go to it's final position (only if the ship is green.)

boondocks 05-30-2011 03:54 PM

1 Attachment(s)
hey im still trying to figure this game out and ended up setting up a boundary around my grid to keep the ship inside. The problem is that on the squares in the Y direction will block out the ship from moving past it, but the squares in the X direction wont. i posted what i have so far. the boundary will end up being invisible and the walls will be up. I still want to place the ships on the grid and have tried to come up with if statements to track the location of the ship(not in this world though) but can't really find a solution. Ideally i want to have 1-1 square ship, 1-2 square ship, and 1-3 square ship. If any body has any ideas for this part of my program i would be grateful.

jediaction 05-30-2011 08:45 PM

Interesting....I might review it once it is completely finished

boondocks 06-13-2011 05:46 PM

heeelp game issues
 
1 Attachment(s)
im still having problems with this game please if anyone can suggest anything,
I have tried to come up with a way to select a square from the grid but either it asks the question twice on wont run right also I made a way to pick the ships but taking that number and converting it to a square from grid isnt working.


All times are GMT -5. The time now is 01:27 PM.

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