diff --git a/.DS_Store b/.DS_Store index dc4ca4e..5542d46 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/dodge_astroid_game/Introduction to Python_ Variables Functions and Loops.html b/dodge_astroid_game/Introduction to Python_ Variables Functions and Loops.html new file mode 100644 index 0000000..9b562e3 --- /dev/null +++ b/dodge_astroid_game/Introduction to Python_ Variables Functions and Loops.html @@ -0,0 +1,1405 @@ + + + + + + Introduction to Python: Variables, Functions, and Loops + + + +
+ +
+
+

Introduction to Python

+
Slide 1 of 11
+
+

Variables, Functions, and Loops

+ +
+
🐍
+

In this introduction to coding in Python for beginners, you will learn how to use variables, loops, and functions to create visual and interactive artwork, animations, simulations, games, and more.

+
+ +

What will I create?

+

Make interactive projects, art, games, and a simulation. By the end of this path you will have created a scalable piece of geometric art.

+ +
+

321…Make! Learning Path

+

This path follows 321…Make! methodology:

+
+
+
3
+

Explore projects

+

Introduce creators to a set of skills and provide step-by-step instructions to help them develop initial confidence.

+
+
+
2
+

Design projects

+

Allow creators to practise skills from the Explore projects, and express themselves creatively while they grow in independence.

+
+
+
1
+

Invent project

+

Encourages creators to use their skills to create a unique project that meets a project brief for a particular audience.

+
+
+
+ +

What do I need to know?

+ + +

What do I need?

+ + +
+

Quick Quiz Instructions

+

Each project contains a quick quiz with three multiple choice questions. You are guided to the correct answer through useful feedback and are awarded a project badge.

+
+ +
+

This Design Project

+

This Design project guides you to use your new skills and encourages you to make design choices based on your interests.

+

You will make: Build a scrolling endless runner game where your character has to avoid obstacles - "Dodge asteroids"

+
+ + +
+ + +
+
+

Set the Scene

+
Slide 2 of 11
+
+ +
+

Step 1: Open the starter project

+

Create a variable called safe to store the background colour.

+
+ +

In the game, the player is safe if they are touching the background colour.

+ +
+ def draw():
+     # Put code to run every frame here
+     global safe
+     safe = Color(200, 100, 0)
+     background(safe)
+
+ +
+

Test:

+

Run your code and you should see a coloured square.

+

The colour is three numbers - the amount of red, green and blue. Try changing the numbers to any whole number between 0 and 255 to get a different colour.

+
+ +

Define a draw_player function

+ +
+ # Draw player function goes here
+def draw_player():
+    text('🀠', 200, 320)
+
+ +

Call the draw_player function so that the player is drawn on the screen.

+ +
+ def draw():
+    # Put code to run every frame here
+    global safe
+    safe = Color(200, 100, 0)
+    background(safe)
+    draw_player()
+
+ +
+

Test:

+

Run your code and you should see the emoji appear near the bottom of the screen.

+

You can paste in a different emoji if you want to.

+
+ +
+

The Emoji Keyboard

+

Your device might have an emoji keyboard that you can use to select an emoji:

+
    +
  • Mobile or tablet: Press the emoji icon (this is typically a smiley face)
  • +
  • Windows: Windows key + Full stop
  • +
  • Mac: CTRL + CMD + Space
  • +
  • Linux: Ctrl + Alt + E
  • +
+

Below are some of the most popular emojis that you could use in your project. You can copy them from here.

+
+ +
+ +
+ +
+

Important:

+

There are over 3,000 emojis available for you to use. They cover a wide variety of emotions, themes, and activities.

+

Tip: Emojis look slightly different on different devices, so someone else may not see exactly the same image as you. Some emojis are not supported on some devices and these appear as a square instead.

+
+ +

To make the player follow the mouse as it moves from side to side, change the player's x position to mouse_x.

+ +
+ # Draw player function goes here
+def draw_player():
+    text('🀠', mouse_x, 320)
+
+ +
+

Test:

+

Run your code and check that the player moves left and right when you move the mouse.

+
+ + +
+ + +
+
+

Create an Obstacle

+
Slide 3 of 11
+
+ +

Create the obstacles that you will have to avoid to keep playing the game.

