diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..32c297c Binary files /dev/null and b/.DS_Store differ diff --git a/Battleships/Lesson1.html b/Battleships/Lesson1.html new file mode 100644 index 0000000..cb25f34 --- /dev/null +++ b/Battleships/Lesson1.html @@ -0,0 +1,121 @@ + + +
+ + +random to create hidden game elementsinput()if / else to give feedbackEvery video game has hidden logic โ secret levels, random enemies, or treasure locations. Learning to hide and reveal things with code is the first step to making your own games!
+These same skills are used in apps, quizzes, and even smart home devices!
+
+import random
+
+ship_row = random.randint(0, 4)
+ship_col = random.randint(0, 4)
+
+print("Guess the ship!")
+guess_row = int(input("Row (0-4): "))
+guess_col = int(input("Col (0-4): "))
+
+if guess_row == ship_row and guess_col == ship_col:
+ print("๐ฏ HIT! You sank the ship!")
+else:
+ print("๐ฆ MISS!")
+
+print("The ship was at", ship_row, ship_col)
+
+ How to create interactive programs that respond to user choices โ the heart of all games!
+ + \ No newline at end of file diff --git a/Battleships/Lesson2.html b/Battleships/Lesson2.html new file mode 100644 index 0000000..13b9103 --- /dev/null +++ b/Battleships/Lesson2.html @@ -0,0 +1,138 @@ + + + + + +hits, turns)for loops and if inside listsReal games donโt end after one guess! They track score, lives, and progress. Learning to manage game state is how you build Pac-Man, Minecraft, or Roblox games!
+Lists and loops are used in every programming language โ from apps to robots.
+
+import random
+
+ships = []
+while len(ships) < 3:
+ r = random.randint(0, 4)
+ c = random.randint(0, 4)
+ if [r, c] not in ships:
+ ships.append([r, c])
+
+print("3 ships hidden! 10 turns to find them all.")
+hits = 0
+
+for turn in range(10):
+ print("\nTurn", turn + 1)
+ guess_row = int(input("Row (0-4): "))
+ guess_col = int(input("Col (0-4): "))
+
+ if [guess_row, guess_col] in ships:
+ print("๐ฏ HIT!")
+ ships.remove([guess_row, guess_col])
+ hits += 1
+ if hits == 3:
+ print("๐ You win!")
+ break
+ else:
+ print("๐ฆ MISS!")
+
+if hits < 3:
+ print("Game over! You found", hits, "ships.")
+
+ row_letter = input("Row (A-E): ").upper()guess_row = ord(row_letter) - ord('A')Youโve learned the core ideas behind almost every game: hidden objects, player input, feedback, and win/lose conditions.
+ + \ No newline at end of file diff --git a/Battleships/battleships-137-main.zip b/Battleships/battleships-137-main.zip new file mode 100644 index 0000000..dd88b54 Binary files /dev/null and b/Battleships/battleships-137-main.zip differ diff --git a/Battleships/lesson_1.py b/Battleships/lesson_1.py new file mode 100644 index 0000000..0eb0f6f --- /dev/null +++ b/Battleships/lesson_1.py @@ -0,0 +1,41 @@ +# BATTLESHIPS - Grade 7 Python Game +# Lesson 2: Full mini-game with 3 ships and turns! + +import random + +# Step 1: Create 3 hidden ships (as a list of [row, col]) +ships = [] +while len(ships) < 3: + r = random.randint(0, 4) + c = random.randint(0, 4) + if [r, c] not in ships: # avoid duplicates + ships.append([r, c]) + +print("3 ships are hidden on a 5x5 grid!") +print("You have 10 turns to find them all.") + +hits = 0 +turns = 10 + +# Step 2: Game loop +for turn in range(turns): + print("\nTurn", turn + 1) + + # Get guess + guess_row = int(input("Row (0-4): ")) + guess_col = int(input("Col (0-4): ")) + + # Check if guess is a ship + if [guess_row, guess_col] in ships: + print("๐ฏ HIT!") + ships.remove([guess_row, guess_col]) # remove found ship + hits += 1 + if hits == 3: + print("๐ You found all ships! You win!") + break + else: + print("๐ฆ MISS!") + +# Step 3: Game over message +if hits < 3: + print("Game over! You found", hits, "out of 3 ships.") \ No newline at end of file diff --git a/Battleships/lesson_2.py b/Battleships/lesson_2.py new file mode 100644 index 0000000..6b34463 --- /dev/null +++ b/Battleships/lesson_2.py @@ -0,0 +1,22 @@ +# BATTLESHIPS - Grade 7 Python Game +# Lesson 1: Find the hidden ship! + +import random + +# Step 1: Create a secret ship location (row 0-4, col 0-4) +ship_row = random.randint(0, 4) +ship_col = random.randint(0, 4) + +# Step 2: Ask the player for a guess (we'll improve this later!) +print("Guess the ship location!") +guess_row = int(input("Row (0-4): ")) +guess_col = int(input("Col (0-4): ")) + +# Step 3: Check if they hit the ship +if guess_row == ship_row and guess_col == ship_col: + print("๐ฏ HIT! You sank the ship!") +else: + print("๐ฆ MISS! Try again.") + +# Step 4: (Optional) Show where the ship really was +print("The ship was at row", ship_row, "and col", ship_col) \ No newline at end of file