Added astroid game
This commit is contained in:
File diff suppressed because it is too large
Load Diff
26
dodge_astroid_game/main.py
Normal file
26
dodge_astroid_game/main.py
Normal file
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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}")
|
||||
Reference in New Issue
Block a user