+ +
+

Step 1: Define a draw_obstacles function

+

Define a draw_obstacles function to draw a cactus emoji 🌡.

+
+ +
+ # Draw obstacles function goes here
+def draw_obstacles():
+    text('🌡', 200, 200)
+
+ +

Call the draw_obstacles function so that the cactus is drawn on the screen.

+ +
+ def draw():
+    # Put code to run every frame here
+    global safe
+    safe = Color(200, 100, 0)
+    background(safe)
+    draw_obstacles()
+    draw_player()
+
+ +
+

Test:

+

Run your code and you should see a cactus as well as your player.

+
+ +

Add Variables for Obstacle Position

+ +
+ def draw_obstacles():
+    obstacle_x = 200
+    obstacle_y = 200
+    text('🌡', obstacle_x, obstacle_y)
+
+ +

Now, add frame_count to the obstacle's y (vertical) position.

+ +
+ def draw_obstacles():
+    obstacle_x = 200
+    obstacle_y = 200 + frame_count
+    text('🌡', obstacle_x, obstacle_y)
+
+ +
+

Test:

+

Run your code and the cactus emoji should move down the screen until it reaches the bottom.

+
+ +
+

Choose Your Obstacle Emoji

+

Select an emoji for your obstacles:

+
+ +
+ +
+ + +
+ + +
+
+

Random Obstacles

+
Slide 4 of 11
+
+ +

Currently, the obstacle disappears off the bottom of the screen, because its obstacle_y position becomes larger than the screen size.

+ +
+

Step 1: Use the modulo operator

+

Use the modulo (%) operator to divide the y position by the screen size and give you the remainder. This makes the obstacle reappear at the top!

+
+ +
+ def draw_obstacles():
+    obstacle_x = 200
+    obstacle_y = 200 + frame_count
+    obstacle_y = obstacle_y % screen_size
+    text('🌡', obstacle_x, obstacle_y)
+
+ +
+

Test:

+

Run your code and you should see the obstacle reach the bottom of the screen and then restart from the top.

+
+ +

Add Random Generation

+ +
+

Step 2: Add a random seed

+

Add a line of code for a random seed. A seed lets you generate the same random numbers in each frame.

+
+ +
+ # Draw obstacles function goes here
+def draw_obstacles():
+    seed(1234)
+    obstacle_x = 200
+    obstacle_y = 200 + frame_count
+
+ +
+

Step 3: Generate random coordinates

+

Update the code so that the x, y coordinates for the obstacle are generated randomly.

+
+ +
+ # Draw obstacles function goes here
+def draw_obstacles():
+    seed(1234)
+    obstacle_x = randint(0, screen_size)
+    obstacle_y = randint(0, screen_size) + frame_count
+
+ +
+

Test:

+

Run your code and you should see the cactus appear at a random position. Change the 1234 value inside the seed to another number and it will appear somewhere else.

+
+ + +
+ + +
+
+

Lots of Obstacles

+
Slide 5 of 11
+
+ +

Now you will add code to make lots of obstacles to avoid.

+ +
+

Step 1: Add a loop

+

Add a loop and indent the code to draw an obstacle. The loop will run this code multiple times.

+
+ +
+ def draw_obstacles():
+    seed(1234)
+    for i in range(8):
+        obstacle_x = randint(0, screen_size)
+        obstacle_y = randint(0, screen_size) + frame_count
+        obstacle_y = obstacle_y % screen_size
+        text('🌡', obstacle_x, obstacle_y)
+
+ +
+

Important:

+

Make sure that the code for the seed is before the loop, otherwise all of your obstacles will be generated on top of each other!

+

Change the number inside range() to control how many obstacles are created.

+
+ +
+

Test:

+

Run your code and you should see several obstacles.

+
+ + +
+ + +
+
+

Collisions

+
Slide 6 of 11
+
+ +

Recall that in the first step you created a 'safe' colour.

+ +
+

Step 1: Create a variable for collision detection

+

Create a variable to store the colour the player emoji is currently touching.

+
+ +
+ def draw_player():
+    player_on = get(mouse_x, 320).hex
+    text('🀠', mouse_x, 320)
+
+ +
+

Step 2: Check for collisions

+

If the player is touching the safe colour, draw the player emoji. If it is not, draw an explosion emoji to show they have crashed.

+
+ +
+ def draw_player():
+    player_on = get(mouse_x, 320).hex
+    if player_on == safe.hex:
+        text('🀠', mouse_x, 320)
+    else:
+        text('πŸ’₯', mouse_x, 320)
+
+ +
+

Test:

+

Run your code and move the player. You should see the explosion emoji if your player touches an obstacle.

+
+ +
+

Important Ordering:

+

Make sure that in draw(), the line of code to draw_obstacles() is before draw_player(). If you check for collisions before drawing the obstacles in a frame, then there won't be any obstacles to collide with!

+
+ + +
+ + +
+
+

Quick Quiz

+
Slide 7 of 11
+
+ +
+

Quiz Instructions:

+

Answer the three questions. There are hints to guide you to the correct answer.

+

When you have answered each question, click on your chosen answer to see feedback.

+

Have fun!

+
+ +
+

Question 1 of 3

+

You have used a lot of if statements to control your game's behaviour. Some of them might have had more complex conditions, using and to make multiple tests at once. If you ran the following piece of conditional code, what would you expect the output to be?

+ +
+ score = 5000
+lives = 2

+if score >= 5000 and lives >= 3:
+    print('Great flying!')

+if score >= 5000:
+    print('Doing well!')
+    if lives > 1:
+        print('Keep going!')
+    else:
+        print('But be careful!')

+elif lives > 1:
+    print('Push harder!')

+else:
+    print('Head for base!')
+
+ +
+
+ A) Great flying! +
+
+ B) Doing well! Keep going! +
+
+ C) Doing well! +
+
+ D) Push harder! +
+
+ +
+ Try again! While score >= 5000 is true, for an and condition both parts must be true, and lives >= 3 is false. +
+ +
+ Correct! This is correct β€” score >= 5000 is true, and so is lives > 1 on the nested if statement. +
+ +
+ Try again! Close, but score >= 5000 isn't the only condition the program would find true as it ran. +
+ +
+ Try again! While lives > 1 is true, only the code inside the first true condition in an if/elif/else statement is executed, and lives > 1 is not the first condition that is true. +
+
+ + +
+ + +
+
+

Quick Quiz (Continued)

+
Slide 8 of 11
+
+ +
+

Question 2 of 3

+

In this project you used procedural generation β€” having the computer create and place parts of your world for you. While doing this is a great time saver, particularly if you're creating very large levels, it can create some issues. Which of these issues should you look out for when testing your procedural generation?

+ +
+
+ A) All of them +
+
+ B) Obstacles could be generated that leave the player with no route forward. +
+
+ C) Obstacles appear directly underneath the player. +
+
+ D) The obstacles are all grouped together, leaving too much open space elsewhere. +
+
+ +
+ Correct! All of these can happen when using procedural generation. You can either add more code to check for and work around these issues, or try different seeds until you find one that works. +
+ +
+ Try again! This can happen with procedurally generated obstacles, particularly when the game first starts.

+ Tip: You could work around this issue by preventing obstacles from appearing too close to the player's starting position. Can you think of other solutions? +
+ +
+ Try again! This can happen either at the start of the game, or when new obstacles are added as a result of increasing the difficulty level, if they happen to choose a position close to the player's.

+ Tip: A potential solution might be to make the player temporarily immune to collision with all obstacles, or even only newly created obstacles, for a short time after a level increase. What problems might having the obstacle choose a new position create if it was too close to the player? +
+ +
+ Try again! Because random generation can choose groups of numbers that are close together, this can be a problem.

+ Tip: One solution might be to switch to semi-random generation β€” break the screen up in to pieces and use random numbers to generate obstacles inside each of those pieces. Can you think of how you could use this sort of procedural generation to make your game more interesting, or more challenging? +
+
+ + +
+ + +
+
+

Quick Quiz (Continued)

+
Slide 9 of 11
+
+ +
+

Question 3 of 3

+

You made a game that you're really pleased with and shared it. A player has reviewed it and has shared some thoughtful feedback with some changes they would like to see.

+

What would be the best way to react to their suggestions?

+ +
+
+ A) Immediately make all the changes they have suggested. +
+
+ B) Ignore the suggestions because you know best. +
+
+ C) Consider their feedback with other feedback and decide how to improve your game. +
+
+ D) Feel really sad that the player didn't think your game was perfect. +
+
+ +
+ Try again! It's great to get feedback, but you shouldn't change your game just to keep one player happy, maybe other players might give different feedback. +
+ +
+ Try again! Not quite. It's usually worth listening to what your users have to say about your work. If a player has given constructive feedback, then you should consider it. +
+ +
+ Correct! You should consider any feedback you get β€” while always trying to get more than one point of view β€” and make decisions to improve the game for all players. +
+ +
+ Try again! No! You shouldn't feel sad if someone suggests improvements to your game. Constructive feedback is really useful and can help improve your game. You should be pleased that they were interested enough in your game to give feedback. +
+
+ + +
+ + +
+
+

Learning Outcomes

+
Slide 10 of 11
+
+ +
+
+

Variables Mastered

+

βœ“ Create and use variables like safe, player_on, obstacle_x, obstacle_y

+

βœ“ Understand RGB color values (0-255)

+

βœ“ Use frame_count for animation

+
+ +
+

Functions Implemented

+

βœ“ Create functions: draw_player(), draw_obstacles()

+

βœ“ Call functions in proper order

+

βœ“ Use def keyword to define functions

+
+ +
+

Loops & Control Flow

+

βœ“ Use for loops with range()

+

βœ“ Implement if/else statements for collision detection

+

βœ“ Use modulo operator (%) for wrapping

+
+ +
+

Game Development Skills

+

βœ“ Procedural generation with randint() and seed()

+

βœ“ Collision detection using color checking

+

βœ“ Player movement with mouse_x

+

βœ“ Game state management

+
+
+ +
+

What You've Accomplished

+

You've built a complete endless runner game with:

+
    +
  • Player character that follows mouse movement
  • +
  • Randomly generated obstacles that scroll down the screen
  • +
  • Collision detection system
  • +
  • Visual feedback for collisions (explosion emoji)
  • +
  • Wrap-around obstacle system using modulo operator
  • +
+
+ + +
+ + +
+
+

Challenge

+
Slide 11 of 11
+
+ +

Now it is over to you! Use the skills you have learned to finish the game.

+ +
+
+
+ Use different emojis to represent the player and the obstacles. +
+ +
+
+ Draw the player or the obstacles using shapes instead (you learned this in the Make a face project). +
+ +
+
+ Draw the player or the obstacles using images instead (you learned this in the Rocket launch project). +
+ +
+
+ Change one line of code to make the obstacles move faster. +
+ +
+
+ Create a variable and add one to it each time the player crashes. +
+ +
+
+ Make the obstacles move faster after every crash. +
+ +
+
+ Add an item for the player to pick up, which disappears when the player touches it. +
+ +
+
+ Add a variable to keep track of the player's score. +
+ +
+
+ Stop the game if the player crashes. +
+ +
+
+ Display a text message on the screen to say 'Game over'. +
+
+ +
+

Your Game Progress

+

0/10 challenges completed

+
+
+
+

Complete these challenges to enhance your game!

+
+ +
+

Tips for Success

+
    +
  • Start with one challenge at a time
  • +
  • Test your code after each change
  • +
  • Use the emoji keyboard shortcuts provided earlier
  • +
  • Remember to save your project regularly
  • +
  • Share your completed game with others for feedback!
  • +
+
+ + +
+ + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/dodge_astroid_game/main.py b/dodge_astroid_game/main.py new file mode 100644 index 0000000..3f996d6 --- /dev/null +++ b/dodge_astroid_game/main.py @@ -0,0 +1,26 @@ +from p5 import * +from random import randint, seed + +# Include global variables here +screen_size = 400 + +# Draw player function goes here + + + +# Draw obstacles function goes here + + +def setup(): + # Put code to run once here + size(screen_size, screen_size) + text_size(40) + + +def draw(): + # Put code to run every frame here + + + +# Keep this to run your code +run() diff --git a/From_concept_to_release.html b/quiz_game/From_concept_to_release.html similarity index 100% rename from From_concept_to_release.html rename to quiz_game/From_concept_to_release.html diff --git a/PULL_REQUEST_TEMPLATE.md b/quiz_game/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to quiz_game/PULL_REQUEST_TEMPLATE.md diff --git a/Quiz_Game_Project-Student Learning_Portal.html b/quiz_game/Quiz_Game_Project-Student Learning_Portal.html similarity index 100% rename from Quiz_Game_Project-Student Learning_Portal.html rename to quiz_game/Quiz_Game_Project-Student Learning_Portal.html diff --git a/README.md b/quiz_game/README.md similarity index 100% rename from README.md rename to quiz_game/README.md diff --git a/Russian_Millionaire_Quiz_Game_Comprehensive_Guide.html b/quiz_game/Russian_Millionaire_Quiz_Game_Comprehensive_Guide.html similarity index 100% rename from Russian_Millionaire_Quiz_Game_Comprehensive_Guide.html rename to quiz_game/Russian_Millionaire_Quiz_Game_Comprehensive_Guide.html diff --git a/__pycache__/app.cpython-313.pyc b/quiz_game/__pycache__/app.cpython-313.pyc similarity index 100% rename from __pycache__/app.cpython-313.pyc rename to quiz_game/__pycache__/app.cpython-313.pyc diff --git a/app.py b/quiz_game/app.py similarity index 100% rename from app.py rename to quiz_game/app.py diff --git a/docs/.DS_Store b/quiz_game/docs/.DS_Store similarity index 100% rename from docs/.DS_Store rename to quiz_game/docs/.DS_Store diff --git a/docs/README.md b/quiz_game/docs/README.md similarity index 100% rename from docs/README.md rename to quiz_game/docs/README.md diff --git a/docs/roles/backend-developer-dima.md b/quiz_game/docs/roles/backend-developer-dima.md similarity index 100% rename from docs/roles/backend-developer-dima.md rename to quiz_game/docs/roles/backend-developer-dima.md diff --git a/docs/roles/database-designer-danil.md b/quiz_game/docs/roles/database-designer-danil.md similarity index 100% rename from docs/roles/database-designer-danil.md rename to quiz_game/docs/roles/database-designer-danil.md diff --git a/docs/roles/frontend-developer-inna.md b/quiz_game/docs/roles/frontend-developer-inna.md similarity index 100% rename from docs/roles/frontend-developer-inna.md rename to quiz_game/docs/roles/frontend-developer-inna.md diff --git a/docs/roles/graphics-designer-artyom.md b/quiz_game/docs/roles/graphics-designer-artyom.md similarity index 100% rename from docs/roles/graphics-designer-artyom.md rename to quiz_game/docs/roles/graphics-designer-artyom.md diff --git a/docs/technical-specs/teacher-project-guide.md b/quiz_game/docs/technical-specs/teacher-project-guide.md similarity index 100% rename from docs/technical-specs/teacher-project-guide.md rename to quiz_game/docs/technical-specs/teacher-project-guide.md diff --git a/gitea passwords.rtf b/quiz_game/gitea passwords.rtf similarity index 100% rename from gitea passwords.rtf rename to quiz_game/gitea passwords.rtf diff --git a/questions.json b/quiz_game/questions.json similarity index 100% rename from questions.json rename to quiz_game/questions.json diff --git a/requirements.txt b/quiz_game/requirements.txt similarity index 100% rename from requirements.txt rename to quiz_game/requirements.txt diff --git a/starter_templates/app.py b/quiz_game/starter_templates/app.py similarity index 100% rename from starter_templates/app.py rename to quiz_game/starter_templates/app.py diff --git a/starter_templates/docs/README.md b/quiz_game/starter_templates/docs/README.md similarity index 100% rename from starter_templates/docs/README.md rename to quiz_game/starter_templates/docs/README.md diff --git a/starter_templates/docs/roles/backend-developer-dima.md b/quiz_game/starter_templates/docs/roles/backend-developer-dima.md similarity index 100% rename from starter_templates/docs/roles/backend-developer-dima.md rename to quiz_game/starter_templates/docs/roles/backend-developer-dima.md diff --git a/quiz_game/starter_templates/docs/roles/database-designer-danil.md b/quiz_game/starter_templates/docs/roles/database-designer-danil.md new file mode 100644 index 0000000..e6e003a --- /dev/null +++ b/quiz_game/starter_templates/docs/roles/database-designer-danil.md @@ -0,0 +1,45 @@ +// 1. This file should contain database connection information +// TODO: Import MongoDB driver (line 1) +import pymongo + +// TODO: Connect to MongoDB using the connection URI (line 3-5) +client = pymongo.MongoClient("mongodb://localhost:27017/") + +// TODO: Select the appropriate database (line 7) +db = client["student_db"] + +// TODO: Select the questions collection (line 9) +questions_collection = db["questions"] + +// TODO: Add error handling for database connection (line 11) +try: + client.admin.command('ping') + print("Successfully connected to MongoDB!") +except Exception as e: + print(f"MongoDB connection error: {e}") + +// 2. Database population instructions (new section) +// TODO: Create function to insert questions into database (line 13-25) +def insert_questions(): + questions = [ + { + "question_number": 0, + "question": "What is the capital of Russia?", + "options": ["Moscow", "Saint Petersburg", "Novosibirsk", "Yekaterinburg"], + "correct_answer": 0 + }, + { + "question_number": 1, + "question": "Which river is the longest in Russia?", + "options": ["Volga", "Yenisey", "Ob", "Amur"], + "correct_answer": 1 + } + ] + + # Insert questions into collection + db.questions.insert_many(questions) + print("Questions inserted successfully!") + +// TODO: Call insert_questions function (line 27) +if __name__ == "__main__":: + insert_questions() \ No newline at end of file diff --git a/starter_templates/docs/roles/frontend-developer-inna.md b/quiz_game/starter_templates/docs/roles/frontend-developer-inna.md similarity index 100% rename from starter_templates/docs/roles/frontend-developer-inna.md rename to quiz_game/starter_templates/docs/roles/frontend-developer-inna.md diff --git a/starter_templates/static/script.js b/quiz_game/starter_templates/static/script.js similarity index 100% rename from starter_templates/static/script.js rename to quiz_game/starter_templates/static/script.js diff --git a/starter_templates/static/style.css b/quiz_game/starter_templates/static/style.css similarity index 100% rename from starter_templates/static/style.css rename to quiz_game/starter_templates/static/style.css diff --git a/starter_templates/templates/game.html b/quiz_game/starter_templates/templates/game.html similarity index 100% rename from starter_templates/templates/game.html rename to quiz_game/starter_templates/templates/game.html diff --git a/starter_templates/templates/index.html b/quiz_game/starter_templates/templates/index.html similarity index 100% rename from starter_templates/templates/index.html rename to quiz_game/starter_templates/templates/index.html diff --git a/static/script.js b/quiz_game/static/script.js similarity index 100% rename from static/script.js rename to quiz_game/static/script.js diff --git a/static/style.css b/quiz_game/static/style.css similarity index 100% rename from static/style.css rename to quiz_game/static/style.css diff --git a/templates/game.html b/quiz_game/templates/game.html similarity index 100% rename from templates/game.html rename to quiz_game/templates/game.html diff --git a/templates/index.html b/quiz_game/templates/index.html similarity index 100% rename from templates/index.html rename to quiz_game/templates/index.html diff --git a/starter_templates/docs/roles/database-designer-danil.md b/starter_templates/docs/roles/database-designer-danil.md deleted file mode 100644 index 2e99dd2..0000000 --- a/starter_templates/docs/roles/database-designer-danil.md +++ /dev/null @@ -1,19 +0,0 @@ -// 1. This file should contain database connection information -// TODO: Import MongoDB driver (line 1) -import pymongo - -// TODO: Connect to MongoDB using the connection URI (line 3-5) -client = pymongo.MongoClient("mongodb://localhost:27017/") - -// TODO: Select the appropriate database (line 7) -db = client["student_db"] - -// TODO: Select the questions collection (line 9) -questions_collection = db["questions"] - -// TODO: Add error handling for database connection (line 11) -try: - client.admin.command('ping') - print("Successfully connected to MongoDB!") -except Exception as e: - print(f"MongoDB connection error: {e}") \ No newline at end of file