diff --git a/ar-SA/code/target-practice-solution/main.py b/ar-SA/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/ar-SA/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/ar-SA/code/target-practice-solution/project_config.yml b/ar-SA/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/ar-SA/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/ar-SA/code/target-practice-starter/main.py b/ar-SA/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/ar-SA/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/ar-SA/code/target-practice-starter/project_config.yml b/ar-SA/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/ar-SA/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/ar-SA/images/alternative-colours.png b/ar-SA/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/ar-SA/images/alternative-colours.png differ diff --git a/ar-SA/images/animation_bg_erase.gif b/ar-SA/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/ar-SA/images/animation_bg_erase.gif differ diff --git a/ar-SA/images/animation_no_bg_erase.gif b/ar-SA/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/ar-SA/images/animation_no_bg_erase.gif differ diff --git a/ar-SA/images/arrow-centre.png b/ar-SA/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/ar-SA/images/arrow-centre.png differ diff --git a/ar-SA/images/arrow-middle.png b/ar-SA/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/ar-SA/images/arrow-middle.png differ diff --git a/ar-SA/images/arrow-target.png b/ar-SA/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/ar-SA/images/arrow-target.png differ diff --git a/ar-SA/images/background.png b/ar-SA/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/ar-SA/images/background.png differ diff --git a/ar-SA/images/banner.png b/ar-SA/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/ar-SA/images/banner.png differ diff --git a/ar-SA/images/blue-circle.png b/ar-SA/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/ar-SA/images/blue-circle.png differ diff --git a/ar-SA/images/blue-points.png b/ar-SA/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/ar-SA/images/blue-points.png differ diff --git a/ar-SA/images/blue_circle_points.gif b/ar-SA/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/ar-SA/images/blue_circle_points.gif differ diff --git a/ar-SA/images/bottom-right.png b/ar-SA/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/ar-SA/images/bottom-right.png differ diff --git a/ar-SA/images/centre.png b/ar-SA/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/ar-SA/images/centre.png differ diff --git a/ar-SA/images/circle-coords.png b/ar-SA/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/ar-SA/images/circle-coords.png differ diff --git a/ar-SA/images/coords_animation.gif b/ar-SA/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/ar-SA/images/coords_animation.gif differ diff --git a/ar-SA/images/difficulty-setting.png b/ar-SA/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/ar-SA/images/difficulty-setting.png differ diff --git a/ar-SA/images/fire_arrow.gif b/ar-SA/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/ar-SA/images/fire_arrow.gif differ diff --git a/ar-SA/images/five_circles.png b/ar-SA/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/ar-SA/images/five_circles.png differ diff --git a/ar-SA/images/green-grass.png b/ar-SA/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/ar-SA/images/green-grass.png differ diff --git a/ar-SA/images/grey-circle.png b/ar-SA/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/ar-SA/images/grey-circle.png differ diff --git a/ar-SA/images/grey-points.png b/ar-SA/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/ar-SA/images/grey-points.png differ diff --git a/ar-SA/images/initial_target.png b/ar-SA/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/ar-SA/images/initial_target.png differ diff --git a/ar-SA/images/missed-points.png b/ar-SA/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/ar-SA/images/missed-points.png differ diff --git a/ar-SA/images/missed_no_points.gif b/ar-SA/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/ar-SA/images/missed_no_points.gif differ diff --git a/ar-SA/images/outline-circles.png b/ar-SA/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/ar-SA/images/outline-circles.png differ diff --git a/ar-SA/images/points-scored.gif b/ar-SA/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/ar-SA/images/points-scored.gif differ diff --git a/ar-SA/images/quiz-colour.png b/ar-SA/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/ar-SA/images/quiz-colour.png differ diff --git a/ar-SA/images/random-side.png b/ar-SA/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/ar-SA/images/random-side.png differ diff --git a/ar-SA/images/rectangle-diagram.png b/ar-SA/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/ar-SA/images/rectangle-diagram.png differ diff --git a/ar-SA/images/showcase_rocket.png b/ar-SA/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/ar-SA/images/showcase_rocket.png differ diff --git a/ar-SA/images/showcase_static.png b/ar-SA/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/ar-SA/images/showcase_static.png differ diff --git a/ar-SA/images/sky_coords.png b/ar-SA/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/ar-SA/images/sky_coords.png differ diff --git a/ar-SA/images/sky_stroke.png b/ar-SA/images/sky_stroke.png new file mode 100644 index 000000000..0d088147f Binary files /dev/null and b/ar-SA/images/sky_stroke.png differ diff --git a/ar-SA/images/stand_coords.png b/ar-SA/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/ar-SA/images/stand_coords.png differ diff --git a/ar-SA/images/step_4_preview.gif b/ar-SA/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/ar-SA/images/step_4_preview.gif differ diff --git a/ar-SA/images/step_5_preview.gif b/ar-SA/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/ar-SA/images/step_5_preview.gif differ diff --git a/ar-SA/images/target-stand.png b/ar-SA/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/ar-SA/images/target-stand.png differ diff --git a/ar-SA/images/target_area.png b/ar-SA/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/ar-SA/images/target_area.png differ diff --git a/ar-SA/images/target_printed.gif b/ar-SA/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/ar-SA/images/target_printed.gif differ diff --git a/ar-SA/images/three-circles.png b/ar-SA/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/ar-SA/images/three-circles.png differ diff --git a/ar-SA/images/top-left.png b/ar-SA/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/ar-SA/images/top-left.png differ diff --git a/ar-SA/images/triangles-coords.png b/ar-SA/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/ar-SA/images/triangles-coords.png differ diff --git a/ar-SA/images/upgrade-ideas.png b/ar-SA/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/ar-SA/images/upgrade-ideas.png differ diff --git a/ar-SA/images/yellow-points.png b/ar-SA/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/ar-SA/images/yellow-points.png differ diff --git a/ar-SA/meta.yml b/ar-SA/meta.yml new file mode 100644 index 000000000..f2472fdb0 --- /dev/null +++ b/ar-SA/meta.yml @@ -0,0 +1,41 @@ +--- +title: تمرين الرماية +hero_image: images/banner.png +description: استخدم Python لرسم هدف وتسجيل نقاط بضربه بالسهام +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: المقدمة + - + title: قم بإنشاء خلفية + - + title: ارسم هدفك + completion: + - engaged + - + title: أطلق سهمك + - + title: تسجيل النقاط + - + title: تفكير + completion: + - external + - + title: قم بتطوير مشروعك + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: ما التالي؟ + challenge: true + - + title: What can you do now? diff --git a/ar-SA/python-comments-demo.txt b/ar-SA/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/ar-SA/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/ar-SA/python-comments.txt b/ar-SA/python-comments.txt new file mode 100644 index 000000000..cac92f5d4 --- /dev/null +++ b/ar-SA/python-comments.txt @@ -0,0 +1,27 @@ +أشياء للقيام بها في كل إطار + +Draw the inner circle + +Draw the middle circle + +نضع دالة shoot_arrow هنا + +نضع دالة mouse_pressed هنا + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/ar-SA/python-translatable-demo.txt b/ar-SA/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/ar-SA/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/ar-SA/python-translatable.txt b/ar-SA/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/ar-SA/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/ar-SA/quiz1/question_1.md b/ar-SA/quiz1/question_1.md new file mode 100644 index 000000000..21d17d151 --- /dev/null +++ b/ar-SA/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +بعد كل سؤال ، اضغط على **إرسال**. سيتم توجيهك نحو الإجابة الصحيحة. + +إستمتع! + +--- question --- +--- +legend: السؤال 1 من 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +هذا صحيح! This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ar-SA/quiz1/question_2.md b/ar-SA/quiz1/question_2.md new file mode 100644 index 000000000..a2b1a1ca1 --- /dev/null +++ b/ar-SA/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: السؤال 2 من 3 +--- + +في مشروعك ، استخدمت `if` و `elif`و `else` للتحقق من اللون الذي سقط عليه السهم. + +In the example below, a variable called `speed` has the number `6` stored in it. عند تشغيل هذا التعليمات البرمجية ، ما الذي سيتم طباعته في منطقة المخرجات ؟ + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- سريع جدًا + + --- feedback --- + + هذا صحيح! تم تخصيص متغير **speed** للقيمة `6`، مما يجعل `speed == 6` شرط **صحيح** ويطبع `سريع جدًا`. + + --- /feedback --- + +- ( ) `لا يمكن تمييز السرعة!` + + --- feedback --- + + ليس تمامًا ، انظر إلى القيمة المخصصة للمتغير **speed**. + + --- /feedback --- + +- لا تتم طباعة أي شيء + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ar-SA/quiz1/question_3.md b/ar-SA/quiz1/question_3.md new file mode 100644 index 000000000..759d22943 --- /dev/null +++ b/ar-SA/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: السؤال 3 من 3 +--- + +يتم رسم القطع الناقص باستخدام التعليمات البرمجية التالي: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0,255,0) +no_stroke() + +def draw(): +ellipse(0,0,300,300) + +run() + +--- /code --- + +أي من الصور أدناه توضح الموضع الصحيح لهذا القطع الناقص في منطقة المخرجات؟ + +--- choices --- + +- ( ) ![دائرة خضراء متمركزة في الركن الأيمن السفلي من منطقة المخرجات.](images/bottom-right.png) + + --- feedback --- + + ليس تمامًا ، لتوسيط الدائرة في الزاوية اليمنى السفلية ، يجب أن تكون الإحداثيات هي نفس حجم الشاشة. في هذا المثال ، سيكون القطع الناقص `ellipse(400,400,300,300)`. + + --- /feedback --- + +- ( ) ![دائرة خضراء تتمركز في منتصف منطقة المخرجات.](images/centre.png) + + --- feedback --- + + ليس تمامًا ، لتوسيط الدائرة في المنتصف ، يجب أن تكون الإحداثيات نصف حجم الشاشة. في هذا المثال ، `ellipse(200,200,300,300)`. + + --- /feedback --- + +- (x) ![دائرة خضراء متمركزة في الزاوية العلوية اليسرى من منطقة المخرجات.](images/top-left.png) + + --- feedback --- + + هذا صحيح! تتركز هذه الدائرة عند الإحداثيات (0،0) ، الزاوية العلوية اليسرى من الشاشة. + + --- /feedback --- + +- ( ) ![دائرة خضراء متمركزة في الجانب العلوي الأيمن من منطقة المخرجات.](images/random-side.png) + + --- feedback --- + + لا ، سيكون لهذه الدائرة التعليمات البرمجية `ellipse(350,150,300,300)` لتوسيطها في أعلى يمين الشاشة. الإحداثي `×` هو مدى المسافة بين القطع الناقص عبر الشاشة ، والإحداثي `y` هو مدى المسافة أسفل الشاشة. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ar-SA/resources/main.py b/ar-SA/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/ar-SA/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/ar-SA/resources/p5.py b/ar-SA/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/ar-SA/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/ar-SA/step_1.md b/ar-SA/step_1.md new file mode 100644 index 000000000..f0c7f755b --- /dev/null +++ b/ar-SA/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +استخدم Python ، مع مكتبة الرسومات `p5` ، لرسم هدف وتسجيل نقاط بضربه بالسهام. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +انقر فوق الزر **تشغيل** أدناه لبدء اللعبة. عندما تظهر النقطة على الهدف ، انقر بالماوس (أو اضغط على جهازك اللوحي) لإطلاق السهم. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/ar-SA/step_2.md b/ar-SA/step_2.md new file mode 100644 index 000000000..893a3456e --- /dev/null +++ b/ar-SA/step_2.md @@ -0,0 +1,39 @@ +## Draw the grass + +--- task --- + +افتح مشروع [بداية الرماية](https://trinket.io/python/eb67937f99){:target="_blank}. + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png)no_stroke() +fill(sky) +rect(0, 0, 400, 250) #محور س, محور ص, العرض, الارتفاع + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 18 +line_highlights: 25 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**اختبار:** قم بتشغيل مشروعك مرة أخرى لعرض الخلفية النهائية. + +![![منطقة مخرجات مع مستطيل بلون السماء فوق مستطيل بلون العشب لإنشاء الخلفية.](images/background.png){:"width="300px}](images/background.png)دالة `size()` تستدعى في `setup()` يعين حجم الشاشة على 400 بكسل × 400 بكسل. + +--- /task --- + +--- save --- diff --git a/ar-SA/step_3.md b/ar-SA/step_3.md new file mode 100644 index 000000000..078de2dd4 --- /dev/null +++ b/ar-SA/step_3.md @@ -0,0 +1,111 @@ +## ارسم هدفك + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![منطقة المخرجات مع الهدف وحامل الهدف.] +(images/three-circles.png) {"width="300px:} + +
+
+ +### Draw a triangular stand + +--- task --- + +قم بتعيين الألوان للمتغيرات `inner` و `bullseye` باستخدام `color()`. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 18 +line_highlights: 24-25 +--- + + fill(wood) # اضبط لون تعبئة الحامل على البني
+ triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**اختبار:** قم بتشغيل التعليمات برمجية الخاص بك لمعرفة الحامل لهدفك. + +![مثلث بني على العشب وقبالة السماء.](images/target-stand.png){:width="400px"} + +--- /task --- + +### ارسم الهدف + +--- task --- + +**نصيحة:** لعمل دائرة ، يجب أن يكون **العرض** و **ارتفاع** هو نفسه. + +قم بإنشاء متغيرين جديدين لتخزين الألوان `inner` و `bullseye` للدوائر المتبقية. + +Draw a circle with x and y coordinates for its centre and a width. + +![مثلث بني على العشب وضد السماء مع تحديد نقاط الإحداثيات. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 31-32 +--- + + المثلث البني: triangle(50, 150, 200, 250, 180, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**اختبار:** قم بتشغيل التعليمات البرمجية الخاص بك لرؤية أول دائرة زرقاء كبيرة. + +The blue circle was drawn after the stand so it is in front. + +![مثلث بني ودائرة زرقاء على العشب وقبالة السماء.](images/blue-circle.png){:width="400px"} + +--- /task --- + +الهدف مكون من دوائر مختلفة الحجم بنفس إحداثيات المركز (200 ، 200) - منتصف الشاشة. + +--- task --- + +**اختبار:** قم بتشغيل مشروعك مرة أخرى لرؤية الهدف بثلاث دوائر ملونة. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 28 +line_highlights: 33-34 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**تتبع الخطأ:** تستخدم Python التهجئة الأمريكية لـ "color" (بدون "u") لذا تأكد من فعل الشيء نفسه. + +![مثلث بني به ثلاث دوائر ملونة على العشب ومقابل السماء.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/ar-SA/step_4.md b/ar-SA/step_4.md new file mode 100644 index 000000000..4db306a49 --- /dev/null +++ b/ar-SA/step_4.md @@ -0,0 +1,95 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +! [الهدف بسهم دائري بني يظهر في عدة مواضع.] (images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11-12 +--- +# تذهب دالة shoot_arrow هنا +def shoot_arrow(): +global hit_color #يمكن استخدامها في دالة أخرى +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) #احفظ اللون قبل رسم السهم +ellipse(arrow_x, arrow_y, 15, 15) + +--- /code --- + +--- /task --- + +--- task --- + +اذهب إلى الكود `draw()` الذي ينشئ الهدف وأضف الكود في النهاية لتعيين `fill()` إلى `wood`، ثم استدعي وظيفة `shoot_arrow()` الجديدة. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 41 +line_highlights: 44-45 +--- + + def shoot_arrow():
+ ellipse(200, 200, 15, 15) + +--- /code --- + +--- /task --- + +--- task --- + +ابحث عن التعليق **# تنتقل دالة mouse_pressed هنا** وأدناه أضف رمزًا لتعريف دالة `mouse_pressed()`. يتم إعادة رسم السهم في إحداثيات عشوائية. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +انتقل إلى الدالة `shoot_arrow()` وأضف متغيرين جديدين `arrow_x` و `arrow_y` لتخزين الأرقام العشوائية بين `100` و `300`. + +--- code --- +--- +language: python filename: main.py line_numbers: true +line_highlights: 9-10 +--- +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) #احفظ اللون قبل رسم السهم +ellipse(arrow_x, arrow_y, 15, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**اختبار:** قم بتشغيل مشروعك. You should see the arrow jump around the target. + +![الهدف ، مع سهم دائري بني يظهر في مواضع مختلفة.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/ar-SA/step_5.md b/ar-SA/step_5.md new file mode 100644 index 000000000..3f0c1ad17 --- /dev/null +++ b/ar-SA/step_5.md @@ -0,0 +1,84 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +يستخدم من أجل **تخصيص** - مثل `arrow_x = 200` لتعيين قيمة متغير + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 9 +line_highlights: 28 +--- +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == bullseye: +print('You hit the bullseye, 500 points!') + +--- /code --- + +يستخدم لاختبار **تكافؤ** - مثل `hit_color == bullseye` - إذا كانت الأشياء على كلا الجانبين لها نفس القيمة ، فإن الاختبار هو `True`، وإلا فهو `False` + +--- /task --- + +--- task --- + +**اختبار:** قم بتشغيل مشروعك. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 10-11 +--- + + def mouse_pressed():
+ if hit_color == outer:
+ print('You hit the outer circle, 50 points!') + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 12-15 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**اختبار:** قم بتشغيل مشروعك. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/ar-SA/step_6.md b/ar-SA/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/ar-SA/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/ar-SA/step_7.md b/ar-SA/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/ar-SA/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/ar-SA/step_8.md b/ar-SA/step_8.md new file mode 100644 index 000000000..28ae6e382 --- /dev/null +++ b/ar-SA/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /no-print --- diff --git a/ar-SA/step_9.md b/ar-SA/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/ar-SA/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/cs-CZ/code/target-practice-solution/main.py b/cs-CZ/code/target-practice-solution/main.py new file mode 100644 index 000000000..92849950f --- /dev/null +++ b/cs-CZ/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import kódu knihovny + +from p5 import * +from random import randint + + +# Zde je funkce mouse_pressed +def mouse_pressed(): + # print('🎯') + if hit_color == Color("modrá").hex: + print("Trefil jsi vnější kruh, 50 bodů!") + elif hit_colour == Color("červená").hex: + print("Trefil jsi vnitřní kruh, 200 bodů!") + elif hit_colour == Color("žlutá").hex: + print("Trefil jsi střed, 500 bodů!") + else: + print("Vedle! Žádné body!") + + +# Zde je funkce shoot_arrow +def shoot_arrow(): + globální hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Zde si nastav svou hru + size(400, 400) + no_stroke() + + +def draw(): + # Co dělat v každém snímku + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Nakresli vnitřní kruh + fill("yellow") + circle(200, 200, 30) # Nakresli prostřední kruh + shoot_arrow() + + +# Toto si ponech pro spuštění kódu +run(frame_rate=2) diff --git a/cs-CZ/code/target-practice-solution/project_config.yml b/cs-CZ/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..df588078e --- /dev/null +++ b/cs-CZ/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Lukostřelba' +identifier: 'target-practice-solution' +type: 'python' diff --git a/cs-CZ/code/target-practice-starter/main.py b/cs-CZ/code/target-practice-starter/main.py new file mode 100644 index 000000000..4ae5dcba6 --- /dev/null +++ b/cs-CZ/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import kódu knihovny +from p5 import * +from random import randint + +# Zde je funkce mouse_pressed + + +# Zde je funkce shoot_arrow + + +def setup(): + # Zde si nastav svou hru + size(400, 400) + no_stroke() + + +def draw(): + # Co dělat v každém snímku + fill("cyan") + rect(0, 0, 400, 250) + + +# Toto si ponech pro spuštění kódu +run(frame_rate=2) diff --git a/cs-CZ/code/target-practice-starter/project_config.yml b/cs-CZ/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..77eee9e10 --- /dev/null +++ b/cs-CZ/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Lukostřelba starter" +identifier: 'target-practice-starter' +type: 'python' diff --git a/cs-CZ/images/alternative-colours.png b/cs-CZ/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/cs-CZ/images/alternative-colours.png differ diff --git a/cs-CZ/images/arrow-centre.png b/cs-CZ/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/cs-CZ/images/arrow-centre.png differ diff --git a/cs-CZ/images/background.png b/cs-CZ/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/cs-CZ/images/background.png differ diff --git a/cs-CZ/images/banner.png b/cs-CZ/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/cs-CZ/images/banner.png differ diff --git a/cs-CZ/images/blue-circle.png b/cs-CZ/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/cs-CZ/images/blue-circle.png differ diff --git a/cs-CZ/images/blue-points.png b/cs-CZ/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/cs-CZ/images/blue-points.png differ diff --git a/cs-CZ/images/blue_circle_points.gif b/cs-CZ/images/blue_circle_points.gif new file mode 100644 index 000000000..8ab59627f Binary files /dev/null and b/cs-CZ/images/blue_circle_points.gif differ diff --git a/cs-CZ/images/bottom-right.png b/cs-CZ/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/cs-CZ/images/bottom-right.png differ diff --git a/cs-CZ/images/centre.png b/cs-CZ/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/cs-CZ/images/centre.png differ diff --git a/cs-CZ/images/circle-coords.png b/cs-CZ/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/cs-CZ/images/circle-coords.png differ diff --git a/cs-CZ/images/fire_arrow.gif b/cs-CZ/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/cs-CZ/images/fire_arrow.gif differ diff --git a/cs-CZ/images/green-grass.png b/cs-CZ/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/cs-CZ/images/green-grass.png differ diff --git a/cs-CZ/images/missed_no_points.gif b/cs-CZ/images/missed_no_points.gif new file mode 100644 index 000000000..8ab59627f Binary files /dev/null and b/cs-CZ/images/missed_no_points.gif differ diff --git a/cs-CZ/images/points-scored.gif b/cs-CZ/images/points-scored.gif new file mode 100644 index 000000000..8ab59627f Binary files /dev/null and b/cs-CZ/images/points-scored.gif differ diff --git a/cs-CZ/images/quiz-colour.png b/cs-CZ/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/cs-CZ/images/quiz-colour.png differ diff --git a/cs-CZ/images/random-side.png b/cs-CZ/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/cs-CZ/images/random-side.png differ diff --git a/cs-CZ/images/showcase_rocket.png b/cs-CZ/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/cs-CZ/images/showcase_rocket.png differ diff --git a/cs-CZ/images/sky_stroke.png b/cs-CZ/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/cs-CZ/images/sky_stroke.png differ diff --git a/cs-CZ/images/stand_coords.png b/cs-CZ/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/cs-CZ/images/stand_coords.png differ diff --git a/cs-CZ/images/target-stand.png b/cs-CZ/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/cs-CZ/images/target-stand.png differ diff --git a/cs-CZ/images/target_area.png b/cs-CZ/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/cs-CZ/images/target_area.png differ diff --git a/cs-CZ/images/target_printed.gif b/cs-CZ/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/cs-CZ/images/target_printed.gif differ diff --git a/cs-CZ/images/three-circles.png b/cs-CZ/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/cs-CZ/images/three-circles.png differ diff --git a/cs-CZ/images/top-left.png b/cs-CZ/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/cs-CZ/images/top-left.png differ diff --git a/cs-CZ/images/upgrade-ideas.png b/cs-CZ/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/cs-CZ/images/upgrade-ideas.png differ diff --git a/cs-CZ/images/yellow-points.png b/cs-CZ/images/yellow-points.png new file mode 100644 index 000000000..4c265e182 Binary files /dev/null and b/cs-CZ/images/yellow-points.png differ diff --git a/cs-CZ/meta.yml b/cs-CZ/meta.yml new file mode 100644 index 000000000..e35ffa65f --- /dev/null +++ b/cs-CZ/meta.yml @@ -0,0 +1,41 @@ +--- +title: Lukostřelba +hero_image: images/banner.png +description: Použij Python k nakreslení cíle a získej body tím, že do něj zasáhneš šípy +meta_title: Projekty kódování Python pro děti a dospívající | Lukostřelba +meta_description: Nauč se Python s projekty kódování pro děti a dospívající nadace Raspberry Pi Foundation. Použij Python k nakreslení cíle a zaznamenávej body tím, že ho zasáhneš šípy. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Co budeš dělat + - + title: Nakresli trávu + - + title: Nakresli terč + completion: + - engaged + - + title: Přidej šíp + - + title: Jakou barvu jsi trefil? + - + title: Získej body + completion: + - internal + - + title: Rychlý kvíz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Výzva + challenge: true + - + title: Co můžeš dělat dál? diff --git a/cs-CZ/python-comments.txt b/cs-CZ/python-comments.txt new file mode 100644 index 000000000..607c4f841 --- /dev/null +++ b/cs-CZ/python-comments.txt @@ -0,0 +1,27 @@ +Co dělat v každém snímku + +Nakreslete vnitřní kruh + +Nakreslete střední kruh + +Zde je funkce shoot_arrow + +Zde je funkce mouse_pressed + +Trefil jsi vnější kruh, 50 bodů! + +Trefil jsi vnitřní kruh, 200 bodů! + +Trefil jsi střed, 500 bodů! + +Trefil jsi střed, 500 bodů! + +Netrefil jsi! Bez bodů! + +Super rychlé + +Docela rychle + +Velmi rychle + +Rychlost nebyla rozpoznána! \ No newline at end of file diff --git a/cs-CZ/python-translatable.txt b/cs-CZ/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/cs-CZ/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/cs-CZ/quiz1/question_1.md b/cs-CZ/quiz1/question_1.md new file mode 100644 index 000000000..6a1b793dc --- /dev/null +++ b/cs-CZ/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Rychlý kvíz + +Odpovězte na tři otázky. Existují tipy, které vás dovedou ke správné odpovědi. + +Po zodpovězení každé otázky klikněte na **Zkontrolujte moji odpověď**. + +Příjemnou zábavu! + +--- question --- +--- +legend: Otázka 1 ze 3 +--- +Ve svém projektu jsi přidal `randint(100, 300)` do funkce `shoot_arrow()`. Co dělá `randint(100, 300)`? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) Vybere náhodné celé číslo mezi 100 a 300. + + --- feedback --- + +Správně. Tím vyberete náhodnou souřadnici x pro vaši šipku. + + --- /feedback --- + +- ( ) Způsobí, že se šipka náhodně pohybuje po obrazovce. + + --- feedback --- + +Ne tak docela. Tento kód je součástí toho, jak se šipka pohybuje náhodně, ale k dosažení tohoto cíle potřebujete také jiný kód. + + --- /feedback --- + +- () Získá barvu, kterou zasáhla šipka. + + --- feedback --- + + Ne tak docela. K získání barvy by se použila funkce get(). + + --- /feedback --- + +- ( ) Nakreslí kruh náhodné velikosti. + + --- feedback --- + + Ne tak docela. K nakreslení kruhu lze použít funkci circle(). + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/cs-CZ/quiz1/question_2.md b/cs-CZ/quiz1/question_2.md new file mode 100644 index 000000000..f3f151eae --- /dev/null +++ b/cs-CZ/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Otázka 2 ze 3 +--- + +Ve svém projektu jsi použil `if` , `elif` and `else` , abys zkontroloval, na kterou barvu šipka přistála. + +V níže uvedeném příkladu má proměnná s názvem `speed` uloženu hodnotu `6`. Když je spuštěn příkaz `if`, co se vytiskne ve výstupní oblasti? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super rychlá') elif speed == 5: print('Docela rychlá') elif speed == 6: print('Velmi rychlá') else: print('Rychlost nebyla rozpoznána!') + +--- /code --- + +--- choices --- + +- (x) `Velmi rychlá` + + --- feedback --- + + Správně! Proměnné **speed** byla přiřazena hodnota `6`. Podmínka `speed == 6` bude vyhodnocena jako **True** a tím pádem bude vytisknuto `Very fast`. + + --- /feedback --- + +- ( ) `Rychlost nebyla rozpoznána!` + + --- feedback --- + + Ne tak docela. Podívej se na hodnotu přiřazenou proměnné **speed**. + + --- /feedback --- + +- ( ) Nic se nevytiskne + + --- feedback --- + + Zkus to znovu, `else` se použije jako poslední možnost, když jsou všechny výše uvedené podmínky nepravdivé. Prohlédni si znovu podmínky, jsou některé z podmínek pravdivé? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/cs-CZ/quiz1/question_3.md b/cs-CZ/quiz1/question_3.md new file mode 100644 index 000000000..0511e1a22 --- /dev/null +++ b/cs-CZ/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Otázka 3 ze 3 +--- + +Kruh se nakreslí pomocí následujícího kódu: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Který z obrázků níže ukazuje správnou polohu tohoto kruhu ve výstupní oblasti? + +--- choices --- + +- ( ) ![Zelený kruh se středem v pravém dolním rohu výstupní oblasti.](images/bottom-right.png) + + --- feedback --- + + Ne tak docela, pro vycentrování kruhu v pravém dolním rohu by souřadnice musely být stejné jako velikost obrazovky. V tomto příkladu by elipsa byla `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Zelený kruh uprostřed oblasti výstupu.](images/centre.png) + + --- feedback --- + + Ne tak docela, aby se kruh vycentroval na střed, souřadnice by musely být poloviční velikosti obrazovky. V tomto příkladu `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Zelený kruh se středem v levém horním rohu výstupní oblasti.](images/top-left.png) + + --- feedback --- + + Správně! Tento kruh je vycentrován na souřadnicích (0,0), v levém horním rohu obrazovky. + + --- /feedback --- + +- ( ) ![Zelený kruh se středem směrem k pravé horní straně výstupní oblasti.](images/random-side.png) + + --- feedback --- + + Ne, tento kruh by měl kód `circle(350, 150, 300)`, aby byl vycentrován směrem k pravé horní části obrazovky. Souřadnice `x` udává, jak daleko přes obrazovku je elipsa, a souřadnice `y` je, jak daleko je na obrazovce. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/cs-CZ/step_1.md b/cs-CZ/step_1.md new file mode 100644 index 000000000..a1f0966bb --- /dev/null +++ b/cs-CZ/step_1.md @@ -0,0 +1,29 @@ +## Co budeš dělat + +Použijte Python k nakreslení cíle a získejte body tím, že do něj zasáhnete šipkami. + +--- print-only --- + +![Lukostřelecký terč se zásahovým bodem na vnějším kruhu. Text „Trefil jsi vnější kruh, 50 bodů!“ se zobrazuje vespod](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Hru spustíte kliknutím na tlačítko **Spustit** níže. Když se tečka objeví na cíli 🎯, klikněte myší (nebo klepněte na tablet) a vystřelte šíp. + + +
+
+ +--- /no-print --- + +
+ Zúčastněte se našeho průzkumu a pomozte nám zlepšit náš editor kódu! +
+ + + diff --git a/cs-CZ/step_2.md b/cs-CZ/step_2.md new file mode 100644 index 000000000..161743b85 --- /dev/null +++ b/cs-CZ/step_2.md @@ -0,0 +1,37 @@ +## Nakreslete trávu + +--- task --- + +Otevřete projekt [Target practice starter](https://editor.raspberrypi.org/cs-CZ/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Přidejte kód** a nakreslete ve spodní části obrazovky zelený obdélník, který bude představovat trávu. + +![Výstupní oblast s obdélníkem barvy nebe nad obdélníkem barvy trávy pro vytvoření pozadí. Levý horní roh obdélníku je označen jako x=0, y=250 toto je počátek obdélníku. Šířka je zvýrazněna jako 400 a výška jako 150. Zobrazí se kód rect(0, 250, 400, 150).](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Spusťte svůj projekt a zobrazte pozadí. + +![Výstupní oblast s obdélníkem barvy nebe nad obdélníkem barvy trávy pro vytvoření pozadí.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/cs-CZ/step_3.md b/cs-CZ/step_3.md new file mode 100644 index 000000000..662301986 --- /dev/null +++ b/cs-CZ/step_3.md @@ -0,0 +1,115 @@ +## Nakresli terč + +
+
+Vaše hra potřebuje cíl, na který budete střílet šípy. +
+
+ +![Výstupní oblast s cílem a stojanem.](images/three-circles.png){:width="300px"} + +
+
+ +### Nakresli trojúhelníkový stojan + +--- task --- + +Nastav barvu výplně na `brown`. + +Nakresli trojúhelník pomocí souřadnic x a y pro každý z rohů. + +![Hnědý trojúhelník na trávě a proti obloze se souřadnicovými body označenými jako 150, 350 a 200, 150 a 250, 350). Rohy plátna jsou také označeny jako x=0, y=0 vlevo nahoře a x=400, y=400 vpravo dole.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Spusťte svůj kód, abyste viděli stojan pro svůj cíl: + +![Hnědý trojúhelník na trávě a proti obloze.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Nakresli kruhy terče + +--- task --- + +Největší část terče je modrý **kruh**. + +Nastav barvu výplně na `blue`. + +Nakresli kružnici se souřadnicemi x a y pro její střed a šířku. + +![Hnědý trojúhelník a modrý kruh na trávě a proti obloze. Kruh je označen souřadnicemi x=200, y=200 jako střed a šířka kruhu 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Spusťte svůj kód a uvidíte první velký modrý kruh. + +Modrý kruh byl nakreslen až když, byl nakreslen stojan, takže je vpředu. + +![Hnědý trojúhelník a modrý kruh na trávě a proti obloze.](images/blue-circle.png){:width="400px"} + +--- /task --- + +Terč je vyroben z různě velkých kruhů se stejnými středovými souřadnicemi (200, 200). + +--- task --- + +**Přidejte** barevné kruhy pro vnitřní a střední části terče. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Spusťte svůj projekt, abyste viděli cíl se třemi barevnými kruhy. + +![Hnědý trojúhelník se třemi barevnými kruhy na trávě a proti obloze.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/cs-CZ/step_4.md b/cs-CZ/step_4.md new file mode 100644 index 000000000..dfbc54d68 --- /dev/null +++ b/cs-CZ/step_4.md @@ -0,0 +1,88 @@ +## Přidejte šíp + +
+
+Přidejte ještě menší kruh, který bude představovat šíp. +
+
+ +![Cíl s hnědou kruhovou šipkou objevující se v různých pozicích.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Kam budeš střílet? + +--- task --- + +Přidej funkci pro nakreslení hnědého kruhu na souřadnicích `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Na konci funkce `draw()`{:.language-python} zavolejte svou novou funkci `shoot_arrow()`{:.language-python}. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Měli byste vidět šíp uprostřed. + +![kruh s hnědou šipkou ve středu terče](images/arrow-centre.png) + + +--- /task --- + +Šíp se musí pohybovat náhodně. + + +--- task --- + +Změňte proměnné `arrow_x`{:.language-python} a `arrow_y`{:.language-python} a vyberte náhodné číslo mezi 100 a 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Klikněte na tlačítko **Spustit**. Měl bys vidět, jak šíp přeskakuje kolem cíle. + +![Animace cíle s hnědou kruhovou šipkou objevující se v různých pozicích.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/cs-CZ/step_5.md b/cs-CZ/step_5.md new file mode 100644 index 000000000..ec47531d6 --- /dev/null +++ b/cs-CZ/step_5.md @@ -0,0 +1,80 @@ +## Jakou barvu jsi trefil? + +Dále přidej nějaký kód, ať získáš barvu v místě šípu. + +### Získej barvu zasaženou šipkou + +--- task --- + +Přidej novou **globální proměnnou** s názvem `hit_color`. + +Přidej část kódu, ať `získáte` barvu ve středu šipky a uložte ji do proměnné `hit_color` . + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** Kód pro `získání` barvy musí být **před kódem**, který kreslí kruh, jinak vždy uložíte hnědou barvu šípu! + +--- /task --- + +--- task --- + +**Test:** Klikněte na tlačítko **Spustit**. Měli byste vidět barvy tištěné ve formátu **Textového výstupu**, v hexadecimálním formátu. + +--- /task --- + +### Spusť kód kliknutím myši + +--- task --- + +Zakomentujte řádek, který tiskne barvu. To znamená, že nepoběží. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Přidej kód pro tisk cílového emoji 🎯 **po kliknutí myší**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klikněte na tlačítko **Spustit**. Když klikneš myší na cíl, měl bys vidět vytištěný znak 🎯. + +![cílové emotikony vytištěné po kliknutí myší](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/cs-CZ/step_6.md b/cs-CZ/step_6.md new file mode 100644 index 000000000..7d0d38a17 --- /dev/null +++ b/cs-CZ/step_6.md @@ -0,0 +1,112 @@ +## Body + +
+
+Přidej skóre podle toho, kam dopadne šíp. +
+
+ +![Animace cíle se šipkou na různých pozicích a skóre jako text pod hrou.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Zakomentuj řádek pro tisk znaku 🎯, aby již neběžel. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Zobrazte zprávu **if** `hit_color`{:.language-python} se rovná `barvě vnějšího` kruhu (modrá). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** Pokud jsi změnil barvu vnějšího kruhu, budeš muset nahradit `modrou` názvem barvy, kterou jsi vybral. + +--- /task --- + +--- task --- + +**Test:** Klikni na tlačítko **Spustit**. Počkejte, až šíp přistane na modrém kruhu, a poté klikni levým tlačítkem myši. ![body získané po kliknutí na modrý kruh](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} lze použít k přidání dalších podmínek k tvému `if`{:.language-python}. + +--- task --- + +Přidejte další kód, abyste získali body, pokud šíp dopadne na **vnitřní** nebo **prostřední** kruhy. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klikněte na tlačítko **Spustit**. Kdykoli zasáhneš cíl, měli byste získat body. + +![body se získávají v jakékoli oblasti cíle](images/yellow-points.png) + +--- /task --- + +### Vedle + +Musíte udělat ještě jedno rozhodnutí: co se stane, když šíp nedopadne na žádný z cílových kruhů? + +Musíte udělat ještě jedno rozhodnutí: co se stane, když šíp nedopadne na žádný z cílových kruhů? + +--- task --- + +Přidejte kód do `print` zprávu, když žádný z `, pokud` a `elif` není pravdivý. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klikněte na tlačítko **Spustit**. Vystřelte šíp do trávy nebo na oblohu, abyste viděli zprávu o chybě. + +![žádné body se tisknou mimo cíl](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/cs-CZ/step_7.md b/cs-CZ/step_7.md new file mode 100644 index 000000000..4b195a338 --- /dev/null +++ b/cs-CZ/step_7.md @@ -0,0 +1 @@ +## Rychlý kvíz \ No newline at end of file diff --git a/cs-CZ/step_8.md b/cs-CZ/step_8.md new file mode 100644 index 000000000..ba2e1f941 --- /dev/null +++ b/cs-CZ/step_8.md @@ -0,0 +1,36 @@ +## Výzva + +--- challenge --- + + +Můžeš: + + +--- task --- + +Přidej `čtvrtý` a `pátý` kruh v nových barvách, které získávají různý počet bodů podle své pozice + +--- /task --- + +--- task --- + +Vlož emotikony do tištěných zpráv ([zde je seznam emotikonů](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"}, ze kterých můžete kopírovat) + +--- /task --- + +--- task --- + +Usnadni nebo zvyš obtížnost hry změnou hodnoty `frame_rate=2` + + +--- /task --- + +--- úkol --- + +Chceš-li sledovat celkové skóre, přidej proměnnou a pokaždé k ní přidej správný počet bodů. + +--- /task --- + + + +--- /challenge --- diff --git a/cs-CZ/step_9.md b/cs-CZ/step_9.md new file mode 100644 index 000000000..017862c63 --- /dev/null +++ b/cs-CZ/step_9.md @@ -0,0 +1,21 @@ +## Co můžeš teď dělat? + +Pokud postupuješ po cestě [Úvod do Pythonu](https://projects.raspberrypi.org/en/raspberrypi/python-intro), můžeš přejít k projektu [Spuštění rakety](https://projects.raspberrypi.org/en/projects/rocket-launch). V tomto projektu vytvoříš interaktivní animaci rakety vynášející satelit na oběžnou dráhu. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Kliknutím na tlačítko **Spustit** zobrazíš příklad tohoto projektu. + + + +\--- /no-print --- + +Nebo proč nezkusit jiný [Python](https://projects.raspberrypi.org/cs-CZ/projects?software%5B%5D=python) projekt. + diff --git a/cy-GB/code/target-practice-solution/main.py b/cy-GB/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/cy-GB/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/cy-GB/code/target-practice-solution/project_config.yml b/cy-GB/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/cy-GB/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/cy-GB/code/target-practice-starter/main.py b/cy-GB/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/cy-GB/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/cy-GB/code/target-practice-starter/project_config.yml b/cy-GB/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/cy-GB/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/cy-GB/images/alternative-colours.png b/cy-GB/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/cy-GB/images/alternative-colours.png differ diff --git a/cy-GB/images/animation_bg_erase.gif b/cy-GB/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/cy-GB/images/animation_bg_erase.gif differ diff --git a/cy-GB/images/animation_no_bg_erase.gif b/cy-GB/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/cy-GB/images/animation_no_bg_erase.gif differ diff --git a/cy-GB/images/arrow-centre.png b/cy-GB/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/cy-GB/images/arrow-centre.png differ diff --git a/cy-GB/images/arrow-middle.png b/cy-GB/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/cy-GB/images/arrow-middle.png differ diff --git a/cy-GB/images/arrow-target.png b/cy-GB/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/cy-GB/images/arrow-target.png differ diff --git a/cy-GB/images/background.png b/cy-GB/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/cy-GB/images/background.png differ diff --git a/cy-GB/images/banner.png b/cy-GB/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/cy-GB/images/banner.png differ diff --git a/cy-GB/images/blue-circle.png b/cy-GB/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/cy-GB/images/blue-circle.png differ diff --git a/cy-GB/images/blue-points.png b/cy-GB/images/blue-points.png new file mode 100644 index 000000000..9525d841a Binary files /dev/null and b/cy-GB/images/blue-points.png differ diff --git a/cy-GB/images/blue_circle_points.gif b/cy-GB/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/cy-GB/images/blue_circle_points.gif differ diff --git a/cy-GB/images/bottom-right.png b/cy-GB/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/cy-GB/images/bottom-right.png differ diff --git a/cy-GB/images/centre.png b/cy-GB/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/cy-GB/images/centre.png differ diff --git a/cy-GB/images/circle-coords.png b/cy-GB/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/cy-GB/images/circle-coords.png differ diff --git a/cy-GB/images/coords_animation.gif b/cy-GB/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/cy-GB/images/coords_animation.gif differ diff --git a/cy-GB/images/difficulty-setting.png b/cy-GB/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/cy-GB/images/difficulty-setting.png differ diff --git a/cy-GB/images/fire_arrow.gif b/cy-GB/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/cy-GB/images/fire_arrow.gif differ diff --git a/cy-GB/images/five_circles.png b/cy-GB/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/cy-GB/images/five_circles.png differ diff --git a/cy-GB/images/green-grass.png b/cy-GB/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/cy-GB/images/green-grass.png differ diff --git a/cy-GB/images/grey-circle.png b/cy-GB/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/cy-GB/images/grey-circle.png differ diff --git a/cy-GB/images/grey-points.png b/cy-GB/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/cy-GB/images/grey-points.png differ diff --git a/cy-GB/images/initial_target.png b/cy-GB/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/cy-GB/images/initial_target.png differ diff --git a/cy-GB/images/missed-points.png b/cy-GB/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/cy-GB/images/missed-points.png differ diff --git a/cy-GB/images/missed_no_points.gif b/cy-GB/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/cy-GB/images/missed_no_points.gif differ diff --git a/cy-GB/images/outline-circles.png b/cy-GB/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/cy-GB/images/outline-circles.png differ diff --git a/cy-GB/images/points-scored.gif b/cy-GB/images/points-scored.gif new file mode 100644 index 000000000..a3630510f Binary files /dev/null and b/cy-GB/images/points-scored.gif differ diff --git a/cy-GB/images/quiz-colour.png b/cy-GB/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/cy-GB/images/quiz-colour.png differ diff --git a/cy-GB/images/random-side.png b/cy-GB/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/cy-GB/images/random-side.png differ diff --git a/cy-GB/images/rectangle-diagram.png b/cy-GB/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/cy-GB/images/rectangle-diagram.png differ diff --git a/cy-GB/images/showcase_rocket.png b/cy-GB/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/cy-GB/images/showcase_rocket.png differ diff --git a/cy-GB/images/showcase_static.png b/cy-GB/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/cy-GB/images/showcase_static.png differ diff --git a/cy-GB/images/sky_coords.png b/cy-GB/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/cy-GB/images/sky_coords.png differ diff --git a/cy-GB/images/sky_stroke.png b/cy-GB/images/sky_stroke.png new file mode 100644 index 000000000..0d088147f Binary files /dev/null and b/cy-GB/images/sky_stroke.png differ diff --git a/cy-GB/images/stand_coords.png b/cy-GB/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/cy-GB/images/stand_coords.png differ diff --git a/cy-GB/images/step_4_preview.gif b/cy-GB/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/cy-GB/images/step_4_preview.gif differ diff --git a/cy-GB/images/step_5_preview.gif b/cy-GB/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/cy-GB/images/step_5_preview.gif differ diff --git a/cy-GB/images/target-stand.png b/cy-GB/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/cy-GB/images/target-stand.png differ diff --git a/cy-GB/images/target_area.png b/cy-GB/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/cy-GB/images/target_area.png differ diff --git a/cy-GB/images/target_printed.gif b/cy-GB/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/cy-GB/images/target_printed.gif differ diff --git a/cy-GB/images/three-circles.png b/cy-GB/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/cy-GB/images/three-circles.png differ diff --git a/cy-GB/images/top-left.png b/cy-GB/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/cy-GB/images/top-left.png differ diff --git a/cy-GB/images/triangles-coords.png b/cy-GB/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/cy-GB/images/triangles-coords.png differ diff --git a/cy-GB/images/upgrade-ideas.png b/cy-GB/images/upgrade-ideas.png new file mode 100644 index 000000000..747bbe19d Binary files /dev/null and b/cy-GB/images/upgrade-ideas.png differ diff --git a/cy-GB/images/yellow-points.png b/cy-GB/images/yellow-points.png new file mode 100644 index 000000000..354e085ff Binary files /dev/null and b/cy-GB/images/yellow-points.png differ diff --git a/cy-GB/meta.yml b/cy-GB/meta.yml new file mode 100644 index 000000000..9d8f62813 --- /dev/null +++ b/cy-GB/meta.yml @@ -0,0 +1,41 @@ +--- +title: Ymarfer saethu +hero_image: images/banner.png +description: Defnyddiwch Python i lunio targed a sgorio pwyntiau drwy ei daro â saethau +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Cyflwyniad + - + title: Creu cefndir + - + title: Llunio eich targed + completion: + - engaged + - + title: Saethu + - + title: Sgorio pwyntiau + - + title: Myfyrio + completion: + - external + - + title: Uwchraddio eich brosiect + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Beth nesaf? + challenge: true + - + title: What can you do now? diff --git a/cy-GB/python-comments-demo.txt b/cy-GB/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/cy-GB/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/cy-GB/python-comments.txt b/cy-GB/python-comments.txt new file mode 100644 index 000000000..9dd839a99 --- /dev/null +++ b/cy-GB/python-comments.txt @@ -0,0 +1,27 @@ +Pethau i'w gwneud ym mhob ffrâm + +Draw the inner circle + +Draw the middle circle + +Mae'r swyddogaeth saethu_saeth yn mynd fan hyn + +Mae'r swyddogaeth mouse_pressed yn mynd fan hyn + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/cy-GB/python-translatable-demo.txt b/cy-GB/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/cy-GB/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/cy-GB/python-translatable.txt b/cy-GB/python-translatable.txt new file mode 100644 index 000000000..006321631 --- /dev/null +++ b/cy-GB/python-translatable.txt @@ -0,0 +1,9 @@ +saethu_saeth + +saeth_x + +saeth_y + +hit_colour + +speed \ No newline at end of file diff --git a/cy-GB/quiz1/question_1.md b/cy-GB/quiz1/question_1.md new file mode 100644 index 000000000..d2a38d25d --- /dev/null +++ b/cy-GB/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Beth nesaf? + +Answer the three questions. There are hints to guide you to the correct answer. + +Atebwch y tri chwestiwn isod i fyfyrio ar yr hyn rydych chi wedi'i ddysgu. + +Ar ôl bob cwestiwn, pwyswch **cyflwyno**. Byddi di'n cael dy dywys i'r ateb cywir. Galli di wneud hyn gymaint ag y mynni. + +--- question --- +--- +legend: Cwestiwn 1 o 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +Dyma sgŵar glas. Beth yw'r gwerthoedd RGB a fydd yn ei greu? +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/cy-GB/quiz1/question_2.md b/cy-GB/quiz1/question_2.md new file mode 100644 index 000000000..59218a361 --- /dev/null +++ b/cy-GB/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Cwestiwn 2 o 3 +--- + +Yn eich prosiect roeddech chi wedi defnyddio'r amodau `if` , `elif`, ac `else` i wirio ar ba liw glaniodd y saeth. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +cyflymder = 6 + +if cyflymder == 7: print('Cyflym iawn iawn') elif cyflymder == 5: print('Eithaf cyflym') elif cyflymder == 6: print('Cyflym iawn') else: print('Heb adnabod y cyflymder!') + +--- /code --- + +--- choices --- + +- (x) `Cyflym iawn` + + --- feedback --- + + Cywir! Mae'r gwerth `6` wedi cael ei neilltuo i'r newidyn **cyflymder**, sy'n golygu mai **True** yw'r amod `cyflymder == 6` a bydd yn printio `Cyflym iawn`. + + --- /feedback --- + +- ( ) `Heb adnabod y cyflymder!` + + --- feedback --- + + Ddim yn hollol, 'drychwch ar y gwerth sydd wedi'i neilltuo i'r newidyn **cyflymder**. + + --- /feedback --- + +- ( ) Dim byd yn cael ei brintio + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/cy-GB/quiz1/question_3.md b/cy-GB/quiz1/question_3.md new file mode 100644 index 000000000..0ed40738f --- /dev/null +++ b/cy-GB/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Cwestiwn 3 o 3 +--- + +Mae elips yn cael ei lunio gan ddefnyddio'r cod canlynol: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0,255,0) +no_stroke() + +def draw(): +ellipse(0,0,300,300) + +run() + +--- /code --- + +Pa un o'r lluniau isod sy'n dangos safle cywir yr elips yn yr ardal allbwn? + +--- choices --- + +- ( ) ![Cylch gwyrdd â'i ganol yng nghornel dde isaf yr ardal allbwn.](images/bottom-right.png) + + --- feedback --- + + Ddim yn hollol. I gael canol y cylch yn y gornel dde isaf, byddai angen i'r cyfesurynnau fod yr un peth â maint y sgrin. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Cylch gwyrdd â'i ganol yng nghanol yr ardal allbwn.](images/centre.png) + + --- feedback --- + + Ddim yn hollol. I gael canol y cylch yn y canol, byddai angen i'r cyfesurynnau fod hanner maint y sgrin. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Cylch gwyrdd â'i ganol yng nghornel chwith uchaf yr ardal allbwn.](images/top-left.png) + + --- feedback --- + + Cywir! Cyfesurynnau canol y cylch yw (0,0), cornel chwith uchaf y sgrin. + + --- /feedback --- + +- ( ) ![Cylch gwyrdd â'i ganol tua chornel dde uchaf yr ardal allbwn.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. Mae'r cyfesuryn `x` yn dangos pa mor bell ar draws y sgrin mae'r elips, a'r cyfesuryn `y` yw pa mor bell i lawr y sgrin mae'r elips. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/cy-GB/resources/main.py b/cy-GB/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/cy-GB/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/cy-GB/resources/p5.py b/cy-GB/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/cy-GB/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/cy-GB/step_1.md b/cy-GB/step_1.md new file mode 100644 index 000000000..13421dca6 --- /dev/null +++ b/cy-GB/step_1.md @@ -0,0 +1,29 @@ +## Cyflwyniad + +Defnyddiwch Python, a'r llyfrgell graffeg `p5`, i lunio targed a sgorio pwyntiau drwy ei daro â saethau. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/cy-GB/step_2.md b/cy-GB/step_2.md new file mode 100644 index 000000000..797407dcb --- /dev/null +++ b/cy-GB/step_2.md @@ -0,0 +1,37 @@ +## Creu cefndir + +--- task --- + +Agorwch y [prosiect dechreuol Saethyddiaeth](https://trinket.io/python/23a6f02447){:target="_blank"}. + +--- /task --- + +--- task --- + +Mae rhywfaint o god wedi'i ysgrifennu i chi yn barod yn y prosiect dechreuol er mwyn i chi fewngludo'r llyfrgell `p5`. Byddwch yn defnyddio'r llyfrgell hon i adeiladu eich gêm saethyddiaeth. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png)Mae'r swyddogaeth `fill()` yn gosod y lliw tu mewn i'r siapiau. Mae'r prosiect dechreuol eisoes yn cynnwys rhai lliwiau RGB gallwch chi eu defnyddio i wneud hyn. + +--- code --- +--- +Mae'r swyddogaeth `fill()` yn gosod y lliw tu mewn i'r siapiau. Mae'r prosiect dechreuol eisoes yn cynnwys rhai lliwiau RGB gallwch chi eu defnyddio i wneud hyn. +line_highlights: 25 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +fill(awyr) + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/cy-GB/step_3.md b/cy-GB/step_3.md new file mode 100644 index 000000000..fe72e4689 --- /dev/null +++ b/cy-GB/step_3.md @@ -0,0 +1,115 @@ +## Llunio eich targed + +
+
+Siâp triongl yw stand y targed. Mae'r targed yn cael ei wneud â chylchoedd lliw — mae'r cylchoedd llai werth mwy o bwyntiau na'r rhai mwy. +
+
+ +![Yr ardal allbwn gyda'r targed a'r stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Llunio'r stand + +--- task --- + +Dychmygwch dorri'r holl siapiau allan o bapur. Yn dibynnu ar sut rydych chi'n trefnu ac yn croesi'r papur hwnnw, gallai'r canlyniad edrych yn wahanol iawn. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png)Pan fyddwch yn galw'r swyddogaeth `triangle()`, rhaid i chi ddarparu tair set o gyfesurynnau, `x1, y1, x2, y2, x3, y3` lle mae pob un yn cynrychioli un o gorneli'r triongl. + +--- code --- +--- +Dyma dri triongl enghreifftiol ac mae gan bob un set wahanol o gyfesurynnau. 'Drychwch ar safle grid pob un i weld sut mae'r cyfesurynnau `x` a `y` yn lleoli corneli'r trionglau: +title: Cyfesurynnau triongl +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png)language: python filename: main.py - draw() line_numbers: true line_number_start: 28 + +--- /task --- + +### Llunio'r targed + +--- task --- + +The largest part of the target is a blue **circle**. + +**Cyngor:** Rydyn ni wedi ychwanegu sylwadau at ein cod, fel `#Gosod lliw llenwi'r stand ar frown`, i roi gwybod i chi beth mae'n ei wneud. Does dim rhaid i chi ychwanegu'r sylwadau hyn at eich cod, ond maen nhw'n gallu bod yn ddefnyddiol i'ch atgoffa beth mae llinellau cod yn ei wneud. + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 31-32 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +Mae angen cyfesurynnau `x` ac `y`, lled ac uchder ar elips. Safle'r canol yw cyfesurynnau `x` ac `y` elips. + +Bydd y cylch glas yn gorchuddio'r triongl brown lle maen nhw'n gorgyffwrdd, oherwydd bod y cylch wedi'i lunio'n ddiweddarach. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png)**Cyngor:** I wneud cylch, rhaid i'r **lled** a'r **uchder** fod yr un fath. + +--- /task --- + +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 33-34 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png)Ewch ati i greu dau newidyn newydd i storio'r lliwiau `mewnol` a `canol_y_nod` ar gyfer y cylchoedd sy'n weddill. + +--- /task --- + +--- save --- diff --git a/cy-GB/step_4.md b/cy-GB/step_4.md new file mode 100644 index 000000000..7852d0f0a --- /dev/null +++ b/cy-GB/step_4.md @@ -0,0 +1,87 @@ +## Saethu + +
+
+Nawr mae'n amser ychwanegu saeth sy'n symud ar hap ar draws yr ardal targed. +
+
+ +![Y targed, gyda chylch brown, y saeth, yn ymddangos mewn amrywiaeth o safleoedd.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Cael y lliw mae'r saeth yn ei daro + +--- task --- + +Dewch o hyd i'r sylw **#Mae'r swyddogaeth saethu_saeth yn mynd fan hyn** ac ychwanegu cod oddi tano i ddiffinio eich swyddogaeth `saethu_saeth()`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 11-12 +--- +# Mae'r swyddogaeth saethu_saeth yn mynd fan hyn +language: python filename: main.py — saethu_saeth() line_numbers: true line_number_start: 10 + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 44-45 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +**Profi:** Rhedwch eich cod a gweld y saeth yn ymddangos yng nghanol y nod. + + +--- task --- + +Mae gemau cyfrifiadur, fideos ac animeiddiadau'n creu effaith symud drwy ddangos llawer o ddelweddau un ar ôl y llall. Ffrâm yw enw pob delwedd. Cyfradd fframiau yw enw'r cyflymder mae'r ddelwedd yn newid ac mae'n cael ei rhoi mewn fps, sef fframiau yr eiliad (frames per second). + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_number_start: 3 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![Y targed ar gefndir gyda chylch brown, y saeth, arno.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/cy-GB/step_5.md b/cy-GB/step_5.md new file mode 100644 index 000000000..b81df359c --- /dev/null +++ b/cy-GB/step_5.md @@ -0,0 +1,86 @@ +## Sgorio pwyntiau + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +language: python filename: main.py line_numbers: true line_number_start: 26 + + +--- code --- +--- +global allanol, mewnol, canol_y_nod +awyr = color(92, 204, 206) #Coch = 92, Gwyrdd = 204, Glas = 206 +gwair = color(149, 212, 122) +pren = color(145, 96, 51) +allanol = color(0, 120, 180) +mewnol = color(210, 60, 60) +canol_y_nod = color(220, 200, 0) +line_highlights: 28 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +Rydyn ni'n defnyddio amodau i wneud penderfyniadau drwy'r amser. Pethau fel 'os nad oes min ar y pensil, mae angen ei finio'. Yn debyg, mae amodau `if` yn gadael i ni ysgrifennu cod sy'n gwneud pethau gwahanol yn dibynnu a yw'r amod yn wir neu ddim. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +def mouse_pressed(): +if lliw_taro == allanol: +print('Ti wedi taro'r cylch allanol, 50 pwynt!') #Fel swyddogaethau, mae datganiadau 'if' yn cael eu mewnoli +line_highlights: 10-11 +--- + + global allanol, mewnol, canol_y_nod + +--- /code --- + +--- /task --- + +--- task --- + +**Cyngor:** Mae `frame_rate()` yn `setup()` yn rheoli pa mor gyflym mae eich gêm yn llunio. Os yw'n mynd yn rhy gyflym, rhowch rif is. + +--- code --- +--- +**Cyngor:** Mae `frame_rate()` yn `setup()` yn rheoli pa mor gyflym mae eich gêm yn llunio. Os yw'n mynd yn rhy gyflym, rhowch rif is. +line_highlights: 12-15 +--- +# Pethau i'w gwneud ym mhob ffrâm +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/cy-GB/step_6.md b/cy-GB/step_6.md new file mode 100644 index 000000000..aabf19e1f --- /dev/null +++ b/cy-GB/step_6.md @@ -0,0 +1,112 @@ +## Myfyrio + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/cy-GB/step_7.md b/cy-GB/step_7.md new file mode 100644 index 000000000..8f7a0fd9f --- /dev/null +++ b/cy-GB/step_7.md @@ -0,0 +1 @@ +## Uwchraddio eich prosiect \ No newline at end of file diff --git a/cy-GB/step_8.md b/cy-GB/step_8.md new file mode 100644 index 000000000..3e299dfdd --- /dev/null +++ b/cy-GB/step_8.md @@ -0,0 +1,36 @@ +## Beth nesaf? + +Os ydych chi'n dilyn y llwybr [Cyflwyniad i Python](https://projects.raspberrypi.org/cy-GB/raspberrypi/python-intro), fe allwch chi symud ymlaen i'r prosiect [Lansio roced](https://projects.raspberrypi.org/cy-GB/projects/rocket-launch). Yn y prosiect hwn, byddwch chi'n gwneud animeiddiad rhyngweithiol o roced yn lansio lloeren i orbit. + + +--- print-only --- + + +--- task --- + +--- /print-only --- + +--- /task --- + +--- task --- + +**Rhoi cynnig arni:** Bydd eich rhaglen yn addasu'r animeiddiad ar sail faint o danwydd rydych chi'n ei roi iddo a bydd naill ai'n llwyddo neu'n methu cyrraedd orbit. Faint o danwydd ydych chi am ei ddefnyddio i gyrraedd orbit heb wastraffu gormod o danwydd ychwanegol? + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/cy-GB/step_9.md b/cy-GB/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/cy-GB/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/de-DE/code/target-practice-solution/main.py b/de-DE/code/target-practice-solution/main.py new file mode 100644 index 000000000..4d467c346 --- /dev/null +++ b/de-DE/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +# Bibliothekscode importieren! + +from p5 import * +from random import randint + + +# Die Funktion „mouse_pressed“ kommt hierher +def mouse_pressed(): + circle(pfeil_x, pfeil_y, 15) # Zeichne einen kleinen Kreis an zufälligen Koordinaten + if getroffene_farbe == Color('blue').hex: # Wie bei Funktionen sind auch 'if'-Anweisungen eingerückt + print('Du hast den äußeren Kreis getroffen, 50 Punkte!') + elif getroffene_farbe == Color('red').hex: + print('Du hast den inneren Kreis erreicht, 200 Punkte!') + elif getroffene_farbe == Color('yellow').hex: + print('Du hast die Mitte getroffen, 500 Punkte!') + else: + print('Daneben! Keine Punkte!') + + +# Die Funktion „schiess_pfeil“ kommt hierher +def schiess_pfeil(): + global hit_colour + pfeil_x = randint(100, 300) # Speichere eine Zufallszahl zwischen 100 und 300 + pfeil_y = randint(100, 300) # Speichere eine Zufallszahl zwischen 100 und 300 + getroffene_farbe = get(pfeil_x, pfeil_y).hex # Hole die Trefferfarbe + global getroffene_farbe # Kann in anderen Funktionen verwendet werden + fill('sienna') # Stelle die Füllfarbe des Pfeils auf Braun ein + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Richte hier Dein Spiel ein + size(400, 400) # Breite und Höhe + no_stroke() + + +def draw(): + # Dinge die in jedem Frame passieren + fill('cyan') + rect(0, 0, 400, 250) # Himmel + fill('lightgreen') + rect(0, 250, 400, 150) # Gras + fill('sienna') + triangle(150, 350, 200, 150, 250, 350) # Stand + fill('blue') + circle(200, 200, 170) # Äußerer Kreis + fill('red') + circle(200, 200, 110) # Innerer Kreis + fill('yellow') + circle(200, 200, 30) # Mitte + schiess_pfeil() + + +# Lass dies so stehen, um Deinen Code auszuführen +run(frame_rate=2) diff --git a/de-DE/code/target-practice-solution/project_config.yml b/de-DE/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..24cb8a195 --- /dev/null +++ b/de-DE/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Schießübung Beispiel' +identifier: 'target-practice-solution' +type: 'python' diff --git a/de-DE/code/target-practice-starter/main.py b/de-DE/code/target-practice-starter/main.py new file mode 100644 index 000000000..9275bb2de --- /dev/null +++ b/de-DE/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +# Bibliothekscode importieren +from p5 import * +from random import randint + +# Die Funktion „mouse_pressed“ kommt hierher + + +# Die Funktion „schiess_pfeil“ kommt hierher + + +def setup(): + # Richte hier Dein Spiel ein + size(400, 400) # Breite und Höhe + no_stroke() + + +def draw(): + # Dinge die in jedem Frame passieren + fill("cyan") + rect(0, 0, 400, 250) + + +# Lass dies so stehen, um Deinen Code auszuführen +run(frame_rate=2) diff --git a/de-DE/code/target-practice-starter/project_config.yml b/de-DE/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..6e0f86586 --- /dev/null +++ b/de-DE/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Zielübung" +identifier: 'target-practice-starter' +type: 'python' diff --git a/de-DE/images/alternative-colours.png b/de-DE/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/de-DE/images/alternative-colours.png differ diff --git a/de-DE/images/animation_bg_erase.gif b/de-DE/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/de-DE/images/animation_bg_erase.gif differ diff --git a/de-DE/images/animation_no_bg_erase.gif b/de-DE/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/de-DE/images/animation_no_bg_erase.gif differ diff --git a/de-DE/images/arrow-centre.png b/de-DE/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/de-DE/images/arrow-centre.png differ diff --git a/de-DE/images/arrow-middle.png b/de-DE/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/de-DE/images/arrow-middle.png differ diff --git a/de-DE/images/arrow-target.png b/de-DE/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/de-DE/images/arrow-target.png differ diff --git a/de-DE/images/background.png b/de-DE/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/de-DE/images/background.png differ diff --git a/de-DE/images/banner.png b/de-DE/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/de-DE/images/banner.png differ diff --git a/de-DE/images/blue-circle.png b/de-DE/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/de-DE/images/blue-circle.png differ diff --git a/de-DE/images/blue-points.png b/de-DE/images/blue-points.png new file mode 100644 index 000000000..b20612a25 Binary files /dev/null and b/de-DE/images/blue-points.png differ diff --git a/de-DE/images/blue_circle_points.gif b/de-DE/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/de-DE/images/blue_circle_points.gif differ diff --git a/de-DE/images/bottom-right.png b/de-DE/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/de-DE/images/bottom-right.png differ diff --git a/de-DE/images/centre.png b/de-DE/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/de-DE/images/centre.png differ diff --git a/de-DE/images/circle-coords.png b/de-DE/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/de-DE/images/circle-coords.png differ diff --git a/de-DE/images/coords_animation.gif b/de-DE/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/de-DE/images/coords_animation.gif differ diff --git a/de-DE/images/difficulty-setting.png b/de-DE/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/de-DE/images/difficulty-setting.png differ diff --git a/de-DE/images/fire_arrow.gif b/de-DE/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/de-DE/images/fire_arrow.gif differ diff --git a/de-DE/images/five_circles.png b/de-DE/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/de-DE/images/five_circles.png differ diff --git a/de-DE/images/green-grass.png b/de-DE/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/de-DE/images/green-grass.png differ diff --git a/de-DE/images/grey-circle.png b/de-DE/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/de-DE/images/grey-circle.png differ diff --git a/de-DE/images/grey-points.png b/de-DE/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/de-DE/images/grey-points.png differ diff --git a/de-DE/images/initial_target.png b/de-DE/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/de-DE/images/initial_target.png differ diff --git a/de-DE/images/missed_no_points.gif b/de-DE/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/de-DE/images/missed_no_points.gif differ diff --git a/de-DE/images/outline-circles.png b/de-DE/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/de-DE/images/outline-circles.png differ diff --git a/de-DE/images/points-scored.gif b/de-DE/images/points-scored.gif new file mode 100644 index 000000000..696cd9c2a Binary files /dev/null and b/de-DE/images/points-scored.gif differ diff --git a/de-DE/images/quiz-colour.png b/de-DE/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/de-DE/images/quiz-colour.png differ diff --git a/de-DE/images/random-side.png b/de-DE/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/de-DE/images/random-side.png differ diff --git a/de-DE/images/rectangle-diagram.png b/de-DE/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/de-DE/images/rectangle-diagram.png differ diff --git a/de-DE/images/showcase_rocket.png b/de-DE/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/de-DE/images/showcase_rocket.png differ diff --git a/de-DE/images/showcase_static.png b/de-DE/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/de-DE/images/showcase_static.png differ diff --git a/de-DE/images/sky_coords.png b/de-DE/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/de-DE/images/sky_coords.png differ diff --git a/de-DE/images/sky_stroke.png b/de-DE/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/de-DE/images/sky_stroke.png differ diff --git a/de-DE/images/stand_coords.png b/de-DE/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/de-DE/images/stand_coords.png differ diff --git a/de-DE/images/step_4_preview.gif b/de-DE/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/de-DE/images/step_4_preview.gif differ diff --git a/de-DE/images/step_5_preview.gif b/de-DE/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/de-DE/images/step_5_preview.gif differ diff --git a/de-DE/images/target-stand.png b/de-DE/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/de-DE/images/target-stand.png differ diff --git a/de-DE/images/target_area.png b/de-DE/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/de-DE/images/target_area.png differ diff --git a/de-DE/images/target_printed.gif b/de-DE/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/de-DE/images/target_printed.gif differ diff --git a/de-DE/images/three-circles.png b/de-DE/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/de-DE/images/three-circles.png differ diff --git a/de-DE/images/top-left.png b/de-DE/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/de-DE/images/top-left.png differ diff --git a/de-DE/images/triangles-coords.png b/de-DE/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/de-DE/images/triangles-coords.png differ diff --git a/de-DE/images/upgrade-ideas.png b/de-DE/images/upgrade-ideas.png new file mode 100644 index 000000000..e654cb7a7 Binary files /dev/null and b/de-DE/images/upgrade-ideas.png differ diff --git a/de-DE/images/yellow-points.png b/de-DE/images/yellow-points.png new file mode 100644 index 000000000..e899817fe Binary files /dev/null and b/de-DE/images/yellow-points.png differ diff --git a/de-DE/meta.yml b/de-DE/meta.yml new file mode 100644 index 000000000..8fd90c4f7 --- /dev/null +++ b/de-DE/meta.yml @@ -0,0 +1,41 @@ +--- +title: Zielübung +hero_image: images/banner.png +description: Zeichne mit Python eine Zielscheibe und erziele Punkte, indem Du sie mit Pfeilen triffst +meta_title: Python Programmierprojekte für Kinder und Jugendliche | Zielübung +meta_description: Lerne Python mit den Programmierprojekten der Raspberry Pi Foundation für Kinder und Jugendliche. Zeichne mit Python eine Zielscheibe und erziele Punkte, indem Du sie mit Pfeilen triffst. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Das wirst du machen + - + title: Erstelle einen Hintergrund + - + title: Zeichne deine Zielscheibe + completion: + - engaged + - + title: Feuere deinen Pfeil ab + - + title: Punkten + - + title: Kurzes Quiz + completion: + - external + - + title: Verbessere Dein Projekt + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Wie geht es weiter? + challenge: true + - + title: What can you do now? diff --git a/de-DE/python-comments-demo.txt b/de-DE/python-comments-demo.txt new file mode 100644 index 000000000..66403a826 --- /dev/null +++ b/de-DE/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Rot = 92, Grün = 204, Blau = 206 + +Stelle die Füllfarbe für das Gras + +x, y, Breite, Höhe + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/de-DE/python-comments.txt b/de-DE/python-comments.txt new file mode 100644 index 000000000..ff0568257 --- /dev/null +++ b/de-DE/python-comments.txt @@ -0,0 +1,27 @@ +Dinge die in jedem Frame passieren + +Draw the inner circle + +Draw the middle circle + +Die Funktion „schiess_pfeil“ kommt hierher + +Die Funktion „mouse_pressed“ kommt hierher + +Du hast den äußeren Kreis getroffen, 50 Punkte! + +Du hast den inneren Kreis getroffen, 200 Punkte! + +Du hast die Mitte getroffen, 500 Punkte! + +You hit the middle, 500 points! + +Du hast das Ziel leider verfehlt! Keine Punkte! + +Super schnell + +Ziemlich schnell + +Sehr schnell + +Geschwindigkeit unbekannt! \ No newline at end of file diff --git a/de-DE/python-translatable-demo.txt b/de-DE/python-translatable-demo.txt new file mode 100644 index 000000000..742f53a97 --- /dev/null +++ b/de-DE/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +Du hast den äußeren Kreis getroffen, 50 Punkte! + +Du hast den inneren Kreis getroffen, 200 Punkte! + +Du hast die Mitte getroffen, 500 Punkte! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/de-DE/python-translatable.txt b/de-DE/python-translatable.txt new file mode 100644 index 000000000..df102b65f --- /dev/null +++ b/de-DE/python-translatable.txt @@ -0,0 +1,9 @@ +schiess_pfeil + +pfeil_x + +pfeil_y + +hit_color + +geschwindigkeit \ No newline at end of file diff --git a/de-DE/quiz1/question_1.md b/de-DE/quiz1/question_1.md new file mode 100644 index 000000000..edd08c971 --- /dev/null +++ b/de-DE/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Kurzes Quiz + +Beantworte die drei Fragen. Hinweise helfen dir beim Finden der richtigen Antwort. + +Nach dem Beantworten der Fragen wähle **Meine Antwort prüfen**. + +Viel Spaß! + +--- question --- +--- +legend: Frage 1 von 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +Richtig. Wenn du diese Funktion nicht verwendest, wird ein schwarzer Rand um deine Formen gezeichnet. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Nicht ganz. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Nicht ganz. Die Funktion fill() erledigt dies und enthält normalerweise eine bestimmte Farbe. + + --- /feedback --- + +- ( ) Es wird eine Kreisform in das Programm gezeichnet. + + --- feedback --- + + Nicht ganz. Die Funktion „circle()“ wird zum Zeichnen eines Kreises verwendet. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/de-DE/quiz1/question_2.md b/de-DE/quiz1/question_2.md new file mode 100644 index 000000000..5b701e935 --- /dev/null +++ b/de-DE/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Frage 2 von 3 +--- + +In deinem Projekt hast du die Bedingungen `if`, `elif` und `else` verwendet, um zu überprüfen, welche Farbe der Pfeil erreicht hat. + +Im folgenden Beispiel ist in einer Variablen namens `geschwindigkeit` die Zahl `6` gespeichert. Was würde im Ausgabebereich stehen, wenn diese `if`-Anweisung ausgeführt wird? + +--- code --- +--- +language: python +--- +geschwindigkeit = 6 + +if geschwindigkeit == 7: print('Superschnell') elif geschwindigkeit == 5: print('Ziemlich schnell') elif geschwindigkeit == 6: print('Sehr schnell') else: print('Geschwindigkeit unbekannt!') + +--- /code --- + +--- choices --- + +- (x) `Sehr schnell` + + --- feedback --- + + Richtig! Der Variablen **geschwindigkeit** wurde der Wert `6` zugewiesen, wodurch die Bedingung `geschwindigkeit == 6` **wahr** wird und `Sehr schnell` ausgegeben wird. + + --- /feedback --- + +- ( ) `Geschwindigkeit unbekannt!` + + --- feedback --- + + Nicht ganz, schau dir den Wert an, der der Variablen **geschwindigkeit** zugewiesen ist. + + --- /feedback --- + +- ( ) Es wird nichts ausgegeben + + --- feedback --- + + Versuch es erneut, `else` (deutsch: sonst) wird als letzte Option verwendet, wenn alle darüber gestellten Bedingungen falsch sind. Schau dir die Bedingungen noch einmal an. Sind einige der Bedingungen wahr? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/de-DE/quiz1/question_3.md b/de-DE/quiz1/question_3.md new file mode 100644 index 000000000..97c445598 --- /dev/null +++ b/de-DE/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Frage 3 von 3 +--- + +Ein Kreis wird mit dem folgenden Code gezeichnet: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Welches der folgenden Bilder zeigt die korrekte Position dieses Kreises im Ausgabebereich? + +--- choices --- + +- ( ) ![Ein grüner Kreis in der Mitte der unteren rechten Ecke des Ausgabebereichs.](images/bottom-right.png) + + --- feedback --- + + Nicht ganz. Um den Kreis in der unteren rechten Ecke zu zentrieren, müssten die Koordinaten mit der Bildschirmgröße übereinstimmen. In diesem Beispiel wäre die Ellipse `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Ein grüner Kreis in der Mitte des Ausgabebereichs.](images/centre.png) + + --- feedback --- + + Nicht ganz. Um den Kreis in der Mitte zu zentrieren, müssten die Koordinaten die Hälfte der Bildschirmgröße betragen. In diesem Beispiel `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Ein grüner Kreis in der Mitte der oberen linken Ecke des Ausgabebereichs.](images/top-left.png) + + --- feedback --- + + Richtig! Der Mittelpunkt dieses Kreises liegt auf den Koordinaten (0,0), der oberen linken Ecke des Bildschirms. + + --- /feedback --- + +- ( ) ![Ein grüner Kreis mit der Mitte oben rechts im Ausgabebereich.](images/random-side.png) + + --- feedback --- + + Nein, dieser Kreis entspräche dem Code `circle(350, 150, 300)`, um ihn oben rechts auf dem Bildschirm zu zentrieren. Die Koordinate `x` gibt an, wie weit die Ellipse über den Bildschirm verläuft, und die Koordinate `y` gibt an, wie weit unten auf dem Bildschirm sie liegt. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/de-DE/step_1.md b/de-DE/step_1.md new file mode 100644 index 000000000..d49f92390 --- /dev/null +++ b/de-DE/step_1.md @@ -0,0 +1,29 @@ +## Das wirst Du machen + +Verwende Python mit der Grafikbibliothek `p5`, um eine Zielscheibe zu zeichnen, und Punkte zu erzielen, indem Du sie mit Pfeilen triffst. + +--- print-only --- + +![Ein Bogenschießziel mit einem Trefferpunkt am äußeren Kreis. Der Text „Du hast den äußeren Kreis getroffen, 50 Punkte!“ wird darunter angezeigt](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Klicke unten auf die Schaltfläche **Ausführen**, um das Spiel zu starten. Wenn der Punkt auf der Zielscheibe 🎯 erscheint, klicke mit der Maus (oder tippe auf deinem Tablet), um deinen Pfeil abzufeuern. + + +
+
+ +--- /no-print --- + +
+ Nimm an unserer Umfrage teil, um unseren Code Editor zu verbessern! +
+ + + diff --git a/de-DE/step_2.md b/de-DE/step_2.md new file mode 100644 index 000000000..13e8e9318 --- /dev/null +++ b/de-DE/step_2.md @@ -0,0 +1,37 @@ +## Zeichne das Gras + +--- task --- + +Öffne das Projekt [Zielübungsstarter](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Füge** Code hinzu, um ein grünes Rechteck am unteren Bildschirmrand zu zeichnen. + +![Der Ausgabebereich mit einem himmelfarbenen Rechteck über einem grasfarbenen Rechteck, um den Hintergrund zu erstellen. Die obere linke Ecke des Rechtecks ist mit x=0, y=250 markiert. Dies ist der Ursprung des Rechtecks. Die Breite wird mit 400 und die Höhe mit 150 hervorgehoben. Der Code rect(0, 250, 400, 150) wird angezeigt.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 14 +line_highlights: 12 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Führe dein Projekt erneut aus, um den fertigen Hintergrund anzuzeigen. + +![Der Ausgabebereich mit einem himmelfarbenen Rechteck über einem grasfarbenen Rechteck, um den Hintergrund zu erstellen.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/de-DE/step_3.md b/de-DE/step_3.md new file mode 100644 index 000000000..62b8c1fde --- /dev/null +++ b/de-DE/step_3.md @@ -0,0 +1,117 @@ +## Zeichne deine Zielscheibe + +
+
+Dein Spiel braucht ein Ziel, auf das du mit Pfeilen schießen kannst. +
+
+ +![Der Ausgabebereich mit der Zielscheibe und dem Ständer.](images/ three-circles.png){:width="300px"} + +
+
+ +### Zeichne einen dreieckigen Ständer + +--- task --- + +Stelle die Füllfarbe auf `sienna` (Braun) ein. + +Zeichne ein Dreieck mit den x- und y-Koordinaten für jede Ecke. + +![Ein braunes Dreieck auf Gras und vor einem Himmel mit den Koordinatenpunkten 150, 350 und 200, 150 und 250, 350). Die Ecken der Leinwand sind außerdem oben links mit x=0, y=0 und unten rechts mit x=400, y=400 beschriftet.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 18 +line_highlights: 20, 21 +--- + + fill('lightgreen') # Stelle die Füllfarbe für das Gras auf Hellgrün ein + rect(0, 250, 400, 150) # Zeichnet ein Rechteck für das Gras mit diesen Werten für x, y, Breite, Höhe + fill('sienna') # Braune Farbe + triangle(150, 350, 200, 150, 250, 350) # Zeichne ein Dreieck für den Zielstand + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Führe deinen Code aus, um den Ständer für deine Zielscheibe zu sehen: + +![Ein braunes Dreieck auf Gras und vor einem Himmel.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Zeichne die Zielkreise + +--- task --- + +Der größte Teil der Zielscheibe ist ein blauer **Kreis** (engl.: „circle“). + +Stelle die Füllfarbe auf `blue` (blau) ein. + +Zeichne einen Kreis mit x- und y-Koordinaten als Mittelpunkt, und einer Breite. + +![Ein braunes Dreieck und ein blauer Kreis auf Gras und vor einem Himmel. Der Kreis ist mit den Koordinaten x=200, y=200 als Mittelpunkt und der Kreisbreite 170 beschriftet.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 20 +line_highlights: 22, 23 +--- + + fill('sienna') # Braune Farbe + triangle(150, 350, 200, 150, 250, 350) # Zeichne ein Dreieck für den Zielstand + fill('blue') # Stelle die Füllfarbe auf blue (blau) ein + circle(200, 200, 170) # Zeichne den äußeren Kreis + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Führe deinen Code aus, um den ersten großen blauen Kreis zu sehen. + +Der blaue Kreis wurde nach dem Ständer gezeichnet, sodass er davor liegt. + +![Ein braunes Dreieck und ein blauer Kreis auf Gras und vor einem Himmel.](images/blue-circle.png){:width="400px"} + +--- /task --- + +Die Zielscheibe besteht aus unterschiedlich großen Kreisen mit denselben Mittelpunktskoordinaten (200, 200). + +--- task --- + +**Füge** farbige Kreise für den inneren und mittleren Teil der Zielscheibe hinzu. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 20 +line_highlights: 24, 25, 26, 27 +--- + + fill('sienna') # Braune Farbe + triangle(150, 350, 200, 150, 250, 350) # Zeichne ein Dreieck für den Zielstand + fill('blue') # Stelle die Füllfarbe auf blue (blau) ein + circle(200, 200, 170) # Zeichne den äußeren Kreis + fill('red') # Stelle die Farbe für die Kreisfüllung auf red (rot) ein + circle(200, 200, 110) # Zeichne den inneren Kreis mit x, y, Breite + fill('yellow') # Stelle die Farbe für die Kreisfüllung auf yellow (gelb) ein + circle(200, 200, 30) # Zeichne den mittleren Kreis mit x, y, Breite + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Führe dein Projekt aus, um die Zielscheibe mit drei farbigen Kreisen zu sehen. + +![Ein braunes Dreieck mit drei farbigen Kreisen auf Gras und vor einem Himmel.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/de-DE/step_4.md b/de-DE/step_4.md new file mode 100644 index 000000000..bfe38c018 --- /dev/null +++ b/de-DE/step_4.md @@ -0,0 +1,90 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![Die Zielscheibe, mit einem braunen kreisförmigen Pfeil, der an verschiedenen Positionen erscheint.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Füge Code hinzu, um zufällig einen braunen Kreis innerhalb eines Zielbereichs zu zeichnen: + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 7 +line_highlights: 8-12 +--- +# Die Funktion „schiess_pfeil“ kommt hierher +def schiess_pfeil(): global getroffene_farbe # Kann in anderen Funktionen verwendet werden +pfeil_x = randint(100, 300) # Speichere eine zufällige Zahl zwischen 100 und 300 pfeil_y = randint(100, 300) # Speichere eine zufällige Zahl zwischen 100 und 300 getroffene_farbe = get(pfeil_x, pfeil_y).hex # Get the hit colour +fill('sienna') # Hol dir die getroffene Farbe circle(pfeil_x, pfeil_y, 15) # Zeichne einen kleinen Kreis an zufälligen Koordinaten + +--- /code --- + +--- /task --- + +--- task --- + +Finde die Funktion `draw` (deutsch: „Zeichne“) und rufe dort deine neue Funktion `schiess_pfeil` auf. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 31 +line_highlights: 33 +--- + + fill('yellow') # Stelle die Farbe für die Kreisfüllung auf yellow (gelb) ein + circle(200, 200, 30) # Zeichne den mittleren Kreis mit x, y, Breite + schiess_pfeil() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Führe dein Projekt aus. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 5 +line_highlights: 9, 12 +--- +def schiess_pfeil(): +pfeil_x = randint(100, 300) # Speichere eine zufällige Zahl zwischen 100 und 300 pfeil_y = randint(100, 300) # Speichere eine zufällige Zahl zwischen 100 und 300 fill('sienna') # Stelle die Füllfarbe des Pfeils auf Braun ein circle(pfeil_x, pfeil_y, 15) # Zeichne einen kleinen Kreis an zufälligen Koordinaten + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** 🔄 Führe dein Projekt aus. You should see the arrow jump around the target. + +![Eine Animation eines Ziels mit einem braunen Kreispfeil, der an verschiedenen Positionen erscheint.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/de-DE/step_5.md b/de-DE/step_5.md new file mode 100644 index 000000000..4a64c0e6e --- /dev/null +++ b/de-DE/step_5.md @@ -0,0 +1,83 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +**Debug:** 🐞 Wenn du eine Meldung siehst, dass `getroffene_farbe` „not defined“ (deutsch: „nicht definiert“) ist, gehe zurück zu `draw()` und überprüfe, ob die Zeile `getroffene_farbe` als eine globale Variable deklariert. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): +if getroffene_farbe == Color('blue').hex: # Wie der Code in Funktionen ist der Code auch in 'if'-Anweisungen eingerückt print('Du hast den äußeren Kreis getroffen, 50 Punkte!') + +--- /code --- + +**Debug:** 🐞 Stelle sicher, dass du die `.hex`-Zeichenfolge für **deine** Kreisfarben verwendet hast. + +--- /task --- + +--- task --- + +**Test:** 🔄 Führe dein Projekt aus. Versuche, den Pfeil auf den blauen äußeren Kreis abzufeuern, um die Ausgabe zu sehen. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 6 +line_highlights: 7, 8 +--- + + def mouse_pressed(): + if getroffene_farbe == Color('blue').hex:
+ print('Du hast den äußeren Kreis getroffen, 50 Punkte!') + elif getroffene_farbe == Color('red').hex: + print('Du hast den inneren Kreis getroffen, 200 Punkte!') + elif getroffene_farbe == Color('yellow').hex: + print('Du hast die Mitte getroffen, 500 Punkte!') + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 5 +line_highlights: 9-12 +--- +# Die Funktion „mouse_pressed“ kommt hierher +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Führe dein Projekt aus. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/de-DE/step_6.md b/de-DE/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/de-DE/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/de-DE/step_7.md b/de-DE/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/de-DE/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/de-DE/step_8.md b/de-DE/step_8.md new file mode 100644 index 000000000..28ae6e382 --- /dev/null +++ b/de-DE/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /no-print --- diff --git a/de-DE/step_9.md b/de-DE/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/de-DE/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/el-GR/code/target-practice-solution/main.py b/el-GR/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/el-GR/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/el-GR/code/target-practice-solution/project_config.yml b/el-GR/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/el-GR/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/el-GR/code/target-practice-starter/main.py b/el-GR/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/el-GR/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/el-GR/code/target-practice-starter/project_config.yml b/el-GR/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/el-GR/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/el-GR/images/alternative-colours.png b/el-GR/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/el-GR/images/alternative-colours.png differ diff --git a/el-GR/images/animation_bg_erase.gif b/el-GR/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/el-GR/images/animation_bg_erase.gif differ diff --git a/el-GR/images/animation_no_bg_erase.gif b/el-GR/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/el-GR/images/animation_no_bg_erase.gif differ diff --git a/el-GR/images/arrow-centre.png b/el-GR/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/el-GR/images/arrow-centre.png differ diff --git a/el-GR/images/arrow-middle.png b/el-GR/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/el-GR/images/arrow-middle.png differ diff --git a/el-GR/images/arrow-target.png b/el-GR/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/el-GR/images/arrow-target.png differ diff --git a/el-GR/images/background.png b/el-GR/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/el-GR/images/background.png differ diff --git a/el-GR/images/banner.png b/el-GR/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/el-GR/images/banner.png differ diff --git a/el-GR/images/blue-circle.png b/el-GR/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/el-GR/images/blue-circle.png differ diff --git a/el-GR/images/blue-points.png b/el-GR/images/blue-points.png new file mode 100644 index 000000000..28040656a Binary files /dev/null and b/el-GR/images/blue-points.png differ diff --git a/el-GR/images/blue_circle_points.gif b/el-GR/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/el-GR/images/blue_circle_points.gif differ diff --git a/el-GR/images/bottom-right.png b/el-GR/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/el-GR/images/bottom-right.png differ diff --git a/el-GR/images/centre.png b/el-GR/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/el-GR/images/centre.png differ diff --git a/el-GR/images/circle-coords.png b/el-GR/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/el-GR/images/circle-coords.png differ diff --git a/el-GR/images/coords_animation.gif b/el-GR/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/el-GR/images/coords_animation.gif differ diff --git a/el-GR/images/difficulty-setting.png b/el-GR/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/el-GR/images/difficulty-setting.png differ diff --git a/el-GR/images/fire_arrow.gif b/el-GR/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/el-GR/images/fire_arrow.gif differ diff --git a/el-GR/images/five_circles.png b/el-GR/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/el-GR/images/five_circles.png differ diff --git a/el-GR/images/green-grass.png b/el-GR/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/el-GR/images/green-grass.png differ diff --git a/el-GR/images/grey-circle.png b/el-GR/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/el-GR/images/grey-circle.png differ diff --git a/el-GR/images/grey-points.png b/el-GR/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/el-GR/images/grey-points.png differ diff --git a/el-GR/images/initial_target.png b/el-GR/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/el-GR/images/initial_target.png differ diff --git a/el-GR/images/missed-points.png b/el-GR/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/el-GR/images/missed-points.png differ diff --git a/el-GR/images/missed_no_points.gif b/el-GR/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/el-GR/images/missed_no_points.gif differ diff --git a/el-GR/images/outline-circles.png b/el-GR/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/el-GR/images/outline-circles.png differ diff --git a/el-GR/images/points-scored.gif b/el-GR/images/points-scored.gif new file mode 100644 index 000000000..00a8ba8aa Binary files /dev/null and b/el-GR/images/points-scored.gif differ diff --git a/el-GR/images/quiz-colour.png b/el-GR/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/el-GR/images/quiz-colour.png differ diff --git a/el-GR/images/random-side.png b/el-GR/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/el-GR/images/random-side.png differ diff --git a/el-GR/images/rectangle-diagram.png b/el-GR/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/el-GR/images/rectangle-diagram.png differ diff --git a/el-GR/images/showcase_rocket.png b/el-GR/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/el-GR/images/showcase_rocket.png differ diff --git a/el-GR/images/showcase_static.png b/el-GR/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/el-GR/images/showcase_static.png differ diff --git a/el-GR/images/sky_coords.png b/el-GR/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/el-GR/images/sky_coords.png differ diff --git a/el-GR/images/sky_stroke.png b/el-GR/images/sky_stroke.png new file mode 100644 index 000000000..0d088147f Binary files /dev/null and b/el-GR/images/sky_stroke.png differ diff --git a/el-GR/images/stand_coords.png b/el-GR/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/el-GR/images/stand_coords.png differ diff --git a/el-GR/images/step_4_preview.gif b/el-GR/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/el-GR/images/step_4_preview.gif differ diff --git a/el-GR/images/step_5_preview.gif b/el-GR/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/el-GR/images/step_5_preview.gif differ diff --git a/el-GR/images/target-stand.png b/el-GR/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/el-GR/images/target-stand.png differ diff --git a/el-GR/images/target_area.png b/el-GR/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/el-GR/images/target_area.png differ diff --git a/el-GR/images/target_printed.gif b/el-GR/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/el-GR/images/target_printed.gif differ diff --git a/el-GR/images/three-circles.png b/el-GR/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/el-GR/images/three-circles.png differ diff --git a/el-GR/images/top-left.png b/el-GR/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/el-GR/images/top-left.png differ diff --git a/el-GR/images/triangles-coords.png b/el-GR/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/el-GR/images/triangles-coords.png differ diff --git a/el-GR/images/upgrade-ideas.png b/el-GR/images/upgrade-ideas.png new file mode 100644 index 000000000..142846c77 Binary files /dev/null and b/el-GR/images/upgrade-ideas.png differ diff --git a/el-GR/images/yellow-points.png b/el-GR/images/yellow-points.png new file mode 100644 index 000000000..e447070db Binary files /dev/null and b/el-GR/images/yellow-points.png differ diff --git a/el-GR/meta.yml b/el-GR/meta.yml new file mode 100644 index 000000000..94ea92b6c --- /dev/null +++ b/el-GR/meta.yml @@ -0,0 +1,41 @@ +--- +title: Εξάσκηση στόχου +hero_image: images/banner.png +description: Χρησιμοποίησε την Python για να σχεδιάσεις έναν στόχο και να κερδίζεις πόντους χτυπώντας τον με βέλη +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Εισαγωγή + - + title: Δημιούργησε ένα υπόβαθρο + - + title: Σχεδίασε τον στόχο σου + completion: + - engaged + - + title: Ρίξε το βέλος σου + - + title: Κέρδισε πόντους + - + title: Αναστοχασμός + completion: + - external + - + title: Αναβάθμιση του έργου σου + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Και τώρα; + challenge: true + - + title: What can you do now? diff --git a/el-GR/python-comments-demo.txt b/el-GR/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/el-GR/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/el-GR/python-comments.txt b/el-GR/python-comments.txt new file mode 100644 index 000000000..c251161ce --- /dev/null +++ b/el-GR/python-comments.txt @@ -0,0 +1,27 @@ +Ενέργειες που πρέπει να γίνονται σε κάθε καρέ + +Draw the inner circle + +Draw the middle circle + +Η συνάρτηση shoot_arrow πηγαίνει εδώ + +Η συνάρτηση mouse_pressed πηγαίνει εδώ + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/el-GR/python-translatable-demo.txt b/el-GR/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/el-GR/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/el-GR/python-translatable.txt b/el-GR/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/el-GR/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/el-GR/quiz1/question_1.md b/el-GR/quiz1/question_1.md new file mode 100644 index 000000000..a18657e69 --- /dev/null +++ b/el-GR/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Αναστοχασμός + +Answer the three questions. There are hints to guide you to the correct answer. + +Απάντησε στις τρεις ερωτήσεις παρακάτω για να διαπιστώσεις τι έμαθες. + +Have fun! + +--- question --- +--- +legend: Ερώτηση 1 από 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +Εδώ είναι ένα μπλε τετράγωνο, ποιες είναι οι τιμές RGB που θα το δημιουργήσουν; +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/el-GR/quiz1/question_2.md b/el-GR/quiz1/question_2.md new file mode 100644 index 000000000..0d8ccf780 --- /dev/null +++ b/el-GR/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Ερώτηση 2 από 3 +--- + +Στο έργο σου, χρησιμοποίησες τις συνθήκες `if` , `elif`και `else` για να ελέγξεις σε ποιο χρώμα προσγειώθηκε το βέλος. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Υπερβολικά γρήγορα') elif speed == 5: print('Αρκετά γρήγορα') elif speed == 6: print('Πολύ γρήγορα') else: print('Δεν αναγνωρίστηκε η ταχύτητα!') + +--- /code --- + +--- choices --- + +- (x) `Πολύ γρήγορα` + + --- feedback --- + + Αυτό είναι το σωστό! Στη μεταβλητή **speed** έχει δοθεί η τιμή `6`, η οποία κάνει την συνθήκη `speed == 6` **Αληθή** και εμφανίζει το μήνυμα `Πολύ γρήγορα`. + + --- /feedback --- + +- ( ) `Δεν αναγνωρίστηκε η ταχύτητα!` + + --- feedback --- + + Όχι ακριβώς, κοίταξε την τιμή που έχει δοθεί στη μεταβλητή **speed**. + + --- /feedback --- + +- ( ) Τίποτα δεν εμφανίζεται + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/el-GR/quiz1/question_3.md b/el-GR/quiz1/question_3.md new file mode 100644 index 000000000..d1da98a87 --- /dev/null +++ b/el-GR/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Ερώτηση 3 από 3 +--- + +Μια έλλειψη σχεδιάζεται χρησιμοποιώντας τον ακόλουθο κώδικα: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0,255,0) +no_stroke() + +def draw(): +ellipse(0,0,300,300) + +run() + +--- /code --- + +Ποια από τις παρακάτω εικόνες δείχνει τη σωστή θέση αυτής της έλλειψης στην περιοχή εξόδου; + +--- choices --- + +- ( ) ![Ένας πράσινος κύκλος με κέντρο στην κάτω δεξιά γωνία της περιοχής εξόδου.](images/bottom-right.png) + + --- feedback --- + + Όχι ακριβώς, για να κεντράρουμε τον κύκλο στην κάτω δεξιά γωνία, οι συντεταγμένες θα πρέπει να είναι ίδιες με το μέγεθος της οθόνης. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Ένας πράσινος κύκλος με κέντρο στο κέντρο της περιοχής εξόδου.](images/centre.png) + + --- feedback --- + + Όχι ακριβώς, για να κεντράρουμε τον κύκλο στη μέση, οι συντεταγμένες θα πρέπει να είναι το μισό του μεγέθους της οθόνης. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Ένας πράσινος κύκλος με κέντρο στην επάνω αριστερή γωνία της περιοχής εξόδου.](images/top-left.png) + + --- feedback --- + + Αυτό είναι το σωστό! Αυτός ο κύκλος είναι κεντραρισμένος στις συντεταγμένες (0,0), στην επάνω αριστερή γωνία της οθόνης. + + --- /feedback --- + +- ( ) ![Ένας πράσινος κύκλος με κέντρο την επάνω δεξιά πλευρά της περιοχής εξόδου.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. Η συντεταγμένη `x` δείχνει πόσο αριστερά ή δεξιά βρίσκεται η έλλειψη στην οθόνη και η συντεταγμένη `y` δείχνει πόσο κάτω ή πάνω βρίσκεται στην οθόνη. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/el-GR/resources/main.py b/el-GR/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/el-GR/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/el-GR/resources/p5.py b/el-GR/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/el-GR/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/el-GR/step_1.md b/el-GR/step_1.md new file mode 100644 index 000000000..86064b819 --- /dev/null +++ b/el-GR/step_1.md @@ -0,0 +1,29 @@ +## Εισαγωγή + +Χρησιμοποίησε την Python, με τη βιβλιοθήκη γραφικών `p5`, για να σχεδιάσεις έναν στόχο και να κερδίσεις πόντους χτυπώντας τον με βέλη. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/el-GR/step_2.md b/el-GR/step_2.md new file mode 100644 index 000000000..1e8220067 --- /dev/null +++ b/el-GR/step_2.md @@ -0,0 +1,37 @@ +## Δημιούργησε ένα υπόβαθρο + +--- task --- + +Άνοιξε το [αρχικό έργο Τοξοβολίας](https://trinket.io/python/1e11252c65){:target="_blank"}. + +--- /task --- + +--- task --- + +Το αρχικό έργο έχει ήδη έτοιμο κώδικα για να εισαγάγεις τη βιβλιοθήκη `p5`, θα χρησιμοποιήσεις αυτήν τη βιβλιοθήκη για να δημιουργήσεις το παιχνίδι τοξοβολίας σου. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 25 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +fill(sky) + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/el-GR/step_3.md b/el-GR/step_3.md new file mode 100644 index 000000000..fde2326ac --- /dev/null +++ b/el-GR/step_3.md @@ -0,0 +1,115 @@ +## Σχεδίασε τον στόχο σου + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![Η περιοχή εξόδου με τον στόχο και τη βάση.](images/three-circles.png){:width="300px"} + +
+
+ +### Σχεδίασε τη βάση + +--- task --- + +Set the fill colour to `brown`. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png)Όταν καλείς τη συνάρτηση `triangle()`, πρέπει να παρέχεις τρία σύνολα συντεταγμένων, `x1, y1, x2, y2, x3, y3` που το καθένα αντιπροσωπεύει τη θέση μιας από τις κορυφές του τριγώνου. + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +title: Συντεταγμένες τριγώνων +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png)language: python filename: main.py - draw() line_numbers: true line_number_start: 28 + +--- /task --- + +### Σχεδίασε τον στόχο + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `blue`. + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 31-32 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +Ο μπλε κύκλος θα καλύψει το καφέ τρίγωνο όπου επικαλύπτονται, επειδή ο κύκλος σχεδιάστηκε αργότερα. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png)**Συμβουλή:** Για να φτιάξεις έναν κύκλο, το **πλάτος** και το **ύψος** πρέπει να είναι τα ίδια. + +--- /task --- + +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 33-34 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png)Δημιούργησε δύο νέες μεταβλητές για να αποθηκεύσεις τα χρώματα `inner` και `bullseye` για τους υπόλοιπους κύκλους. + +--- /task --- + +--- save --- diff --git a/el-GR/step_4.md b/el-GR/step_4.md new file mode 100644 index 000000000..05ccc8817 --- /dev/null +++ b/el-GR/step_4.md @@ -0,0 +1,87 @@ +## Ρίξε το βέλος σου + +
+
+Τώρα ήρθε η ώρα να προσθέσεις ένα βέλος που κινείται τυχαία στην περιοχή του στόχου. +
+
+ +![Ο στόχος, με ένα καφέ κυκλικό βέλος να εμφανίζεται σε διάφορες θέσεις.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Μάθε το χρώμα που χτυπά το βέλος + +--- task --- + +Βρες το σχόλιο **#Η συνάρτηση shoot_arrow πηγαίνει εδώ** και από κάτω πρόσθεσε κώδικα για να ορίσεις τη συνάρτηση `shoot_arrow()`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 11-12 +--- +# Η συνάρτηση shoot_arrow πηγαίνει εδώ +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 10 + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 44-45 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +**Δοκιμή:** Εκτέλεσε τον κώδικά σου και δες το βέλος να εμφανίζεται στο κέντρο του στόχου. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_number_start: 3 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![Ο στόχος στο φόντο με ένα καφέ κυκλικό βέλος πάνω του.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/el-GR/step_5.md b/el-GR/step_5.md new file mode 100644 index 000000000..27f1cf12c --- /dev/null +++ b/el-GR/step_5.md @@ -0,0 +1,84 @@ +## Κέρδισε πόντους + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +language: python filename: main.py line_numbers: true line_number_start: 26 + + +--- code --- +--- +global outer, inner, bullseye +sky = color(92, 204, 206) #Κόκκινο = 92, Πράσινο = 204, Μπλε = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +bullseye = color(220, 200, 0) +line_highlights: 28 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 10-11 +--- + + global outer, inner, bullseye + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 12-15 +--- +# Ενέργειες που πρέπει να γίνονται σε κάθε καρέ +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/el-GR/step_6.md b/el-GR/step_6.md new file mode 100644 index 000000000..c071b4b2c --- /dev/null +++ b/el-GR/step_6.md @@ -0,0 +1,112 @@ +## Και τώρα; + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/el-GR/step_7.md b/el-GR/step_7.md new file mode 100644 index 000000000..3ddd6af31 --- /dev/null +++ b/el-GR/step_7.md @@ -0,0 +1 @@ +## Αναβάθμιση του έργου σου \ No newline at end of file diff --git a/el-GR/step_8.md b/el-GR/step_8.md new file mode 100644 index 000000000..f303c67a1 --- /dev/null +++ b/el-GR/step_8.md @@ -0,0 +1,36 @@ +## Και τώρα; + +--- challenge --- + + +--- print-only --- + + +--- task --- + +--- /print-only --- + +--- /task --- + +--- task --- + +--- no-print --- + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Το έργο αυτό μεταφράστηκε από τους εθελοντές: + +--- /task --- + + + +--- /challenge --- diff --git a/el-GR/step_9.md b/el-GR/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/el-GR/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/en-US/code/target-practice-solution/main.py b/en-US/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/en-US/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/en-US/code/target-practice-solution/project_config.yml b/en-US/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/en-US/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/en-US/code/target-practice-starter/main.py b/en-US/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/en-US/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/en-US/code/target-practice-starter/project_config.yml b/en-US/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/en-US/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/en-US/images/alternative-colours.png b/en-US/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/en-US/images/alternative-colours.png differ diff --git a/en-US/images/animation_bg_erase.gif b/en-US/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/en-US/images/animation_bg_erase.gif differ diff --git a/en-US/images/animation_no_bg_erase.gif b/en-US/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/en-US/images/animation_no_bg_erase.gif differ diff --git a/en-US/images/arrow-centre.png b/en-US/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/en-US/images/arrow-centre.png differ diff --git a/en-US/images/arrow-middle.png b/en-US/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/en-US/images/arrow-middle.png differ diff --git a/en-US/images/arrow-target.png b/en-US/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/en-US/images/arrow-target.png differ diff --git a/en-US/images/background.png b/en-US/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/en-US/images/background.png differ diff --git a/en-US/images/banner.png b/en-US/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/en-US/images/banner.png differ diff --git a/en-US/images/blue-circle.png b/en-US/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/en-US/images/blue-circle.png differ diff --git a/en-US/images/blue-points.png b/en-US/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/en-US/images/blue-points.png differ diff --git a/en-US/images/blue_circle_points.gif b/en-US/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/en-US/images/blue_circle_points.gif differ diff --git a/en-US/images/bottom-right.png b/en-US/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/en-US/images/bottom-right.png differ diff --git a/en-US/images/centre.png b/en-US/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/en-US/images/centre.png differ diff --git a/en-US/images/circle-coords.png b/en-US/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/en-US/images/circle-coords.png differ diff --git a/en-US/images/coords_animation.gif b/en-US/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/en-US/images/coords_animation.gif differ diff --git a/en-US/images/difficulty-setting.png b/en-US/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/en-US/images/difficulty-setting.png differ diff --git a/en-US/images/fire_arrow.gif b/en-US/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/en-US/images/fire_arrow.gif differ diff --git a/en-US/images/five_circles.png b/en-US/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/en-US/images/five_circles.png differ diff --git a/en-US/images/green-grass.png b/en-US/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/en-US/images/green-grass.png differ diff --git a/en-US/images/grey-circle.png b/en-US/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/en-US/images/grey-circle.png differ diff --git a/en-US/images/grey-points.png b/en-US/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/en-US/images/grey-points.png differ diff --git a/en-US/images/initial_target.png b/en-US/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/en-US/images/initial_target.png differ diff --git a/en-US/images/missed-points.png b/en-US/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/en-US/images/missed-points.png differ diff --git a/en-US/images/missed_no_points.gif b/en-US/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/en-US/images/missed_no_points.gif differ diff --git a/en-US/images/outline-circles.png b/en-US/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/en-US/images/outline-circles.png differ diff --git a/en-US/images/points-scored.gif b/en-US/images/points-scored.gif new file mode 100644 index 000000000..3fbe161a8 Binary files /dev/null and b/en-US/images/points-scored.gif differ diff --git a/en-US/images/quiz-colour.png b/en-US/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/en-US/images/quiz-colour.png differ diff --git a/en-US/images/random-side.png b/en-US/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/en-US/images/random-side.png differ diff --git a/en-US/images/rectangle-diagram.png b/en-US/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/en-US/images/rectangle-diagram.png differ diff --git a/en-US/images/showcase_rocket.png b/en-US/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/en-US/images/showcase_rocket.png differ diff --git a/en-US/images/showcase_static.png b/en-US/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/en-US/images/showcase_static.png differ diff --git a/en-US/images/sky_coords.png b/en-US/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/en-US/images/sky_coords.png differ diff --git a/en-US/images/sky_stroke.png b/en-US/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/en-US/images/sky_stroke.png differ diff --git a/en-US/images/stand_coords.png b/en-US/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/en-US/images/stand_coords.png differ diff --git a/en-US/images/step_4_preview.gif b/en-US/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/en-US/images/step_4_preview.gif differ diff --git a/en-US/images/step_5_preview.gif b/en-US/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/en-US/images/step_5_preview.gif differ diff --git a/en-US/images/target-stand.png b/en-US/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/en-US/images/target-stand.png differ diff --git a/en-US/images/target_area.png b/en-US/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/en-US/images/target_area.png differ diff --git a/en-US/images/target_printed.gif b/en-US/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/en-US/images/target_printed.gif differ diff --git a/en-US/images/three-circles.png b/en-US/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/en-US/images/three-circles.png differ diff --git a/en-US/images/top-left.png b/en-US/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/en-US/images/top-left.png differ diff --git a/en-US/images/triangles-coords.png b/en-US/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/en-US/images/triangles-coords.png differ diff --git a/en-US/images/upgrade-ideas.png b/en-US/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/en-US/images/upgrade-ideas.png differ diff --git a/en-US/images/yellow-points.png b/en-US/images/yellow-points.png new file mode 100644 index 000000000..0c461812c Binary files /dev/null and b/en-US/images/yellow-points.png differ diff --git a/en-US/meta.yml b/en-US/meta.yml new file mode 100644 index 000000000..e56ce34a6 --- /dev/null +++ b/en-US/meta.yml @@ -0,0 +1,41 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: What you will make + - + title: Draw the grass + - + title: Draw your target + completion: + - engaged + - + title: Add an arrow + - + title: What colour did you hit? + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Challenge + challenge: true + - + title: What can you do now? diff --git a/en-US/python-comments-demo.txt b/en-US/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/en-US/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/en-US/python-comments.txt b/en-US/python-comments.txt new file mode 100644 index 000000000..35750f346 --- /dev/null +++ b/en-US/python-comments.txt @@ -0,0 +1,27 @@ +Things to do in every frame + +Draw the inner circle + +Draw the middle circle + +The shoot_arrow function goes here + +The mouse_pressed function goes here + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/en-US/python-translatable-demo.txt b/en-US/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/en-US/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/en-US/python-translatable.txt b/en-US/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/en-US/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/en-US/quiz1/question_1.md b/en-US/quiz1/question_1.md new file mode 100644 index 000000000..e91239d96 --- /dev/null +++ b/en-US/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/en-US/quiz1/question_2.md b/en-US/quiz1/question_2.md new file mode 100644 index 000000000..cb8b743b2 --- /dev/null +++ b/en-US/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/en-US/quiz1/question_3.md b/en-US/quiz1/question_3.md new file mode 100644 index 000000000..de44b3b7f --- /dev/null +++ b/en-US/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/en-US/resources/main.py b/en-US/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/en-US/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/en-US/resources/p5.py b/en-US/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/en-US/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/en-US/step_1.md b/en-US/step_1.md new file mode 100644 index 000000000..e3a8012cf --- /dev/null +++ b/en-US/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Use Python to draw a target and score points by hitting it with arrows. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/en-US/step_2.md b/en-US/step_2.md new file mode 100644 index 000000000..919a62214 --- /dev/null +++ b/en-US/step_2.md @@ -0,0 +1,37 @@ +## Draw the grass + +--- task --- + +Open the [Target practice starter](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"} project. + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to view the background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/en-US/step_3.md b/en-US/step_3.md new file mode 100644 index 000000000..c0895baaf --- /dev/null +++ b/en-US/step_3.md @@ -0,0 +1,115 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `brown`. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `blue`. + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/en-US/step_4.md b/en-US/step_4.md new file mode 100644 index 000000000..0e4f7b007 --- /dev/null +++ b/en-US/step_4.md @@ -0,0 +1,88 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![An animation of target with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/en-US/step_5.md b/en-US/step_5.md new file mode 100644 index 000000000..2933b68ca --- /dev/null +++ b/en-US/step_5.md @@ -0,0 +1,80 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/en-US/step_6.md b/en-US/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/en-US/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/en-US/step_7.md b/en-US/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/en-US/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/en-US/step_8.md b/en-US/step_8.md new file mode 100644 index 000000000..910635d28 --- /dev/null +++ b/en-US/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/en-US/step_9.md b/en-US/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/en-US/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/es-419/images/animation_bg_erase.gif b/es-419/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/es-419/images/animation_bg_erase.gif differ diff --git a/es-419/images/animation_no_bg_erase.gif b/es-419/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/es-419/images/animation_no_bg_erase.gif differ diff --git a/es-419/images/arrow-middle.png b/es-419/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/es-419/images/arrow-middle.png differ diff --git a/es-419/images/arrow-target.png b/es-419/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/es-419/images/arrow-target.png differ diff --git a/es-419/images/background.png b/es-419/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/es-419/images/background.png differ diff --git a/es-419/images/banner.png b/es-419/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/es-419/images/banner.png differ diff --git a/es-419/images/blue-circle.png b/es-419/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/es-419/images/blue-circle.png differ diff --git a/es-419/images/blue-points.png b/es-419/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/es-419/images/blue-points.png differ diff --git a/es-419/images/bottom-right.png b/es-419/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/es-419/images/bottom-right.png differ diff --git a/es-419/images/centre.png b/es-419/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/es-419/images/centre.png differ diff --git a/es-419/images/coords_animation.gif b/es-419/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/es-419/images/coords_animation.gif differ diff --git a/es-419/images/difficulty-setting.png b/es-419/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/es-419/images/difficulty-setting.png differ diff --git a/es-419/images/fire_arrow.gif b/es-419/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/es-419/images/fire_arrow.gif differ diff --git a/es-419/images/five_circles.png b/es-419/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/es-419/images/five_circles.png differ diff --git a/es-419/images/grey-circle.png b/es-419/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/es-419/images/grey-circle.png differ diff --git a/es-419/images/grey-points.png b/es-419/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/es-419/images/grey-points.png differ diff --git a/es-419/images/initial_target.png b/es-419/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/es-419/images/initial_target.png differ diff --git a/es-419/images/missed-points.png b/es-419/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/es-419/images/missed-points.png differ diff --git a/es-419/images/outline-circles.png b/es-419/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/es-419/images/outline-circles.png differ diff --git a/es-419/images/points-scored.gif b/es-419/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/es-419/images/points-scored.gif differ diff --git a/es-419/images/quiz-colour.png b/es-419/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/es-419/images/quiz-colour.png differ diff --git a/es-419/images/random-side.png b/es-419/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/es-419/images/random-side.png differ diff --git a/es-419/images/showcase_rocket.png b/es-419/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/es-419/images/showcase_rocket.png differ diff --git a/es-419/images/showcase_static.png b/es-419/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/es-419/images/showcase_static.png differ diff --git a/es-419/images/sky_coords.png b/es-419/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/es-419/images/sky_coords.png differ diff --git a/es-419/images/sky_stroke.png b/es-419/images/sky_stroke.png new file mode 100644 index 000000000..0d088147f Binary files /dev/null and b/es-419/images/sky_stroke.png differ diff --git a/es-419/images/stand_coords.png b/es-419/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/es-419/images/stand_coords.png differ diff --git a/es-419/images/step_4_preview.gif b/es-419/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/es-419/images/step_4_preview.gif differ diff --git a/es-419/images/step_5_preview.gif b/es-419/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/es-419/images/step_5_preview.gif differ diff --git a/es-419/images/target-stand.png b/es-419/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/es-419/images/target-stand.png differ diff --git a/es-419/images/target_area.png b/es-419/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/es-419/images/target_area.png differ diff --git a/es-419/images/three-circles.png b/es-419/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/es-419/images/three-circles.png differ diff --git a/es-419/images/top-left.png b/es-419/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/es-419/images/top-left.png differ diff --git a/es-419/images/triangles-coords.png b/es-419/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/es-419/images/triangles-coords.png differ diff --git a/es-419/images/upgrade-ideas.png b/es-419/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/es-419/images/upgrade-ideas.png differ diff --git a/es-419/images/yellow-points.png b/es-419/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/es-419/images/yellow-points.png differ diff --git a/es-419/meta.yml b/es-419/meta.yml new file mode 100644 index 000000000..d1ce4d02c --- /dev/null +++ b/es-419/meta.yml @@ -0,0 +1,33 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Introduction + - + title: Create a background + - + title: Draw your target + completion: engaged + - + title: Fire the arrow + - + title: Score points + - + title: Reflection + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: internal + - + title: Upgrade your project + completion: external + - + title: What next? diff --git a/es-419/quiz1/question_1.md b/es-419/quiz1/question_1.md new file mode 100644 index 000000000..62fb5bfa0 --- /dev/null +++ b/es-419/quiz1/question_1.md @@ -0,0 +1,55 @@ +## Reflection + +Well done, you made a game! Now it's time to reflect — reflecting is an important part of learning because it helps make new connections in your brain. + +Answer the three questions below to reflect on what you've learnt. + +After each question, press **submit**. You will be guided towards the correct answer. You can do this activity as many times as you want to. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +Here is a blue square, what are the RGB values that will create it? + +![A single block of blue colour.](images/quiz-colour.png) + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +Not quite, when all the colour values are set to `0`, the color is **black**. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite, colours follow the RGB model. This colour has maximum R value and no G or B, so will be **red**. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + That's correct! Colours follow the RGB model. This colour has no R or G, but maximum B, so will be **blue**. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite, when all the colour values are set to the `255` maximum, the color is **white**. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/es-419/quiz1/question_2.md b/es-419/quiz1/question_2.md new file mode 100644 index 000000000..4e34bc1d4 --- /dev/null +++ b/es-419/quiz1/question_2.md @@ -0,0 +1,50 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +When this code is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- + +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + No, with the else statement, there will always be something that is true. Therefore, an output will be printed. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/es-419/quiz1/question_3.md b/es-419/quiz1/question_3.md new file mode 100644 index 000000000..ff4ceecc2 --- /dev/null +++ b/es-419/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +An ellipse is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0,255,0) +no_stroke() + +def draw(): +ellipse(0,0,300,300) + +run() + +--- /code --- + +Which of the images below show the correct position of this ellipse in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `ellipse(400,400,300,300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `ellipse(200,200,300,300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `ellipse(350,150,300,300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/es-419/step_1.md b/es-419/step_1.md new file mode 100644 index 000000000..4612f6a39 --- /dev/null +++ b/es-419/step_1.md @@ -0,0 +1,39 @@ +## Introduction + +Use Python, with the `p5` graphics library, to draw a target and score points by hitting it with arrows. + +You will: + + Personalise your game with **RGB colours** + + Use **conditional statements** (`if`, `elif`, `else`) to make decisions + + Position shapes with **x, y coordinates**

+ RGB colours have values between 0 and 255 for each of R(ed), G(reen), and B(lue). Purple has values R,G,B (128, 0, 128) — medium amounts of red and blue, with no green. Video game artists and graphic designers work with RGB colours. +

+ +--- no-print --- + +--- task --- + +### Try it +
+
+Click the **Run** button below to start the game. When the dot appears on the target, click the mouse (or tap on your tablet) to fire your arrow. + +Have a few goes. Your score appears in the output area below the target. How does your score change when the arrow lands on the different colours? + +
+
+ +--- /task --- + +--- /no-print --- + +--- print-only --- + +![Completed project.](images/yellow-points.png) + +--- /print-only --- + +

+The oldest evidence of archery comes from the Sibudu Cave in KwaZulu-Natal, South Africa. Remains of stone and bone arrowheads have been found, which date to between 60,000 and 70,000 years ago. +

diff --git a/es-419/step_2.md b/es-419/step_2.md new file mode 100644 index 000000000..b6734be61 --- /dev/null +++ b/es-419/step_2.md @@ -0,0 +1,141 @@ +## Create a background + +
+
+The sky and grass are made by writing code to draw coloured rectangles. +
+
+ +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="300px"} + +
+
+ +--- task --- + +Open the [Archery starter](https://trinket.io/python/9973649e5c){:target="_blank"} project. + +If you have a Trinket account, you can click on the **Remix** button to save a copy to your `My Trinkets` library. + +--- /task --- + +The starter project has some code already written for you to import the `p5` library, you will use this library to build your archery game. + +[[[p5-processing-library]]] + +--- task --- + +The `fill()` function sets the inside colour of shapes. The starter project already contains some RGB colours you can use to do this. + +Find your `draw()` function and prepare to draw the sky by adding indented code to set the `fill()` colour to `sky`: + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 18 +line_highlights: 25 +--- + +def draw(): +#Things to do in every frame +sky = color(92, 204, 206) #Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) + + fill(sky) + +--- /code --- + +--- /task --- + +The `size()` function call in `setup()` sets the screen size to 400 pixels by 400 pixels. + +[[[p5-coordinates]]] + +--- task --- + +After your `fill()` code, draw a `rect()` for the sky with top-left coordinates (`0`,`0`), a width of `400` to match the width of the screen and a height of `250`. + +![A blue rectangle with a coordinates grid showing the position of the sky rectangle starting in the top corner, above a grey rectangle.](images/sky_coords.png) + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 25 +line_highlights: 26 +--- + + fill(sky) rect(0, 0, 400, 250) #Start x, start y, width, height + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the sky you've drawn. Remember that with the `p5` library, the `run()` function calls the `setup()` function once, then the `draw()` function repeatedly. + +![A blue rectangle with a black border around it, above a grey rectangle.](images/sky_stroke.png){:width="300px"} + +That's a bit strange: there's a black line around your sky! This is because, when the program starts, it automatically sets a black border — called a **stroke** — around everything it draws. + +--- /task --- + +--- task --- + +Turn off the stroke by adding `no_stroke()` before you start drawing the sky. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 23 +line_highlights: 25 +--- + + outer = color(0, 120, 180) + + no_stroke() +fill(sky) +rect(0, 0, 400, 250) #x, y, width, height + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project again to check that the stroke has gone. + +--- /task --- + +--- task --- + +`fill()` changes the fill colour for all shapes drawn until `fill()` is called again with a new colour. + +Change the `fill()` colour to `grass` and add another `rect(x, y, width, height)`. + +This rectangle needs to be positioned below the sky at coordinates (0, 250), so that it starts in the lower part of the screen. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 23 +line_highlights: 28-29 +--- + + outer = color(0, 120, 180) + + no_stroke() +fill(sky) +rect(0, 0, 400, 250) #x, y, width, height +fill(grass) +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project again to view the finished background. + +--- /task --- + +--- save --- diff --git a/es-419/step_3.md b/es-419/step_3.md new file mode 100644 index 000000000..28da55514 --- /dev/null +++ b/es-419/step_3.md @@ -0,0 +1,171 @@ +## Draw your target +
+
+The target stand is a triangle shape. The target is made with coloured circles — smaller circles are worth more points than larger ones. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +Shapes are drawn in the order that the lines of code run. The triangular wooden stand is partly behind the target circles so it must be drawn first. + +Imagine cutting all the shapes out of paper. Depending on how you arrange and overlap that paper, the final result could look very different. + +### Draw the stand + +--- task --- + +When you call the `triangle()` function, you need to provide three sets of coordinates, `x1, y1, x2, y2, x3, y3` each representing the position of one of the triangle's corners. + +--- collapse --- +--- +title: Triangle coordinates +--- + + Here are three example triangles, each with different sets of coordinates. Look at the grid position of each to see how the `x` and `y` coordinates position the corners of the triangles: + + Green triangle: triangle(50, 50, 150, 50, 180, 100) + + Blue triangle: triangle(210, 280, 300, 350, 380, 100) + + Brown triangle: triangle(50, 150, 200, 250, 180, 350) + + ![The output area with three triangles.](images/triangles-coords.png) + +--- /collapse --- + +Draw a `triangle()` for the stand with corners at (150, 350), (200, 150), and (250, 350). + +![A brown triangle on grass and against a sky with the coordinate points labelled.](images/stand_coords.png) + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 28 +line_highlights: 31-32 +--- + + fill(grass) +rect(0, 250, 400, 150) #x, y, width, height + + fill(wood) #Set the stand fill colour to brown +triangle(150, 350, 200, 150, 250, 350) + + +--- /code --- + +**Tip:** We have added comments to our code, like `#Set the stand fill colour to brown`, to tell you what it does. You don't need to add these comments to your code, but they can be helpful to remind you what lines of code do. + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target. + +![A brown triangle on grass and against a sky.](images/target-stand.png) + +--- /task --- + +### Draw the target + +--- task --- + +The largest part of the target will be a blue **circle** made by using the `ellipse()` function. An ellipse is a shape with a single side and no corners. It can be squashed, like an oval, or perfecly round, like a circle. + +An ellipse needs `x` and `y` coordinates, width, and height. The `x` and `y` coordinates of an ellipse are the centre position. + +The blue circle will cover the brown triangle where they overlap, because the circle was drawn later. + +**Tip:** To make a circle, the **width** and **height** must be the same. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 33-34 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) +ellipse(200, 200, 170, 170) #Outer circle. 200, 200 is the middle of the screen + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png) + +--- /task --- + +--- task --- + +Create two new variables to store colours `inner` and `bullseye` for the remaining circles. + +Assign colours to the `inner` and `bullseye` variables using `color()`. + +The `color()` function expects three numbers: one each for red, green, and blue. + +We used numbers that give traditional archery target colours, but you can use whatever colours you like as long as they are different from each other. + +[[[generic-theory-simple-colours]]] + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 18 +line_highlights: 24-25 +--- + +def draw(): +#Things to do in every frame + + sky = color(92, 204, 206) +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) #Blue +inner = color(210, 60, 60) # Red +bullseye = color(220, 200, 0) #Yellow + +--- /code --- + +--- /task --- + +--- task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200) — the middle of the screen. + +Add two more circles to represent an inner circle and the bullseye. Change the `fill()` before drawing each circle. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 33 +line_highlights: 37-40 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) #Stand +fill(outer) +ellipse(200, 200, 170, 170) #Outer circle +fill(inner) +ellipse(200, 200, 110, 110) #Inner circle +fill(bullseye) +ellipse(200, 200, 30, 30) #Bullseye + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project again to see the target with three coloured circles. Change the colours until you are happy with them. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png) + +**Debug:** Python uses the American spelling of 'color' (without a 'u') so make sure you do the same. + +--- /task --- + +--- save --- + diff --git a/es-419/step_4.md b/es-419/step_4.md new file mode 100644 index 000000000..691adc45a --- /dev/null +++ b/es-419/step_4.md @@ -0,0 +1,210 @@ +## Fire your arrow + +
+
+Now it's time to add an arrow that moves randomly across the target area. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +--- task --- + +Find the comment **#The shoot_arrow function goes here** and below it add code to define your `shoot_arrow()` function. + +Add a small `ellipse()` in the centre of the screen to represent the arrow. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 10 +line_highlights: 11-12 +--- + +# The shoot_arrow function goes here +def shoot_arrow(): +ellipse(200, 200, 15, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Go to the `draw()` code that creates the target and add code at the end to set the `fill()` to `wood`, then call your new `shoot_arrow()` function. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 41 +line_highlights: 44-45 +--- + + fill(bullseye) +ellipse(200, 200, 30, 30) + + fill(wood) +shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run you code and see the arrow appear in the bullseye. + +![The target on the background with a brown circle arrow on it.](images/arrow-middle.png) + +--- /task --- + +

Computer games, videos, and animations create the effect of movement by showing lots of images one after another. Each image is called a frame . The speed that the image changes at is called the frame rate and is given in fps or frames per second. +

+ +The `frame_rate(2)` line in `setup()` sets the frame rate to 2 frames per second. + +The `draw()` function is called every frame. You are going to draw the arrow in a random position each time `draw()` is called. + +The background and target will be drawn over the old arrow. This means you only see one arrow at a time. + +--- task --- + +Find the `import` statements, at the top of your code, you are going to use `randint` from the `random` library. + +--- code --- +--- +language: python filename: main.py line_numbers: true +line_number_start: 3 +--- + +# Import library code +from p5 import * +from math import * +from random import randint + +--- /code --- + +--- /task --- + +--- task --- + +Go to your `shoot_arrow()` function and add two new `arrow_x` and `arrow_y` variables to store random numbers between `100` and `300`. + +This will let some shots miss the target, without them going all the way to the edges of your game. + +Change your `ellipse()` to use the new variables to position your arrow. + +![A rectangle showing the target area coordinates in a semi transparent rectangle.](images/target_area.png) + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 10 +line_highlights: 12-14 +--- + +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +ellipse(arrow_x, arrow_y, 15, 15) #Upate to random coordinates + +--- /code --- + +--- /task --- + +### Get the colour the arrow hits + +The `get()` function returns the colour of a pixel. + +

+A pixel, short for picture element, is a single coloured dot within an image. Images are made up of lots of coloured pixels. +

+ +--- task --- + +You need to store the colour that the arrow is aiming at before you draw an arrow on top of it. + +Add code to store the `hit_color`. Use the `get()` function, to get the colour of the pixel at the `arrow_x` and `arrow_y` coordinates — the centre of the arrow. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 10 +line_highlights: 14 +--- + +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) #Save the colour before drawing the arrow +ellipse(arrow_x, arrow_y, 15, 15) + +--- /code --- + +**Tip:** The code to get the colour and save it needs to be **before** the code to draw the ellipse otherwise you will always save the wood colour of the arrow! + +--- /task --- + +The `p5` library 'listens' for certain events, one of these is the press of the mouse button. When it detects that the button has been pressed, it will run whatever code it has been given in the `mouse_pressed()` function. + +--- task --- + +Find the comment **#The mouse_pressed function goes here** and below it add code to define your `mouse_pressed()` function. + +Add code to print the amounts of red, green, and blue in the pixel the arrow lands on. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 9-10 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +print( red(hit_color), green(hit_color), blue(hit_color) ) + +--- /code --- + +--- /task --- + +--- task --- + +You have defined two functions `shoot_arrow()` and `mouse_pressed()`, both of these functions need to use the `hit_color` variable. + +A variable that needs to be used thoughout a program is known as a **global variable**. Add code to your `shoot_arrow()` function to make `hit_color` a global variable: + +--- code --- +--- +language: python filename: main.py - shoot_arrow() line_numbers: true line_number_start: 12 +line_highlights: 14 +--- + +# The shoot_arrow function goes here +def shoot_arrow(): +global hit_color #Can be used in other functions +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) #Save the colour before drawing the arrow +ellipse(arrow_x, arrow_y, 15, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project. The arrow is redrawn at random coordinates. + +The project gets the `hit_color` each time the arrow is redrawn and prints the colour value in the output area underneath the target. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +**Debug:** If you are seeing a message about `hit_colour` being 'not defined', then go back to `shoot_arrow()` and check that you have the `global hit_color` line. + +**Debug:** Check the `print` line really carefully for commas and brackets. + +--- /task --- + +--- save --- + diff --git a/es-419/step_5.md b/es-419/step_5.md new file mode 100644 index 000000000..5695ef1d9 --- /dev/null +++ b/es-419/step_5.md @@ -0,0 +1,165 @@ +## Score points + +
+
+In this step, you will add scores based on where the arrow hits. +
+
+ +![The target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +The colour variables in the `draw()` function will be used to check the score in the `mouse_pressed()` function. To do this, they need to be set as global variables: + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 28 +--- + +def draw(): +# Things to do in every frame + global outer, inner, bullseye +sky = color(92, 204, 206) #Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +bullseye = color(220, 200, 0) + +--- /code --- + +--- /task --- + +

+We use conditions all the time to make decisions. We could say 'if the pencil is blunt, then sharpen it'. Similarly, `if` conditions let us write code that does something different depending on whether a condition is true or false. +

+ +--- task --- + +To `print` a message for the target's outer circle, add code to your `mouse_pressed()` function to check if the `hit_color` is `==` to `outer`. + +Be careful when using the `=` symbol in Python: + + `=` is used for **assignment** — like `arrow_x = 200` to set the value of a variable + + `==` is used to test **equivalence** — like `hit_color == bullseye` — if the things on either side have the same value, then the test is `True`, otherwise it is `False` + +Change the code in your `print()` to give a score: + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 10-11 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project. Try to stop the arrow on the blue outer circle to see your message. The colour of the pixel at the centre of the arrow is the colour that is saved and checked. + +**Tip:** `frame_rate()`, in `setup()`, controls how fast your game draws. If it's going too fast, set it to a lower number. + +![The output area with arrow touching the outer circle. The points print statement appears in the output area.](images/blue-points.png) + +**Debug:** Make sure your code matches exactly and you indented the code inside your `if` statement. The indent tells Python that the code should only run if the condition is `True`. + +--- /task --- + +As points will be scored if the arrow lands on the `inner` or `bullseye` circles too, `outer` is not the only circle you need to check. To do this, use `elif` (a shortened version of else - if). + +

+We use else - if to make decisions in real life. When you are painting a picture of the sky, you might check if there is a yellow paint for the sun. Else, if there is no yellow paint, you look for orange. Else, if there is no yellow or orange paint, you might use red — really lightly! +

+ +--- task --- + +An `elif` can only be used with an `if` statement and, like an `if`, it checks a condition. If the condition is `True`, the `elif` runs some code. + +What makes `elif` different is that it will only make that check if the conditions of the `if` and any `elif`s before it are `False`. + +Add `elif` statements for `inner` and `bullseye`. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 9 +line_highlights: 12-15 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == bullseye: +print('You hit the bullseye, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project. Try to stop the arrow on the red and yellow circles to see their messages. + +![The output area with arrow touching the inner circle. The points print statement appears in the output area.](images/yellow-points.png) + +**Debug:** Make sure your `elif` is at the same indentation level as your `if`, and the code inside your `elif` is at the same level as the code inside your `if`. + +**Debug:** If you see a message about `inner` or `bullseye` being 'not defined', then go back to `draw()` and check that they are on the line that declares variables global. + +```python +global outer, inner, bullseye +``` + +--- /task --- + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? To do this last check, you use `else`. + +

+We use if … else to make decisions. When you wake up, you check and if it is morning you get up, else you go back to sleep. Can you think of any if ... else decisions you make? +

+ +--- task --- + +Add code to `print` a message `else` none of the `if` and `elif` statements have been met. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 9 +line_highlights: 16-17 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == bullseye: +print('You hit the bullseye, 500 points!') +else: +print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project. Try to stop the arrow in the grass or sky to see the miss message. Change the number of points scored for the different colours if you like. + +![The output area with an arrow missing the target. The points print statement appears in the output area.](images/missed-points.png) + +--- /task --- + +--- save --- diff --git a/es-419/step_6.md b/es-419/step_6.md new file mode 100644 index 000000000..d7bab7933 --- /dev/null +++ b/es-419/step_6.md @@ -0,0 +1 @@ +## Reflection \ No newline at end of file diff --git a/es-419/step_7.md b/es-419/step_7.md new file mode 100644 index 000000000..a3696bcb3 --- /dev/null +++ b/es-419/step_7.md @@ -0,0 +1,36 @@ +## Upgrade your project + +
+
+Personalise and add more to your project. Perhaps you could change the difficulty level or add more circles to your target. +
+
+ +![The output area showing a target with five circles.](images/five_circles.png){:width="300px"} + +
+
+ +--- task --- + +You could: + ++ Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position ++ Put emoji in your print messages ([here's a list of emoji](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) ++ Make the game easier or harder by changing the `frame_rate(2)` value ++ Use `input()` to ask the user which difficulty level they want to play at + +--- /task --- + +![Upgraded project ideas: one with five circles, one with a difficulty input question, one with emoji in the points message.](images/upgrade-ideas.png) + +--- collapse --- +--- +title: Completed project +--- + +You can view the [completed project here](https://trinket.io/python/f686c82d8a){:target="_blank"}. + +--- /collapse --- + +--- save --- diff --git a/es-419/step_8.md b/es-419/step_8.md new file mode 100644 index 000000000..a7d0e10a4 --- /dev/null +++ b/es-419/step_8.md @@ -0,0 +1,31 @@ +## What next? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png) + +--- /print-only --- + +--- no-print --- + +--- task --- + +**Try it:** Your program will adjust the animation based on how much fuel you give it and will succeed or fail in reaching orbit. How much fuel do you want to use to reach orbit but not waste too much extra fuel? + +**Tip:** Around 25,000kg should be enough, but experiment with the numbers to see what happens. + + + +![Rocket launch project](images/showcase_rocket.png) + +--- /task --- + +--- /no-print --- + +If you want to have more fun exploring Python, then you could try out any of [these projects](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + + + diff --git a/es-LA/code/target-practice-solution/main.py b/es-LA/code/target-practice-solution/main.py new file mode 100644 index 000000000..fe6bcecb2 --- /dev/null +++ b/es-LA/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Importar código de biblioteca + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # imprimir('🎯') + if hit_colour == Color("blue").hex: + print("Le diste al círculo externo, ¡50 puntos!") + elif hit_colour == Color("red").hex: + print("Le diste al círculo interno, ¡200 puntos!") + elif hit_colour == Color("yellow").hex: + print("¡Le diste al centro, 500 puntos!") + else: + print("¡Fallaste! ¡Sin puntos!') + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Configura tu juego aquí + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Dibuja el círculo interior + fill("yellow") + circle(200, 200, 30) # Dibuja el círculo del medio + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/es-LA/code/target-practice-solution/project_config.yml b/es-LA/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/es-LA/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/es-LA/code/target-practice-starter/main.py b/es-LA/code/target-practice-starter/main.py new file mode 100644 index 000000000..eedda9979 --- /dev/null +++ b/es-LA/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Importa la biblioteca +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Configura tu juego aquí + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/es-LA/code/target-practice-starter/project_config.yml b/es-LA/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/es-LA/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/es-LA/images/alternative-colours.png b/es-LA/images/alternative-colours.png new file mode 100644 index 000000000..a688ac942 Binary files /dev/null and b/es-LA/images/alternative-colours.png differ diff --git a/es-LA/images/animation_bg_erase.gif b/es-LA/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/es-LA/images/animation_bg_erase.gif differ diff --git a/es-LA/images/animation_no_bg_erase.gif b/es-LA/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/es-LA/images/animation_no_bg_erase.gif differ diff --git a/es-LA/images/arrow-centre.png b/es-LA/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/es-LA/images/arrow-centre.png differ diff --git a/es-LA/images/arrow-middle.png b/es-LA/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/es-LA/images/arrow-middle.png differ diff --git a/es-LA/images/arrow-target.png b/es-LA/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/es-LA/images/arrow-target.png differ diff --git a/es-LA/images/background.png b/es-LA/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/es-LA/images/background.png differ diff --git a/es-LA/images/banner.png b/es-LA/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/es-LA/images/banner.png differ diff --git a/es-LA/images/blue-circle.png b/es-LA/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/es-LA/images/blue-circle.png differ diff --git a/es-LA/images/blue-points.png b/es-LA/images/blue-points.png new file mode 100644 index 000000000..cd90ab957 Binary files /dev/null and b/es-LA/images/blue-points.png differ diff --git a/es-LA/images/blue_circle_points.gif b/es-LA/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/es-LA/images/blue_circle_points.gif differ diff --git a/es-LA/images/bottom-right.png b/es-LA/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/es-LA/images/bottom-right.png differ diff --git a/es-LA/images/centre.png b/es-LA/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/es-LA/images/centre.png differ diff --git a/es-LA/images/circle-coords.png b/es-LA/images/circle-coords.png new file mode 100644 index 000000000..6c0d2c78b Binary files /dev/null and b/es-LA/images/circle-coords.png differ diff --git a/es-LA/images/coords_animation.gif b/es-LA/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/es-LA/images/coords_animation.gif differ diff --git a/es-LA/images/difficulty-setting.png b/es-LA/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/es-LA/images/difficulty-setting.png differ diff --git a/es-LA/images/fire_arrow.gif b/es-LA/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/es-LA/images/fire_arrow.gif differ diff --git a/es-LA/images/five_circles.png b/es-LA/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/es-LA/images/five_circles.png differ diff --git a/es-LA/images/green-grass.png b/es-LA/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/es-LA/images/green-grass.png differ diff --git a/es-LA/images/grey-circle.png b/es-LA/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/es-LA/images/grey-circle.png differ diff --git a/es-LA/images/grey-points.png b/es-LA/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/es-LA/images/grey-points.png differ diff --git a/es-LA/images/initial_target.png b/es-LA/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/es-LA/images/initial_target.png differ diff --git a/es-LA/images/missed-points.png b/es-LA/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/es-LA/images/missed-points.png differ diff --git a/es-LA/images/missed_no_points.gif b/es-LA/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/es-LA/images/missed_no_points.gif differ diff --git a/es-LA/images/outline-circles.png b/es-LA/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/es-LA/images/outline-circles.png differ diff --git a/es-LA/images/points-scored.gif b/es-LA/images/points-scored.gif new file mode 100644 index 000000000..d91309212 Binary files /dev/null and b/es-LA/images/points-scored.gif differ diff --git a/es-LA/images/quiz-colour.png b/es-LA/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/es-LA/images/quiz-colour.png differ diff --git a/es-LA/images/random-side.png b/es-LA/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/es-LA/images/random-side.png differ diff --git a/es-LA/images/rectangle-diagram.png b/es-LA/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/es-LA/images/rectangle-diagram.png differ diff --git a/es-LA/images/showcase_rocket.png b/es-LA/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/es-LA/images/showcase_rocket.png differ diff --git a/es-LA/images/showcase_static.png b/es-LA/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/es-LA/images/showcase_static.png differ diff --git a/es-LA/images/sky_coords.png b/es-LA/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/es-LA/images/sky_coords.png differ diff --git a/es-LA/images/sky_stroke.png b/es-LA/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/es-LA/images/sky_stroke.png differ diff --git a/es-LA/images/stand_coords.png b/es-LA/images/stand_coords.png new file mode 100644 index 000000000..28e151045 Binary files /dev/null and b/es-LA/images/stand_coords.png differ diff --git a/es-LA/images/step_4_preview.gif b/es-LA/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/es-LA/images/step_4_preview.gif differ diff --git a/es-LA/images/step_5_preview.gif b/es-LA/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/es-LA/images/step_5_preview.gif differ diff --git a/es-LA/images/target-stand.png b/es-LA/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/es-LA/images/target-stand.png differ diff --git a/es-LA/images/target_area.png b/es-LA/images/target_area.png new file mode 100644 index 000000000..72d80ba1d Binary files /dev/null and b/es-LA/images/target_area.png differ diff --git a/es-LA/images/target_printed.gif b/es-LA/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/es-LA/images/target_printed.gif differ diff --git a/es-LA/images/three-circles.png b/es-LA/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/es-LA/images/three-circles.png differ diff --git a/es-LA/images/top-left.png b/es-LA/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/es-LA/images/top-left.png differ diff --git a/es-LA/images/triangles-coords.png b/es-LA/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/es-LA/images/triangles-coords.png differ diff --git a/es-LA/images/upgrade-ideas.png b/es-LA/images/upgrade-ideas.png new file mode 100644 index 000000000..b55cb6e2e Binary files /dev/null and b/es-LA/images/upgrade-ideas.png differ diff --git a/es-LA/images/yellow-points.png b/es-LA/images/yellow-points.png new file mode 100644 index 000000000..65e6a043e Binary files /dev/null and b/es-LA/images/yellow-points.png differ diff --git a/es-LA/meta.yml b/es-LA/meta.yml new file mode 100644 index 000000000..e0434cacf --- /dev/null +++ b/es-LA/meta.yml @@ -0,0 +1,41 @@ +--- +title: Tiro al blanco +hero_image: images/banner.png +description: Usa Python para dibujar un blanco y ganar puntos golpeándolo con flechas +meta_title: Proyectos de codificación Python para niños y adolescentes | Práctica de tiro al blanco +meta_description: Aprende Python con los proyectos de codificación de la Fundación Raspberry Pi para niños y adolescentes. Usa Python para dibujar un objetivo y ganar puntos tirando flechas. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Harás + - + title: Crea un fondo + - + title: Dibuja tu blanco + completion: + - comprometido + - + title: Dispara tu flecha + - + title: Gana puntos + - + title: Test rápido + completion: + - external + - + title: Mejora tu proyecto + knowledge_quiz: + path: prueba1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - externo + - + title: '¿Qué sigue?' + challenge: true + - + title: '¿Qué puedes hacer ahora?' diff --git a/es-LA/python-comments-demo.txt b/es-LA/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/es-LA/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/es-LA/python-comments.txt b/es-LA/python-comments.txt new file mode 100644 index 000000000..70474731c --- /dev/null +++ b/es-LA/python-comments.txt @@ -0,0 +1,27 @@ +Cosas que hacer en cada cuadro + +Draw the inner circle + +Draw the middle circle + +La función disparar_flecha va aquí + +La función mouse_pressed va aquí + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Súper rápido + +Bastante rápido + +Muy rapido + +¡Velocidad no reconocida! \ No newline at end of file diff --git a/es-LA/python-translatable-demo.txt b/es-LA/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/es-LA/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/es-LA/python-translatable.txt b/es-LA/python-translatable.txt new file mode 100644 index 000000000..eaf2ecaa1 --- /dev/null +++ b/es-LA/python-translatable.txt @@ -0,0 +1,9 @@ +disparar_flecha + +flecha_x + +flecha_y + +color_de_impacto + +velocidad \ No newline at end of file diff --git a/es-LA/quiz1/question_1.md b/es-LA/quiz1/question_1.md new file mode 100644 index 000000000..dc5805383 --- /dev/null +++ b/es-LA/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Examen rápido + +Contesta las tres preguntas. Hay sugerencias que te guían hacia la respuesta correcta. + +Cuando hayas respondido a cada pregunta, haz clic en **Revisar mi respuesta**. + +¡Qué te diviertas! + +--- pregunta --- +--- +legend: Pregunta 1 de 3 +--- +En tu proyecto agregaste `randint(100, 300)` a tu función `shoot_arrow()`. ¿Qué hace `randint(100, 300)`? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- opciones --- + +- (x) Elige un número entero aleatorio entre 100 y 300. + + --- feedback --- + +That's correct. Esto elige una coordenada x aleatoria para tu flecha. + + --- /retroalimentación --- + +- ( ) Hace que la flecha se mueva aleatoriamente por la pantalla. + + --- feedback --- + +Not quite. Esta parte del código muestra cómo la flecha se mueve aleatoriamente, pero también necesitas otro código para que alcance el objetivo. + + --- /retroalimentación --- + +- () Obtiene el color donde se clavó la flecha. + + --- feedback --- + + Not quite. La función get() se puede utilizar para obtener el color. + + --- /feedback --- + +- ( ) Dibuja un círculo de tamaño aleatorio. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /opciones --- + +--- /pregunta --- diff --git a/es-LA/quiz1/question_2.md b/es-LA/quiz1/question_2.md new file mode 100644 index 000000000..37e7c7792 --- /dev/null +++ b/es-LA/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Pregunta 2 de 3 +--- + +En su proyecto, usaste condiciones `if`, `elif` y `else` para verificar en qué color aterrizó la flecha. + +En el siguiente ejemplo, una variable llamada `velocidad` `6` almacena el número 6. Cuando se ejecuta esta instrucción `if`, ¿qué se imprimirá en el área de salida? + +--- code --- +--- +language: python +--- +velocidad = 6 + +if velocidad == 7: print('Súper rápido') elif velocidad == 5: print('Bastante rápido') elif velocidad == 6: print('Muy rápido') else: print('¡Velocidad no reconocida!') + +--- /code --- + +--- choices --- + +- (x) `Muy rápido` + + --- feedback --- + + ¡Correcto! A la variable **velocidad** se le ha asignado el valor `6`, lo que hace que la `velocidad == 6` Sea **Verdadero** e imprima `Muy rápido`. + + --- /feedback --- + +- ( ) `¡Velocidad no reconocida!` + + --- feedback --- + + No del todo, mira el valor asignado a la variable **velocidad**. + + --- /feedback --- + +- ( ) No se escribe nada + + --- feedback --- + + Inténtalo de nuevo, `else` se usa como una opción final para cuando todas las condiciones anteriores son falsas. Mira nuevamente las condiciones, ¿alguna de las condiciones es verdadera? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/es-LA/quiz1/question_3.md b/es-LA/quiz1/question_3.md new file mode 100644 index 000000000..b5d399c30 --- /dev/null +++ b/es-LA/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Pregunta 3 de 3 +--- + +Un círculo se dibuja usando el siguiente código: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +¿Cuál de las siguientes imágenes muestra la posición correcta de este círculo en el área de salida? + +--- choices --- + +- ( ) ![Un círculo verde centrado en la esquina inferior derecha del área de salida.](images/bottom-right.png) + + --- feedback --- + + No del todo, para centrar el círculo en la esquina inferior derecha, las coordenadas deberían ser las mismas que el tamaño de la pantalla. En este ejemplo, la elipse sería `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Un círculo verde centrado en el medio del área de salida.](images/centre.png) + + --- feedback --- + + No del todo, para centrar el círculo en el medio, las coordenadas tendrían que ser la mitad del tamaño de la pantalla. En este ejemplo, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Un círculo verde centrado en la esquina superior izquierda del área de salida.](images/top-left.png) + + --- feedback --- + + ¡Correcto! Este círculo está centrado en las coordenadas (0,0), la esquina superior izquierda de la pantalla. + + --- /feedback --- + +- ( ) ![Un círculo verde centrado hacia el lado superior derecho del área de salida.](images/random-side.png) + + --- feedback --- + + No, el código de este círculo sería `circle(350, 150, 300)` para centrarlo hacia la parte superior derecha de la pantalla. La coordenada `x` es qué tan lejos está la elipse a través de la pantalla, y la coordenada `y` es qué tan lejos está hacia abajo de la pantalla. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/es-LA/resources/main.py b/es-LA/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/es-LA/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/es-LA/resources/p5.py b/es-LA/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/es-LA/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/es-LA/step_1.md b/es-LA/step_1.md new file mode 100644 index 000000000..ba6e09db2 --- /dev/null +++ b/es-LA/step_1.md @@ -0,0 +1,29 @@ +## Lo que harás + +Usa Python, con la biblioteca de gráficos `p5`, para dibujar una diana y ganar puntos golpeándolo con flechas. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Haz clic en el botón **Ejecutar** abajo para iniciar el juego. Cuando aparezca el punto en el objetivo 🎯, haz clic con el mouse (o toca en tu tableta) para disparar tu flecha. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/es-LA/step_2.md b/es-LA/step_2.md new file mode 100644 index 000000000..b61a8b8b9 --- /dev/null +++ b/es-LA/step_2.md @@ -0,0 +1,37 @@ +## Dibuja el césped + +--- task --- + +Abre el [proyecto inicial de Tiro al blanco](https://trinket.io/python/88502d5879){:target="_blank"}. + +--- /task --- + +--- task --- + +**Agregue** código para dibujar un rectángulo verde en la parte inferior de la pantalla. + +![El área de salida con un rectángulo color cielo sobre un rectángulo color hierba para crear el fondo. La esquina superior izquierda del rectángulo está marcada como x=0, y=250, este es el origen del rectángulo. El ancho de 400 y la altura de 150 están resaltados. Se muestra el código rect(0, 250, 400, 150).](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 17 +line_highlights: 15 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Prueba:** Ejecuta tu proyecto de nuevo para ver el fondo terminado. + +![El área de salida con un rectángulo color cielo sobre un rectángulo color césped para crear el fondo.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/es-LA/step_3.md b/es-LA/step_3.md new file mode 100644 index 000000000..9b685fdaf --- /dev/null +++ b/es-LA/step_3.md @@ -0,0 +1,117 @@ +## Dibuja tu blanco + +
+
+Tu juego necesita un blanco al que disparar flechas. +
+
+ +![El área de salida con el blanco y el soporte.](images/three-circles.png){:width="300px"} + +
+
+ +### Dibuja un soporte triangular + +--- task --- + +Establece el color de relleno a `madera` (marrón). + +Dibuja un triángulo usando las coordenadas x e y para cada una de las esquinas. + +![Un triángulo marrón sobre hierba y contra un cielo con los puntos de coordenadas etiquetados en 150, 350 y 200, 150 y 250, 350). Las esquinas del lienzo también están etiquetadas como x=0, y=0 en la parte superior izquierda y x=400, y=400 en la parte inferior derecha.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 27 +line_highlights: 29, 30 +--- + + fill(pasto)
+ rect(0, 250, 400, 150) + fill(madera) # Establece el color de relleno del soporte en madera
+ triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Prueba:** Ejecuta tu código para ver el soporte de tu blanco: + +![Un triángulo marrón sobre el césped y contra el cielo.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Dibuja los círculos del blanco + +--- task --- + +La parte más grande del blanco es un **círculo** azul. + +Establece el color de relleno en `externo` (azul). + +Dibuja un círculo con coordenadas x e y para su centro y un ancho. + +![Un triángulo marrón y un círculo azul sobre el césped y contra el cielo. El círculo está etiquetado con las coordenadas x=200, y=200 como el centro y el ancho del círculo de 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 17 +line_highlights: 31, 32 +--- + + fill(madera)
+ triangle(150, 350, 200, 150, 250, 350)
+ fill(externo) # Establece el color de relleno del círculo en exterior
+ circle(200, 200, 170) # x, y, ancho del círculo + +--- /code --- + +--- /task --- + +--- task --- + +**Prueba:** Ejecuta tu código para ver el primer círculo grande azul. + +El círculo azul se dibujó después del soporte, por lo que está al frente: + +![Un triángulo marrón y un círculo azul sobre el césped y contra el cielo.](images/blue-circle.png){:width="400px"} + +--- /task --- + +El blanco está formado por círculos de diferentes tamaños con las mismas coordenadas centrales (200, 200); el centro de la pantalla. + +--- task --- + +**Agregue** círculos de colores para las partes interior y media del objetivo. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 29 +line_highlights: 24, 25 +--- + + fill(madera)
+ triangle(150, 350, 200, 150, 250, 350)
+ fill(externo)
+ circle(200, 200, 170) + fill(interno) # Establece el color de relleno del círculo en interior
+ circle(200, 200, 110) # Círculo interior - x, y, ancho del círculo
+ fill(medio) # Establece el color de relleno del círculo en medio
+ circle(200, 200, 30) # Círculo medio - x, y, ancho del círculo + +--- /code --- + +--- /task --- + +--- task --- + +**Prueba:** Vuelve a ejecutar tu proyecto para ver el blanco con tres círculos de colores. + +![Un triángulo marrón con tres círculos de colores sobre el césped y contra el cielo.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/es-LA/step_4.md b/es-LA/step_4.md new file mode 100644 index 000000000..96622abcf --- /dev/null +++ b/es-LA/step_4.md @@ -0,0 +1,96 @@ +## Dispara tu flecha + +
+
+Añade un círculo aún más pequeño para representar una flecha. +
+
+ +![El blanco, con una flecha circular marrón que aparece en una variedad de posiciones.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### ¿Donde dispararás? + +--- task --- + +Agrega una función para dibujar un círculo marrón en las coordenadas `200`, `200`. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 10, 11, 12, 13, 14 +--- +# La función disparar_flecha va aquí +def disparar_flecha(): +global color_de_impacto # Se puede utilizar en otras funciones +flecha_x = randint(100, 300) +flecha_y = randint(100, 300) +color_de_impacto = get(flecha_x, flecha_y) # Guardar el color antes de dibujar la flecha fill(madera) +circle(flecha_x, flecha_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Ve a la función `draw` y llama a tu nueva función `disparar_flecha`. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 42 +line_highlights: 44 +--- + + fill(medio)
+ circle(200, 200, 30)
+ disparar_flecha() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Ejecuta tu proyecto. Deberías ver la flecha en el centro. + +![un círculo marrón representando la flecha en el centro del objetivo](images/arrow-centre.png) + + +--- /task --- + +La flecha debe moverse aleatoriamente. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python filename: main.py — disparar_flecha() line_numbers: true line_number_start: 9 +line_highlights: 13 +--- +def disparar_flecha(): +flecha_x = randint(100, 300) +flecha_y = randint(100, 300) +color_de_impacto = get(flecha_x, flecha_y) # Consigue el color en que cayó la flecha fill(madera) +circle(flecha_x, flecha_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Ejecuta tu proyecto. Deberías ver la flecha saltar alrededor del objetivo. + +![El blanco, con una flecha circular marrón apareciendo en una variedad de posiciones.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/es-LA/step_5.md b/es-LA/step_5.md new file mode 100644 index 000000000..2747a9de9 --- /dev/null +++ b/es-LA/step_5.md @@ -0,0 +1,86 @@ +## ¿Que color te salió? + +A continuación, agregarás código para obtener el color en la ubicación de la flecha. + +### Obtener el color donde se clavó la flecha + +--- task --- + +**Depuración:** 🐞 Si ve un mensaje sobre `interno` o `medio` que están 'not defined', vuelve a `draw()` y verifica que estén en la línea que declara variables globales. + +Agregue código para `obtener (get)` el color en el centro de la flecha y almacenarlo en la variable `hit_colour` . + + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 8 +line_highlights: 28 +--- +def mouse_pressed(): +if color_de_impacto == externo: +print('Le diste al círculo externo, ¡50 puntos!') +elif color_de_impacto == interno: +print('Le diste al círculo interno, ¡200 puntos!') +elif color_de_impacto == medio: +print('¡Le diste al centro, 500 puntos!') +else: +print('¡Fallaste! ¡Sin puntos!') + +--- /code --- + +**Elije:** 💭 Cambia la cantidad de puntos que ganas para los diferentes colores si así lo deseas. + +--- /task --- + +--- task --- + +**Prueba:** Ejecuta tu proyecto. Deberías ver los colores impresos en la **salida de texto**, en formato hexadecimal. + +--- /task --- + +### Imprime el color cuando se presiona el mouse + +--- task --- + +Comment out the line that prints the colour. Esto significa que no funcionará. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 9 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9, 10 +--- +# La función mouse_pressed va aquí +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Prueba:** Ejecuta tu proyecto. Intenta detener la flecha en los círculos interior y medio para ver sus mensajes. + +![emoji de objetivo impreso al hacer clic con el mouse](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/es-LA/step_6.md b/es-LA/step_6.md new file mode 100644 index 000000000..da1fa5c1e --- /dev/null +++ b/es-LA/step_6.md @@ -0,0 +1,112 @@ +## Gana puntos + +
+
+Añade una puntuación basada en dónde impacta la flecha. +
+
+ +![Una animación del blanco, con la flecha apareciendo en una variedad de posiciones y puntajes que aparecen como texto debajo del juego.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comenta la línea para imprimir el carácter 🎯 para que ya no se ejecute. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Muestra un mensaje **si (if)** el `hit_colour`{:.language-python} es igual al `color del círculo exterior` (azul). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print(''Le diste al círculo externo, ¡50 puntos!') + +--- /code --- + +**Consejo:** Si cambiaste el color de tu círculo exterior, deberás reemplazar `blue (azul)` con el nombre del color que hayas elegido. + +--- /task --- + +--- task --- + +**Prueba:** Haz clic en el botón **Ejecutar (Run)**. Espera a que la flecha aterrice en el círculo azul y luego haz clic con el botón izquierdo del mouse. ![puntos obtenidos al hacer clic en el círculo azul](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} se puede usar para agregar más condiciones a tu declaración `if`{:.language-python}. + +--- task --- + +Agrega más código para sumar puntos si la flecha cae en los círculos **internos ** o en los círculos **centrales **. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print(''Le diste al círculo externo, ¡50 puntos!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('¡Le diste al centro, 500 puntos!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Fallar el blanco + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('¡Le diste al centro, 500 puntos!') + else: + print('¡Fallaste! ¡Sin puntos!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/es-LA/step_7.md b/es-LA/step_7.md new file mode 100644 index 000000000..33c047a0d --- /dev/null +++ b/es-LA/step_7.md @@ -0,0 +1 @@ +## Test rápido \ No newline at end of file diff --git a/es-LA/step_8.md b/es-LA/step_8.md new file mode 100644 index 000000000..cd72e24fe --- /dev/null +++ b/es-LA/step_8.md @@ -0,0 +1,36 @@ +## Desafío + +--- desafío --- + + +Podrías: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Poner emojis en tus mensajes impresos ([aquí hay una lista de emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} que puedes usar para copiar) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /no-print --- diff --git a/es-LA/step_9.md b/es-LA/step_9.md new file mode 100644 index 000000000..a33d53568 --- /dev/null +++ b/es-LA/step_9.md @@ -0,0 +1,21 @@ +## ¿Qué puedes hacer ahora? + +Si estás siguiendo la ruta [Introducción a Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro), puedes pasar al proyecto [Lanzamiento de cohete](https://projects.raspberrypi.org/en/projects/rocket-launch). En este proyecto, harás una animación interactiva de un cohete que lanza un satélite a la órbita. + +\--- print-only --- + +![Proyecto de lanzamiento de cohete.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/fr-FR/code/target-practice-solution/main.py b/fr-FR/code/target-practice-solution/main.py new file mode 100644 index 000000000..0c658a9cc --- /dev/null +++ b/fr-FR/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Importer le code de la bibliothèque + +from p5 import * +from random import randint + + +# La fonction souris_pressee vient ici +def mouse_pressed(): + # print('🎯') + if couleur_touchee == Color("blue").hex: + print('Tu as touché le cercle extérieur, 50 points !') + elif couleur_touchee == Color('red').hex: + print('Tu as touché le cercle intérieur, 200 points !') + elif couleur_touchee == Color('yellow').hex: + print('Tu as touché le centre, 500 points !') + else: + print('Tu as loupé la cible ! Aucun point !') + + +# La fonction tire_fleche vient ici +def tire_fleche(): + global couleur_touchee + fleche_x = randint(100, 300) + fleche_y = randint(100, 300) + couleur_touchee = get(fleche_x, fleche_y).hex + # print(couleur_touchee) + fill("brown") + circle(fleche_x, fleche_y, 15) + + +def setup(): + # Configure ton jeu ici + size(400, 400) + no_stroke() + + +def draw(): + # Choses à faire dans chaque image + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Dessiner le cercle intérieur + fill("yellow") + circle(200, 200, 30) # Dessiner le cercle du milieu + tire_fleche() + + +# Garde ceci pour exécuter ton code +run(frame_rate=2) diff --git a/fr-FR/code/target-practice-solution/project_config.yml b/fr-FR/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..3dfec0d4f --- /dev/null +++ b/fr-FR/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Exemple de Tir sur cible' +identifier: 'target-practice-solution' +type: 'python' diff --git a/fr-FR/code/target-practice-starter/main.py b/fr-FR/code/target-practice-starter/main.py new file mode 100644 index 000000000..9d4f8633a --- /dev/null +++ b/fr-FR/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Importer le code de la bibliothèque +from p5 import * +from random import randint + +# La fonction souris_pressee vient ici + + +# La fonction tire_fleche vient ici + + +def setup(): + # Configure ton jeu ici + size(400, 400) + no_stroke() + + +def draw(): + # Choses à faire dans chaque image + fill("cyan") + rect(0, 0, 400, 250) + + +# Garde ceci pour exécuter ton code +run(frame_rate=2) diff --git a/fr-FR/code/target-practice-starter/project_config.yml b/fr-FR/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..110a0412e --- /dev/null +++ b/fr-FR/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Tir sur cible" +identifier: 'target-practice-starter' +type: 'python' diff --git a/fr-FR/images/alternative-colours.png b/fr-FR/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/fr-FR/images/alternative-colours.png differ diff --git a/fr-FR/images/animation_bg_erase.gif b/fr-FR/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/fr-FR/images/animation_bg_erase.gif differ diff --git a/fr-FR/images/animation_no_bg_erase.gif b/fr-FR/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/fr-FR/images/animation_no_bg_erase.gif differ diff --git a/fr-FR/images/arrow-centre.png b/fr-FR/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/fr-FR/images/arrow-centre.png differ diff --git a/fr-FR/images/arrow-middle.png b/fr-FR/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/fr-FR/images/arrow-middle.png differ diff --git a/fr-FR/images/arrow-target.png b/fr-FR/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/fr-FR/images/arrow-target.png differ diff --git a/fr-FR/images/background.png b/fr-FR/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/fr-FR/images/background.png differ diff --git a/fr-FR/images/banner.png b/fr-FR/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/fr-FR/images/banner.png differ diff --git a/fr-FR/images/blue-circle.png b/fr-FR/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/fr-FR/images/blue-circle.png differ diff --git a/fr-FR/images/blue-points.png b/fr-FR/images/blue-points.png new file mode 100644 index 000000000..a77c34e68 Binary files /dev/null and b/fr-FR/images/blue-points.png differ diff --git a/fr-FR/images/blue_circle_points.gif b/fr-FR/images/blue_circle_points.gif new file mode 100644 index 000000000..e818d42c2 Binary files /dev/null and b/fr-FR/images/blue_circle_points.gif differ diff --git a/fr-FR/images/bottom-right.png b/fr-FR/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/fr-FR/images/bottom-right.png differ diff --git a/fr-FR/images/centre.png b/fr-FR/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/fr-FR/images/centre.png differ diff --git a/fr-FR/images/circle-coords.png b/fr-FR/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/fr-FR/images/circle-coords.png differ diff --git a/fr-FR/images/coords_animation.gif b/fr-FR/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/fr-FR/images/coords_animation.gif differ diff --git a/fr-FR/images/difficulty-setting.png b/fr-FR/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/fr-FR/images/difficulty-setting.png differ diff --git a/fr-FR/images/fire_arrow.gif b/fr-FR/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/fr-FR/images/fire_arrow.gif differ diff --git a/fr-FR/images/five_circles.png b/fr-FR/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/fr-FR/images/five_circles.png differ diff --git a/fr-FR/images/green-grass.png b/fr-FR/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/fr-FR/images/green-grass.png differ diff --git a/fr-FR/images/grey-circle.png b/fr-FR/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/fr-FR/images/grey-circle.png differ diff --git a/fr-FR/images/grey-points.png b/fr-FR/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/fr-FR/images/grey-points.png differ diff --git a/fr-FR/images/initial_target.png b/fr-FR/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/fr-FR/images/initial_target.png differ diff --git a/fr-FR/images/missed-points.png b/fr-FR/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/fr-FR/images/missed-points.png differ diff --git a/fr-FR/images/missed_no_points.gif b/fr-FR/images/missed_no_points.gif new file mode 100644 index 000000000..e28795f49 Binary files /dev/null and b/fr-FR/images/missed_no_points.gif differ diff --git a/fr-FR/images/outline-circles.png b/fr-FR/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/fr-FR/images/outline-circles.png differ diff --git a/fr-FR/images/points-scored.gif b/fr-FR/images/points-scored.gif new file mode 100644 index 000000000..556dc51c5 Binary files /dev/null and b/fr-FR/images/points-scored.gif differ diff --git a/fr-FR/images/quiz-colour.png b/fr-FR/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/fr-FR/images/quiz-colour.png differ diff --git a/fr-FR/images/random-side.png b/fr-FR/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/fr-FR/images/random-side.png differ diff --git a/fr-FR/images/rectangle-diagram.png b/fr-FR/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/fr-FR/images/rectangle-diagram.png differ diff --git a/fr-FR/images/showcase_rocket.png b/fr-FR/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/fr-FR/images/showcase_rocket.png differ diff --git a/fr-FR/images/showcase_static.png b/fr-FR/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/fr-FR/images/showcase_static.png differ diff --git a/fr-FR/images/sky_coords.png b/fr-FR/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/fr-FR/images/sky_coords.png differ diff --git a/fr-FR/images/sky_stroke.png b/fr-FR/images/sky_stroke.png new file mode 100644 index 000000000..0d088147f Binary files /dev/null and b/fr-FR/images/sky_stroke.png differ diff --git a/fr-FR/images/stand_coords.png b/fr-FR/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/fr-FR/images/stand_coords.png differ diff --git a/fr-FR/images/step_4_preview.gif b/fr-FR/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/fr-FR/images/step_4_preview.gif differ diff --git a/fr-FR/images/step_5_preview.gif b/fr-FR/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/fr-FR/images/step_5_preview.gif differ diff --git a/fr-FR/images/target-stand.png b/fr-FR/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/fr-FR/images/target-stand.png differ diff --git a/fr-FR/images/target_area.png b/fr-FR/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/fr-FR/images/target_area.png differ diff --git a/fr-FR/images/target_printed.gif b/fr-FR/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/fr-FR/images/target_printed.gif differ diff --git a/fr-FR/images/three-circles.png b/fr-FR/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/fr-FR/images/three-circles.png differ diff --git a/fr-FR/images/top-left.png b/fr-FR/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/fr-FR/images/top-left.png differ diff --git a/fr-FR/images/triangles-coords.png b/fr-FR/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/fr-FR/images/triangles-coords.png differ diff --git a/fr-FR/images/upgrade-ideas.png b/fr-FR/images/upgrade-ideas.png new file mode 100644 index 000000000..dfb8e7c1a Binary files /dev/null and b/fr-FR/images/upgrade-ideas.png differ diff --git a/fr-FR/images/yellow-points.png b/fr-FR/images/yellow-points.png new file mode 100644 index 000000000..effe8910f Binary files /dev/null and b/fr-FR/images/yellow-points.png differ diff --git a/fr-FR/meta.yml b/fr-FR/meta.yml new file mode 100644 index 000000000..15f9e0b51 --- /dev/null +++ b/fr-FR/meta.yml @@ -0,0 +1,41 @@ +--- +title: Tir sur cible +hero_image: images/banner.png +description: Utilise Python pour dessiner une cible et marquer des points en l'atteignant avec des flèches +meta_title: Projets de codage Python pour enfants et adolescents | Tir sur cible +meta_description: Apprends le langage Python avec les projets de codage de la Raspberry Pi Foundation pour les enfants et les adolescents. Utilise Python pour dessiner une cible et marquer des points en l'atteignant avec des flèches. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Ce que tu vas faire + - + title: Dessiner l'herbe + - + title: Dessiner ta cible + completion: + - engaged + - + title: Ajouter une flèche + - + title: Quelle est la couleur atteinte ? + - + title: Marquer des points + completion: + - internal + - + title: Questionnaire rapide + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Défi + challenge: true + - + title: Que peux-tu faire maintenant ? diff --git a/fr-FR/python-comments-demo.txt b/fr-FR/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/fr-FR/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/fr-FR/python-comments.txt b/fr-FR/python-comments.txt new file mode 100644 index 000000000..27b6c04e7 --- /dev/null +++ b/fr-FR/python-comments.txt @@ -0,0 +1,27 @@ +Choses à faire dans chaque image + +Dessiner le cercle intérieur + +Dessiner le cercle du milieu + +La fonction tire_fleche vient ici + +La fonction souris_pressee vient ici + +Tu as touché le cercle extérieur, 50 points ! + +Tu as touché le cercle intérieur, 200 points ! + +Tu as touché le milieu, 500 points ! + +Tu as touché le milieu, 500 points ! + +Tu as loupé la cible ! Aucun point ! + +Super rapide + +Assez rapide + +Très rapide + +Vitesse non reconnue ! \ No newline at end of file diff --git a/fr-FR/python-translatable-demo.txt b/fr-FR/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/fr-FR/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/fr-FR/python-translatable.txt b/fr-FR/python-translatable.txt new file mode 100644 index 000000000..96e3f3a80 --- /dev/null +++ b/fr-FR/python-translatable.txt @@ -0,0 +1,9 @@ +tire_fleche + +fleche_x + +fleche_y + +couleur_touchee + +vitesse \ No newline at end of file diff --git a/fr-FR/quiz1/question_1.md b/fr-FR/quiz1/question_1.md new file mode 100644 index 000000000..fe6be2bae --- /dev/null +++ b/fr-FR/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Questionnaire rapide + +Réponds aux trois questions. Il y a des indices pour te guider vers la bonne réponse. + +Lorsque tu as répondu à chaque question, clique sur **Vérifier ma réponse**. + +Amuse-toi bien ! + +--- question --- +--- +legend: Question 1 sur 3 +--- +Dans ton projet, tu as ajouté `randint(100, 300)` à ta fonction `tire_fleche()`. Que fait `randint(100, 300)` ? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) Il choisit un nombre entier aléatoire entre 100 et 300. + + --- feedback --- + +C'est correct ! Cela permet de choisir une coordonnée x aléatoire pour ta flèche. + + --- /feedback --- + +- ( ) Cela fait bouger la flèche de manière aléatoire sur l'écran. + + --- feedback --- + +Pas tout à fait. Ce code explique en partie comment la flèche se déplace de manière aléatoire, mais tu as besoin d'autres codes pour atteindre cet objectif. + + --- /feedback --- + +- () Il s'agit de la couleur qui a été touchée par la flèche. + + --- feedback --- + + Pas tout à fait. La fonction get() est utilisée pour obtenir la couleur. + + --- /feedback --- + +- ( ) Il dessine un cercle de taille aléatoire. + + --- feedback --- + + Pas tout à fait. La fonction circle() serait utilisée pour dessiner un cercle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/fr-FR/quiz1/question_2.md b/fr-FR/quiz1/question_2.md new file mode 100644 index 000000000..0d1071fc3 --- /dev/null +++ b/fr-FR/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 sur 3 +--- + +Dans ton projet, tu as utilisé les conditions `if`, `elif` et `else` pour vérifier sur quelle couleur la flèche a atterri. + +Dans l'exemple ci-dessous, une variable appelée `vitesse` contient le nombre `6` stocké. Lorsque cette instruction `if` est exécutée, que serait imprimé dans la zone de sortie ? + +--- code --- +--- +language: python +--- +vitesse = 6 + +if vitesse == 7: print('Super rapide') elif vitesse == 5: print('Assez rapide') elif vitesse == 6: print('Très rapide') else: print('Vitesse non reconnue !') + +--- /code --- + +--- choices --- + +- (x) `Très rapide` + + --- feedback --- + + C'est correct ! La variable **vitesse** a reçu la valeur `6`, ce qui rend la condition `vitesse == 6` **True** et imprime `Très rapide`. + + --- /feedback --- + +- ( ) `Vitesse non reconnue !` + + --- feedback --- + + Pas tout à fait, regarde la valeur attribuée à la variable **vitesse**. + + --- /feedback --- + +- ( ) Rien ne s'imprime + + --- feedback --- + + Réessaie, `else` est utilisé comme option finale lorsque toutes les conditions ci-dessus sont fausses. Regarde à nouveau les conditions, est-ce que l'une d'entre elles est vraie ? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/fr-FR/quiz1/question_3.md b/fr-FR/quiz1/question_3.md new file mode 100644 index 000000000..06fa02145 --- /dev/null +++ b/fr-FR/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 sur 3 +--- + +Un cercle est dessiné en utilisant le code suivant : + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Laquelle des images ci-dessous montre la position correcte de ce cercle dans la zone de sortie ? + +--- choices --- + +- ( ) ![Un cercle vert centré dans le coin inférieur droit de la zone de sortie.](images/bottom-right.png) + + --- feedback --- + + Pas tout à fait, pour centrer le cercle dans le coin inférieur droit, les coordonnées doivent être identiques à la taille de l'écran. Dans cet exemple, le cercle serait `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Un cercle vert centré au milieu de la zone de sortie.](images/centre.png) + + --- feedback --- + + Pas tout à fait, pour centrer le cercle au centre, les coordonnées devraient être la moitié de la taille de l'écran. Dans cet exemple, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Un cercle vert centré dans le coin supérieur gauche de la zone de sortie.](images/top-left.png) + + --- feedback --- + + C'est correct ! Ce cercle est centré aux coordonnées (0,0), le coin supérieur gauche de l'écran. + + --- /feedback --- + +- ( ) ![Un cercle vert centré vers le côté supérieur droit de la zone de sortie.](images/random-side.png) + + --- feedback --- + + Non, cette ellipse aurait le code `circle(350, 150, 300)` pour le centrer vers le haut à droite de l'écran. La coordonnée `x` est la distance horizontale entre l'ellipse et le bord de l'écran, et la coordonnée `y` est la distance verticale sur l'écran. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/fr-FR/resources/main.py b/fr-FR/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/fr-FR/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/fr-FR/resources/p5.py b/fr-FR/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/fr-FR/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/fr-FR/step_1.md b/fr-FR/step_1.md new file mode 100644 index 000000000..35d34513e --- /dev/null +++ b/fr-FR/step_1.md @@ -0,0 +1,29 @@ +## Ce que tu vas faire + +Utilise Python pour dessiner une cible et marque des points en l'atteignant avec des flèches. + +--- print-only --- + +![Une cible de tir à l'arc avec un point de vie sur le cercle extérieur. Le texte "Tu as atteint le cercle extérieur, 50 points !" est affiché en dessous](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Clique sur le bouton **Run** ci-dessous pour démarrer le jeu. Lorsque le point apparaît sur la cible, clique sur la souris (ou appuie sur ta tablette) pour tirer ta flèche. + + +
+
+ +--- /no-print --- + +
+ Réponds à notre enquête pour nous aider à améliorer notre Code Editor ! +
+ + + diff --git a/fr-FR/step_2.md b/fr-FR/step_2.md new file mode 100644 index 000000000..426743fbb --- /dev/null +++ b/fr-FR/step_2.md @@ -0,0 +1,37 @@ +## Dessiner l'herbe + +--- task --- + +Ouvre le [projet de démarrage Tir sur cible](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Ajoute** du code pour dessiner un rectangle vert au bas de l'écran pour représenter l'herbe. + +![La zone de sortie avec un rectangle de couleur ciel au-dessus d'un rectangle de couleur herbe pour créer l'arrière-plan. Le coin supérieur gauche du rectangle est marqué x=0, y=250 ; c'est l'origine du rectangle. La largeur est surlignée à 400 et la hauteur à 150. Le code rect(0, 0, 400, 250) s'affiche.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** exécute ton projet pour voir l'arrière-plan. + +![La zone de sortie avec un rectangle de couleur ciel au-dessus d'un rectangle de couleur herbe pour créer l'arrière-plan.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/fr-FR/step_3.md b/fr-FR/step_3.md new file mode 100644 index 000000000..b08e9ddb0 --- /dev/null +++ b/fr-FR/step_3.md @@ -0,0 +1,115 @@ +## Dessiner ta cible + +
+
+Ton jeu a besoin d'une cible pour tirer des flèches. +
+
+ +![La zone de sortie avec la cible et le support.](images/three-circles.png){:width="300px"} + +
+
+ +### Dessiner un support triangulaire + +--- task --- + +Définis la couleur de remplissage sur `brun`. + +Dessine un triangle en utilisant les coordonnées x et y de chacun des angles. + +![Un triangle marron sur de l'herbe et sur un ciel dont les points de coordonnées sont marqués 150, 350 et 200, 150 et 250, 350). Les coins du canevas sont également marqués x=0, y=0 en haut à gauche et x=400, y=400 en bas à droite.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** exécute ton code pour voir la position de ta cible : + +![Un triangle marron sur l'herbe et sur fond de ciel.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Dessiner les cibles + +--- task --- + +La plus grande partie de la cible est un **cercle** bleu. + +Définis la couleur de remplissage sur `blue`. + +Dessine un cercle avec des coordonnées x et y pour son centre et une largeur. + +![Un triangle marron et un cercle bleu sur l'herbe et sur fond de ciel. Le cercle est nommé avec les coordonnées x=200, y=200 comme centre et une largeur de cercle de 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** exécute ton code pour voir le premier grand cercle bleu. + +Le cercle bleu a été dessiné après le support donc il est devant. + +![Un triangle marron et un cercle bleu sur l'herbe et sur fond de ciel.](images/blue-circle.png){:width="400px"} + +--- /task --- + +La cible est constituée de cercles de tailles différentes ayant les mêmes coordonnées centrales (200, 200). + +--- task --- + +**Ajoute** des cercles de couleur pour les parties intérieure et centrale de la cible. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** exécute ton projet pour voir la cible avec trois cercles colorés. + +![Un triangle marron avec trois cercles colorés sur de l'herbe et sur fond de ciel.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/fr-FR/step_4.md b/fr-FR/step_4.md new file mode 100644 index 000000000..c6cc66d92 --- /dev/null +++ b/fr-FR/step_4.md @@ -0,0 +1,88 @@ +## Ajouter une flèche + +
+
+Ajoute un cercle encore plus petit pour représenter une flèche. +
+
+ +![La cible, avec une flèche circulaire marron apparaissant dans diverses positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Où vas-tu tirer ? + +--- task --- + +Ajoute une fonction pour dessiner un cercle brun aux coordonnées `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# La fonction tire_fleche vient ici +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Appelle ta nouvelle fonction `tire_fleche()`{:.language-python} à la fin de ta fonction `draw()`{:.language-python}. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** clique sur le bouton **Run**. Tu devrais voir la flèche au centre. + +![un cercle de flèche brun au centre de la cible](images/arrow-centre.png) + + +--- /task --- + +La flèche doit se déplacer de manière aléatoire. + + +--- task --- + +Modifie les variables `fleche_x`{:.language-python} et `fleche_y`{:.language-python} pour choisir un nombre aléatoire entre 100 et 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test :** clique sur le bouton **Run**. Tu devrais voir la flèche sauter autour de la cible. + +![Une animation de cible avec une flèche circulaire marron apparaissant dans diverses positions.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/fr-FR/step_5.md b/fr-FR/step_5.md new file mode 100644 index 000000000..da77cc99c --- /dev/null +++ b/fr-FR/step_5.md @@ -0,0 +1,80 @@ +## Quelle est la couleur atteinte ? + +Ensuite, tu ajouteras du code pour obtenir la couleur à l’emplacement de la flèche. + +### Obtenir la couleur touchée par la flèche + +--- task --- + +Ajoute une nouvelle **variable globale** appelée `couleur_touchee`. + +Ajoute du code pour `obtenir` la couleur au centre de la flèche et la stocker dans la variable `couleur_touchee`. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Astuce :** le code pour `obtenir` la couleur doit être **avant** le code pour dessiner le `cercle` sinon tu garderas toujours la couleur brune de la flèche ! + +--- /task --- + +--- task --- + +**Test :** clique sur le bouton **Run** . Tu devrais voir les couleurs imprimées dans **Text output**, au format hexadécimal. + +--- /task --- + +### Exécuter le code lorsque la souris est pressée + +--- task --- + +Commente la ligne qui imprime la couleur. Cela signifie qu'elle ne s'exécuteras pas. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Ajoute du code pour imprimer l'emoji cible 🎯 **quand la souris est cliquée**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# La fonction souris_pressee vient ici +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** clique sur le bouton **Run**. Tu dois voir le caractère 🎯 s'imprimer lorsque tu cliques sur la cible avec la souris. + +![emoji cible imprimé lorsque l'on clique sur la souris](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/fr-FR/step_6.md b/fr-FR/step_6.md new file mode 100644 index 000000000..4953efe16 --- /dev/null +++ b/fr-FR/step_6.md @@ -0,0 +1,112 @@ +## Marquer des points + +
+
+Ajoute un score en fonction de l'endroit où la flèche frappe. +
+
+ +![Une animation de la cible, avec la flèche apparaissant dans diverses positions et les scores apparaissant sous forme de texte sous le jeu.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Commente la ligne pour imprimer le caractère 🎯 afin qu'il ne s'exécute plus. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Affiche un message **if** la `touche_couleur`{:.language-python} est égale à la couleur du cercle `extérieur` (bleu). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Astuce :** si tu as modifié la couleur de ton cercle extérieur, tu dois remplacer `blue` par le nom de la couleur que tu as choisie. + +--- /task --- + +--- task --- + +**Test :** clique sur le bouton **Run** . Attends que la flèche atterrisse sur le cercle bleu, puis clique sur le bouton gauche de la souris. ![points marqués lorsque le cercle bleu est cliqué](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} peut être utilisé pour ajouter plus de conditions à ton instruction `if`{:.language-python}. + +--- task --- + +Ajoute un peu de code pour marquer des points si la flèche tombe sur les cercles **intérieure** ou **milieu**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** clique sur le bouton **Run**. Tu devrais marquer des points chaque fois que tu atteins la cible. + +![points marqués sur n'importe quelle zone de la cible](images/yellow-points.png) + +--- /task --- + +### Manquer la cible + +Il te reste une décision à prendre : que se passe-t-il si la flèche n'atterrit sur aucun des cercles de la cible ? + +Pour faire cette dernière vérification, tu utiliseras `else`{:.language-python}. + +--- task --- + +Ajoute du code pour `imprimer` un message lorsque aucune des déclarations `if` et `elif` n'est vraie. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test :** clique sur le bouton **Run** . Tire la flèche dans l'herbe ou dans le ciel pour voir le message qui te dit que tu as loupé la cible. + +![aucun point imprimé en dehors de la cible](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/fr-FR/step_7.md b/fr-FR/step_7.md new file mode 100644 index 000000000..80a2ca5cd --- /dev/null +++ b/fr-FR/step_7.md @@ -0,0 +1 @@ +## Questionnaire rapide \ No newline at end of file diff --git a/fr-FR/step_8.md b/fr-FR/step_8.md new file mode 100644 index 000000000..541f8c878 --- /dev/null +++ b/fr-FR/step_8.md @@ -0,0 +1,36 @@ +## Défi + +--- challenge --- + + +Tu pourrais : + + +--- task --- + +Ajouter un `quatrième` et un `cinquième` cercle, dans de nouvelles couleurs, qui rapportent différents points en fonction de leur position + +--- /task --- + +--- task --- + +Mettre des emojis dans tes messages imprimés ([voici une liste d'emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} que tu peux copier) + +--- /task --- + +--- task --- + +Rendre le jeu plus facile ou plus difficile en modifiant la valeur `frame_rate=2` + + +--- /task --- + +--- task --- + +Ajouter une variable pour suivre le score total, en y ajoutant le nombre correct de points à chaque fois. + +--- /task --- + + + +--- /challenge --- diff --git a/fr-FR/step_9.md b/fr-FR/step_9.md new file mode 100644 index 000000000..ef7077575 --- /dev/null +++ b/fr-FR/step_9.md @@ -0,0 +1,21 @@ +## Que peux-tu faire maintenant ? + +Si tu suis le parcours [Introduction à Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro), tu peux passer au projet [Lancement de fusée](https://projects.raspberrypi.org/en/projects/rocket-launch). Dans ce projet, tu réaliseras une animation interactive d'une fusée lançant un satellite en orbite. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Clique sur le bouton **Run** pour afficher un exemple de ce projet. + + + +\--- /no-print --- + +Ou pourquoi ne pas essayer un autre projet [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + diff --git a/hi-IN/code/target-practice-solution/main.py b/hi-IN/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/hi-IN/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/hi-IN/code/target-practice-solution/project_config.yml b/hi-IN/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/hi-IN/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/hi-IN/code/target-practice-starter/main.py b/hi-IN/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/hi-IN/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/hi-IN/code/target-practice-starter/project_config.yml b/hi-IN/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/hi-IN/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/hi-IN/images/alternative-colours.png b/hi-IN/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/hi-IN/images/alternative-colours.png differ diff --git a/hi-IN/images/animation_bg_erase.gif b/hi-IN/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/hi-IN/images/animation_bg_erase.gif differ diff --git a/hi-IN/images/animation_no_bg_erase.gif b/hi-IN/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/hi-IN/images/animation_no_bg_erase.gif differ diff --git a/hi-IN/images/arrow-centre.png b/hi-IN/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/hi-IN/images/arrow-centre.png differ diff --git a/hi-IN/images/arrow-middle.png b/hi-IN/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/hi-IN/images/arrow-middle.png differ diff --git a/hi-IN/images/arrow-target.png b/hi-IN/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/hi-IN/images/arrow-target.png differ diff --git a/hi-IN/images/background.png b/hi-IN/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/hi-IN/images/background.png differ diff --git a/hi-IN/images/banner.png b/hi-IN/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/hi-IN/images/banner.png differ diff --git a/hi-IN/images/blue-circle.png b/hi-IN/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/hi-IN/images/blue-circle.png differ diff --git a/hi-IN/images/blue-points.png b/hi-IN/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/hi-IN/images/blue-points.png differ diff --git a/hi-IN/images/blue_circle_points.gif b/hi-IN/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/hi-IN/images/blue_circle_points.gif differ diff --git a/hi-IN/images/bottom-right.png b/hi-IN/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/hi-IN/images/bottom-right.png differ diff --git a/hi-IN/images/centre.png b/hi-IN/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/hi-IN/images/centre.png differ diff --git a/hi-IN/images/circle-coords.png b/hi-IN/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/hi-IN/images/circle-coords.png differ diff --git a/hi-IN/images/coords_animation.gif b/hi-IN/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/hi-IN/images/coords_animation.gif differ diff --git a/hi-IN/images/difficulty-setting.png b/hi-IN/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/hi-IN/images/difficulty-setting.png differ diff --git a/hi-IN/images/fire_arrow.gif b/hi-IN/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/hi-IN/images/fire_arrow.gif differ diff --git a/hi-IN/images/five_circles.png b/hi-IN/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/hi-IN/images/five_circles.png differ diff --git a/hi-IN/images/green-grass.png b/hi-IN/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/hi-IN/images/green-grass.png differ diff --git a/hi-IN/images/grey-circle.png b/hi-IN/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/hi-IN/images/grey-circle.png differ diff --git a/hi-IN/images/grey-points.png b/hi-IN/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/hi-IN/images/grey-points.png differ diff --git a/hi-IN/images/initial_target.png b/hi-IN/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/hi-IN/images/initial_target.png differ diff --git a/hi-IN/images/missed-points.png b/hi-IN/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/hi-IN/images/missed-points.png differ diff --git a/hi-IN/images/missed_no_points.gif b/hi-IN/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/hi-IN/images/missed_no_points.gif differ diff --git a/hi-IN/images/outline-circles.png b/hi-IN/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/hi-IN/images/outline-circles.png differ diff --git a/hi-IN/images/points-scored.gif b/hi-IN/images/points-scored.gif new file mode 100644 index 000000000..3fbe161a8 Binary files /dev/null and b/hi-IN/images/points-scored.gif differ diff --git a/hi-IN/images/quiz-colour.png b/hi-IN/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/hi-IN/images/quiz-colour.png differ diff --git a/hi-IN/images/random-side.png b/hi-IN/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/hi-IN/images/random-side.png differ diff --git a/hi-IN/images/rectangle-diagram.png b/hi-IN/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/hi-IN/images/rectangle-diagram.png differ diff --git a/hi-IN/images/showcase_rocket.png b/hi-IN/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/hi-IN/images/showcase_rocket.png differ diff --git a/hi-IN/images/showcase_static.png b/hi-IN/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/hi-IN/images/showcase_static.png differ diff --git a/hi-IN/images/sky_coords.png b/hi-IN/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/hi-IN/images/sky_coords.png differ diff --git a/hi-IN/images/sky_stroke.png b/hi-IN/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/hi-IN/images/sky_stroke.png differ diff --git a/hi-IN/images/stand_coords.png b/hi-IN/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/hi-IN/images/stand_coords.png differ diff --git a/hi-IN/images/step_4_preview.gif b/hi-IN/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/hi-IN/images/step_4_preview.gif differ diff --git a/hi-IN/images/step_5_preview.gif b/hi-IN/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/hi-IN/images/step_5_preview.gif differ diff --git a/hi-IN/images/target-stand.png b/hi-IN/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/hi-IN/images/target-stand.png differ diff --git a/hi-IN/images/target_area.png b/hi-IN/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/hi-IN/images/target_area.png differ diff --git a/hi-IN/images/target_printed.gif b/hi-IN/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/hi-IN/images/target_printed.gif differ diff --git a/hi-IN/images/three-circles.png b/hi-IN/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/hi-IN/images/three-circles.png differ diff --git a/hi-IN/images/top-left.png b/hi-IN/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/hi-IN/images/top-left.png differ diff --git a/hi-IN/images/triangles-coords.png b/hi-IN/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/hi-IN/images/triangles-coords.png differ diff --git a/hi-IN/images/upgrade-ideas.png b/hi-IN/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/hi-IN/images/upgrade-ideas.png differ diff --git a/hi-IN/images/yellow-points.png b/hi-IN/images/yellow-points.png new file mode 100644 index 000000000..0c461812c Binary files /dev/null and b/hi-IN/images/yellow-points.png differ diff --git a/hi-IN/meta.yml b/hi-IN/meta.yml new file mode 100644 index 000000000..a647de58f --- /dev/null +++ b/hi-IN/meta.yml @@ -0,0 +1,41 @@ +--- +title: लक्ष्य अभ्यास +hero_image: images/banner.png +description: एक लक्ष्य बनाने के लिए पाइथन का उपयोग करें और इसे तीर से मारते हुए अंक स्कोर करें +meta_title: Python बच्चों और किशोरों के लिए प्रोजेक्ट कोडिंग | लक्ष्य अभ्यास +meta_description: बच्चों और किशोरों के लिए Raspberry Pi फाउंडेशन की कोडिंग प्रोजेक्ट्स के साथ Python जानें। एक लक्ष्य बनाने के लिए Python का उपयोग करें और इसे तीर से मारते हुए अंक स्कोर करें। +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: What you will make + - + title: Draw the grass + - + title: अपना लक्ष्य बनाएँ + completion: + - engaged + - + title: Add an arrow + - + title: What colour did you hit? + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Challenge + challenge: true + - + title: What can you do now? diff --git a/hi-IN/python-comments-demo.txt b/hi-IN/python-comments-demo.txt new file mode 100644 index 000000000..830f0433e --- /dev/null +++ b/hi-IN/python-comments-demo.txt @@ -0,0 +1,73 @@ +अपना गेम यहां सेट करें + +स्क्रीन की चौड़ाई और ऊंचाई + +हर फ्रेम में करने के लिए चीजें + +red = 92, green = 204, blue = 206 + +भरण रंग को घास पर सेट करें + +X, y, width, height + +स्टैंड भरण रंग को लकड़ी पर सेट करें + +सर्कल भरण रंग को बाहरी पर सेट करें + +X, y, चौड़ाई ऑफ़ द सर्कल + +नीला + +लाल + +पीला + +सर्कल भरण रंग को अंदर की ओर सेट करें + +भीतरी वृत्त - x, y, वृत्त की चौड़ाई + +सर्कल भरण रंग को बीच में सेट करें + +मध्य वृत्त - x, y, वृत्त की चौड़ाई + +move_arrow फ़ंक्शन यहाँ जाता है + +100 और 300 के बीच एक यादृच्छिक संख्या स्टोर करें + +लकड़ी में रंग भरने के लिए तीर सेट करें + +यादृच्छिक निर्देशांक पर एक छोटा वृत्त बनाएं + +हिट रंग प्राप्त करें + +mouse_powed फ़ंक्शन यहाँ जाता है + +अन्य फंक्शन में उपयोग किया जा सकता है + +तीर बनाने से पहले रंग सेव करें + +जैसे फ़ंक्शंस, 'if' कथन इंडेंट किए गए हैं + +लाइब्रेरी कोड आयात करें + +अपना कोड चलाने के लिए इसे रखें + +p5psi संसाधन लाइब्रेरी के साथ संगतता के लिए परिभाषाएँ + +आकृति + +फ़ॉन्ट + +टेक्स्ट + +कलर + +images + +environment + +रूपांतरित करें + +कीबोर्ड + +भरण रंग को घास पर सेट करें diff --git a/hi-IN/python-comments.txt b/hi-IN/python-comments.txt new file mode 100644 index 000000000..1aeb88a5d --- /dev/null +++ b/hi-IN/python-comments.txt @@ -0,0 +1,27 @@ +हर फ्रेम में करने के लिए चीजें + +Draw the inner circle + +Draw the middle circle + +shoot_arrow फ़ंक्शन यहाँ जाता है + +mouse_pressed फ़ंक्शन यहाँ जाता है + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/hi-IN/python-translatable-demo.txt b/hi-IN/python-translatable-demo.txt new file mode 100644 index 000000000..7329d46b2 --- /dev/null +++ b/hi-IN/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +आकाश + +घास + +आउटर + +अंदर + +मध्य + +boot_arrow + +row_x + +row_y + +rop_color + +आप बाहरी सर्कल को हिट करते हैं, 50 पॉइंट! + +आपने आंतरिक वृत्त को मारा, 200 अंक! + +आपने बीच में मारा, 500 अंक! + +आप चूक गए! कोई अंक नहीं! + +बहुत तेज + +बहुत जल्दी है + +बहुत तेज + +गति नहीं पहचानी गई! + +गति diff --git a/hi-IN/python-translatable.txt b/hi-IN/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/hi-IN/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/hi-IN/quiz1/question_1.md b/hi-IN/quiz1/question_1.md new file mode 100644 index 000000000..943b9481b --- /dev/null +++ b/hi-IN/quiz1/question_1.md @@ -0,0 +1,60 @@ +## शीघ्र क्विज़ + +तीनों सवालों के जवाब दें। सही उत्तर के लिए आपका मार्गदर्शन करने के लिए संकेत हैं। + +जब आप प्रत्येक प्रश्न का उत्तर दे चुके हैं, तो ** > मेरे जंडैक ** पर क्लिक करें। + +आनंद लें! + +--- question --- +--- +legend: प्रश्न 1 का 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/hi-IN/quiz1/question_2.md b/hi-IN/quiz1/question_2.md new file mode 100644 index 000000000..c2f624bb0 --- /dev/null +++ b/hi-IN/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: तीन में से दूसरा प्रश्न +--- + +अपने प्रोजेक्ट में, आपने `if`, `elif`, और `else` शर्तों का उपयोग किया है ताकि यह पता लगाया जा सके कि तीर किस रंग में उतरा। + +नीचे दिए गए उदाहरण में, एक वेरिएबल जिसे ` > ` कहा जाता है उसमें संख्या ` > ` संग्रहीत है। जब यह ` > ` स्टेटमेंट चलाया जाता है, तो आउटपुट क्षेत्र में क्या प्रिंट किया जाएगा? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + यह सही है! **speed** वेरिएबल को `6` का मान सौंपा गया है, जो `speed == 6` स्थिति को **True** बनाता है और `Very fast` प्रिंट करता है। + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + बिल्कुल नहीं, **speed** वेरिएबल को असाइन किए गए मान को देखें। + + --- /feedback --- + +- () कुछ भी नहीं छपा + + --- feedback --- + + फिर से प्रयास करें, जब उपरोक्त सभी स्थितियाँ झूठी होती हैं, तो के लिए अंतिम विकल्प के रूप में ` account ` का उपयोग किया जाता है। शर्तों को फिर से देखें, क्या कोई भी स्थिति सच है? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/hi-IN/quiz1/question_3.md b/hi-IN/quiz1/question_3.md new file mode 100644 index 000000000..eb9786205 --- /dev/null +++ b/hi-IN/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: 3 प्रश्नों में तीसरा +--- + +निम्नलिखित कोड का उपयोग करके एक वृत्त बनाया जाता है: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_strop() + +def draway(): +circle(0, 0, 300) + +run() + +--- /code --- + +निम्न में से कौन सी छवियां आउटपुट क्षेत्र में इस वृत्त की सही स्थिति दिखाती हैं? + +--- choices --- + +- ( ) ![आउटपुट क्षेत्र के निचले-दाएँ कोने में केंद्रित एक हरा वृत्त।](images/bottom-right.png) + + --- feedback --- + + नहीं, निचले-दाएँ कोने में वृत्त को केंद्र में लाने के लिए, निर्देशांक स्क्रीन के आकार के समान होने चाहिए। इस उदाहरण में, दीर्घवृत्त ` >(400, 400, 300)` होगा। + + --- /feedback --- + +- ( ) ![आउटपुट क्षेत्र के मध्य में केंद्रित एक हरा वृत्त।](images/centre.png) + + --- feedback --- + + बिल्कुल नहीं, मध्य में वृत्त को केंद्रित करने के लिए, निर्देशांक स्क्रीन के आकार का आधा होना चाहिए। इस उदाहरण में, ` >(200, 200, 300)`। + + --- /feedback --- + +- (x) ![आउटपुट क्षेत्र के ऊपरी-बाएँ कोने में केंद्रित एक हरा वृत्त।](images/top-left.png) + + --- feedback --- + + यह सही है! यह वृत्त निर्देशांक (0,0) पर केंद्रित है, जो स्क्रीन का ऊपरी-बायाँ कोना है। + + --- /feedback --- + +- ( ) ![आउटपुट क्षेत्र के ऊपरी-दाईं ओर केंद्रित एक हरा वृत्त।](images/random-side.png) + + --- feedback --- + + नहीं, इस सर्कल में स्क्रीन के शीर्ष-दाईं ओर इसे केंद्रित करने के लिए ` >> (350, 150, 300) का कोड होगा। x` निर्देशांक यह है कि कितनी दूर स्क्रीन पर दीर्घवृत्त है, और `y` निर्देशांक है कि स्क्रीन कितनी नीचे है। + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/hi-IN/resources/main.py b/hi-IN/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/hi-IN/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/hi-IN/resources/p5.py b/hi-IN/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/hi-IN/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/hi-IN/step_1.md b/hi-IN/step_1.md new file mode 100644 index 000000000..7606cb493 --- /dev/null +++ b/hi-IN/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Use Python to draw a target and score points by hitting it with arrows. + +--- print-only --- + +![बाहरी सर्कल पर एक हिट पॉइंट के साथ एक तीरंदाजी लक्ष्य। 'आप बाहरी वृत्त से टकराए, 50 अंक!' पाठ नीचे प्रदर्शित होता है](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ अपने कोड एडिटर को बेहतर बनाने में मदद के लिए हमारे सर्वेक्षक बनाएँ! +
+ + + diff --git a/hi-IN/step_2.md b/hi-IN/step_2.md new file mode 100644 index 000000000..b55168c94 --- /dev/null +++ b/hi-IN/step_2.md @@ -0,0 +1,37 @@ +## घास बनाएं + +--- task --- + +[ PLASS Statch starding ](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"} प्रोजेक्ट खोलें। + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![पृष्ठभूमि बनाने के लिए एक घास के रंग के आयत के ऊपर आकाश-रंगीन आयत वाला आउटपुट क्षेत्र। आयत का ऊपरी बायाँ कोना x=0, y=250 के रूप में चिह्नित है यह आयत का मूल है। चौड़ाई 400 और ऊंचाई 150 के रूप में हाइलाइट की गई है। कोड रेक्ट(0, 250, 400, 150) दिखाया गया है।](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to view the background. + +![पृष्ठभूमि बनाने के लिए एक घास के रंग के आयत के ऊपर आकाश-रंगीन आयत वाला आउटपुट क्षेत्र।](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/hi-IN/step_3.md b/hi-IN/step_3.md new file mode 100644 index 000000000..48c1824f0 --- /dev/null +++ b/hi-IN/step_3.md @@ -0,0 +1,115 @@ +## अपना लक्ष्य बनाएँ + +
+
+आपके गेम को पर तीर चलाने के लिए एक लक्ष्य की आवश्यकता है। +
+
+ +![लक्ष्य और स्टैंड वाला आउटपुट क्षेत्र।](images/three-circle.png){:width="300px"} + +
+
+ +### एक त्रिकोणीय स्टैंड बनाएं + +--- task --- + +Set the fill colour to `brown`. + +प्रत्येक कोनों के लिए x और y निर्देशांक का उपयोग करके एक त्रिकोण बनाएं। + +![घास पर एक भूरा त्रिकोण और एक आकाश के खिलाफ 150, 350 और 200, 150 और 250, 350 पर लेबल निर्देशांक बिंदुओं के साथ)। कैनवास के कोने भी ऊपर बाएँ x=0, y=0 और नीचे दाईं ओर x=400, y=400 के रूप में लेबल किए गए हैं।](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![घास पर एक भूरा त्रिकोण और एक आकाश के खिलाफ।](images/target-stand.png){:width="400px"} + +--- /task --- + +### लक्ष्य वृत्त बनाएं + +--- task --- + +लक्ष्य का सबसे बड़ा भाग एक नीला ** अपलोड ** है। + +भरण रंग को ` > ` पर सेट करें। + +इसके केंद्र और चौड़ाई के लिए x और y निर्देशांक के साथ एक वृत्त बनाएं। + +![एक भूरा त्रिकोण और घास पर नीला घेरा और एक आकाश के खिलाफ। वृत्त को निर्देशांक x=200, y=200 के साथ केंद्र के रूप में और 170 की वृत्त चौड़ाई के साथ लेबल किया गया है।](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +** >:** पहला बड़ा नीला वृत्त देखने के लिए अपना कोड चलाता है। + +नीले घेरे को स्टैंड के बाद खींचा गया था इसलिए यह सामने है। + +![एक भूरा त्रिकोण और घास पर नीला घेरा और एक आकाश के खिलाफ।](images/blue-circle.png){:width="400px"} + +--- /task --- + +लक्ष्य एक ही केंद्र निर्देशांक (200, 200) के साथ अलग-अलग आकार के वृत्तों से बना होता है। + +--- task --- + +लक्ष्य के भीतरी और मध्य भागों के लिए ** > ** रंगीन घेरे। + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![एक भूरा त्रिकोण जिसमें तीन रंगीन घेरे घास पर और एक आकाश के खिलाफ हैं।](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/hi-IN/step_4.md b/hi-IN/step_4.md new file mode 100644 index 000000000..8ead9abaa --- /dev/null +++ b/hi-IN/step_4.md @@ -0,0 +1,88 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![लक्ष्य, एक भूरे वृत्त तीर के साथ विभिन्न स्थानों में दिखाई देता है।](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# shoot_arrow फ़ंक्शन यहाँ जाता है +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![भूरे वृत्त तीर के साथ लक्ष्य का एक एनीमेशन विभिन्न स्थानों में दिखाई दे रहा है।](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/hi-IN/step_5.md b/hi-IN/step_5.md new file mode 100644 index 000000000..8d30135a2 --- /dev/null +++ b/hi-IN/step_5.md @@ -0,0 +1,80 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# mouse_powed फ़ंक्शन यहाँ जाता है +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/hi-IN/step_6.md b/hi-IN/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/hi-IN/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/hi-IN/step_7.md b/hi-IN/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/hi-IN/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/hi-IN/step_8.md b/hi-IN/step_8.md new file mode 100644 index 000000000..910635d28 --- /dev/null +++ b/hi-IN/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/hi-IN/step_9.md b/hi-IN/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/hi-IN/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/hr-HR/images/alternative-colours.png b/hr-HR/images/alternative-colours.png new file mode 100644 index 000000000..a688ac942 Binary files /dev/null and b/hr-HR/images/alternative-colours.png differ diff --git a/hr-HR/images/animation_bg_erase.gif b/hr-HR/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/hr-HR/images/animation_bg_erase.gif differ diff --git a/hr-HR/images/animation_no_bg_erase.gif b/hr-HR/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/hr-HR/images/animation_no_bg_erase.gif differ diff --git a/hr-HR/images/arrow-middle.png b/hr-HR/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/hr-HR/images/arrow-middle.png differ diff --git a/hr-HR/images/arrow-target.png b/hr-HR/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/hr-HR/images/arrow-target.png differ diff --git a/hr-HR/images/background.png b/hr-HR/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/hr-HR/images/background.png differ diff --git a/hr-HR/images/banner.png b/hr-HR/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/hr-HR/images/banner.png differ diff --git a/hr-HR/images/blue-circle.png b/hr-HR/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/hr-HR/images/blue-circle.png differ diff --git a/hr-HR/images/blue-points.png b/hr-HR/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/hr-HR/images/blue-points.png differ diff --git a/hr-HR/images/bottom-right.png b/hr-HR/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/hr-HR/images/bottom-right.png differ diff --git a/hr-HR/images/centre.png b/hr-HR/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/hr-HR/images/centre.png differ diff --git a/hr-HR/images/circle-coords.png b/hr-HR/images/circle-coords.png new file mode 100644 index 000000000..6c0d2c78b Binary files /dev/null and b/hr-HR/images/circle-coords.png differ diff --git a/hr-HR/images/coords_animation.gif b/hr-HR/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/hr-HR/images/coords_animation.gif differ diff --git a/hr-HR/images/difficulty-setting.png b/hr-HR/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/hr-HR/images/difficulty-setting.png differ diff --git a/hr-HR/images/fire_arrow.gif b/hr-HR/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/hr-HR/images/fire_arrow.gif differ diff --git a/hr-HR/images/five_circles.png b/hr-HR/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/hr-HR/images/five_circles.png differ diff --git a/hr-HR/images/green-grass.png b/hr-HR/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/hr-HR/images/green-grass.png differ diff --git a/hr-HR/images/grey-circle.png b/hr-HR/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/hr-HR/images/grey-circle.png differ diff --git a/hr-HR/images/grey-points.png b/hr-HR/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/hr-HR/images/grey-points.png differ diff --git a/hr-HR/images/initial_target.png b/hr-HR/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/hr-HR/images/initial_target.png differ diff --git a/hr-HR/images/missed-points.png b/hr-HR/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/hr-HR/images/missed-points.png differ diff --git a/hr-HR/images/outline-circles.png b/hr-HR/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/hr-HR/images/outline-circles.png differ diff --git a/hr-HR/images/points-scored.gif b/hr-HR/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/hr-HR/images/points-scored.gif differ diff --git a/hr-HR/images/quiz-colour.png b/hr-HR/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/hr-HR/images/quiz-colour.png differ diff --git a/hr-HR/images/random-side.png b/hr-HR/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/hr-HR/images/random-side.png differ diff --git a/hr-HR/images/rectangle-diagram.png b/hr-HR/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/hr-HR/images/rectangle-diagram.png differ diff --git a/hr-HR/images/showcase_rocket.png b/hr-HR/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/hr-HR/images/showcase_rocket.png differ diff --git a/hr-HR/images/showcase_static.png b/hr-HR/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/hr-HR/images/showcase_static.png differ diff --git a/hr-HR/images/sky_coords.png b/hr-HR/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/hr-HR/images/sky_coords.png differ diff --git a/hr-HR/images/sky_stroke.png b/hr-HR/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/hr-HR/images/sky_stroke.png differ diff --git a/hr-HR/images/stand_coords.png b/hr-HR/images/stand_coords.png new file mode 100644 index 000000000..28e151045 Binary files /dev/null and b/hr-HR/images/stand_coords.png differ diff --git a/hr-HR/images/step_4_preview.gif b/hr-HR/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/hr-HR/images/step_4_preview.gif differ diff --git a/hr-HR/images/step_5_preview.gif b/hr-HR/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/hr-HR/images/step_5_preview.gif differ diff --git a/hr-HR/images/target-stand.png b/hr-HR/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/hr-HR/images/target-stand.png differ diff --git a/hr-HR/images/target_area.png b/hr-HR/images/target_area.png new file mode 100644 index 000000000..72d80ba1d Binary files /dev/null and b/hr-HR/images/target_area.png differ diff --git a/hr-HR/images/three-circles.png b/hr-HR/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/hr-HR/images/three-circles.png differ diff --git a/hr-HR/images/top-left.png b/hr-HR/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/hr-HR/images/top-left.png differ diff --git a/hr-HR/images/triangles-coords.png b/hr-HR/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/hr-HR/images/triangles-coords.png differ diff --git a/hr-HR/images/upgrade-ideas.png b/hr-HR/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/hr-HR/images/upgrade-ideas.png differ diff --git a/hr-HR/images/yellow-points.png b/hr-HR/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/hr-HR/images/yellow-points.png differ diff --git a/hr-HR/meta.yml b/hr-HR/meta.yml new file mode 100644 index 000000000..d4420e902 --- /dev/null +++ b/hr-HR/meta.yml @@ -0,0 +1,36 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: You will make + - + title: Create a background + - + title: Draw your target + completion: + - engaged + - + title: Fire your arrow + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Upgrade your project + - + title: What next? diff --git a/hr-HR/python-comments-demo.txt b/hr-HR/python-comments-demo.txt new file mode 100644 index 000000000..cb2eb5621 --- /dev/null +++ b/hr-HR/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill color to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill color to grass diff --git a/hr-HR/python-comments.txt b/hr-HR/python-comments.txt new file mode 100644 index 000000000..160666a85 --- /dev/null +++ b/hr-HR/python-comments.txt @@ -0,0 +1,87 @@ +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Start x, start y, width, height + +x, y, width, height + +Set the stand fill colour to wood + +Set the arrow to fill colour to wood + +Set the stand fill colour to grass + +Set the circle fill colour to outer + +Set the circle fill colour to inner + +Set the circle fill colour to middle + +x, y, width of the circle + +Inner circle - x, y, width of the circle + +Middle circle - x, y, width of the circle + +Outer circle.200, 200 is the middle of the screen + +Blue + +Red + +Yellow + +Stand + +Outer circle + +Inner circle + +Bullseye + +The shoot_arrow function goes here + +Import library code + +Update to random coordinates + +Save the colour before drawing the arrow + +The mouse_pressed function goes here + +Can be used in other functions + +Like functions, 'if' statements are indented + +Setup your game here + +width and height + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Keep this to run your code + +Store a random number between 100 and 300 + +Get the hit colour + +Draw a small circle at random coordinates + +width and height of screen diff --git a/hr-HR/python-translatable-demo.txt b/hr-HR/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/hr-HR/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/hr-HR/python-translatable.txt b/hr-HR/python-translatable.txt new file mode 100644 index 000000000..75c0058cc --- /dev/null +++ b/hr-HR/python-translatable.txt @@ -0,0 +1,43 @@ +sky + +grass + +wood + +outer + +inner + +bullseye + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the bullseye, 500 points! + +You missed! No points! + +How fast do you want the arrow? slow, medium, fast + +You hit red, 200 points! + +speed + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! diff --git a/hr-HR/quiz1/question_1.md b/hr-HR/quiz1/question_1.md new file mode 100644 index 000000000..7413e69a7 --- /dev/null +++ b/hr-HR/quiz1/question_1.md @@ -0,0 +1,53 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +Here is a blue square, what are the RGB values that will create it? + +![A single block of blue colour.](images/quiz-colour.png) + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +Not quite, when all the colour values are set to `0`, the color is **black**. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite, colours follow the RGB model. This colour has maximum R value and no G or B, so will be **red**. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + That's correct! Colours follow the RGB model. This colour has no R or G, but maximum B, so will be **blue**. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite, when all the colour values are set to the `255` maximum, the color is **white**. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/hr-HR/quiz1/question_2.md b/hr-HR/quiz1/question_2.md new file mode 100644 index 000000000..cb8b743b2 --- /dev/null +++ b/hr-HR/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/hr-HR/quiz1/question_3.md b/hr-HR/quiz1/question_3.md new file mode 100644 index 000000000..de44b3b7f --- /dev/null +++ b/hr-HR/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/hr-HR/step_1.md b/hr-HR/step_1.md new file mode 100644 index 000000000..21a69d6b9 --- /dev/null +++ b/hr-HR/step_1.md @@ -0,0 +1,40 @@ +## You will make + +Use Python, with the `p5` graphics library, to draw a target and score points by hitting it with arrows. + +You will: + + Personalise your game with **RGB colours** + + Use **conditional statements** (`if`, `elif`, `else`) to make decisions + + Position shapes with **x, y coordinates** + +--- no-print --- + +### Play ▶️ + +--- task --- + +
+
+Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + +Have a few goes. Your score appears in the output area below the target. How does your score change when the arrow lands on the different colours? + +
+
+ +--- /task --- + +--- /no-print --- + +--- print-only --- + +![Completed project.](images/yellow-points.png) + +--- /print-only --- + +

+The oldest evidence of archery comes from the Sibudu Cave in KwaZulu-Natal, South Africa. Remains of stone and bone arrowheads have been found, which date to between 60,000 and 70,000 years ago. +

+ +![](http://code.org/api/hour/begin_coderdojo_target.png) diff --git a/hr-HR/step_2.md b/hr-HR/step_2.md new file mode 100644 index 000000000..b03ac80cf --- /dev/null +++ b/hr-HR/step_2.md @@ -0,0 +1,97 @@ +## Create a background + +
+
+Your game needs a colourful background. +
+
+ +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="300px"} + +
+
+ +### Open the starter project + +--- task --- + +Open the [Target practice starter](https://trinket.io/python/9973649e5c){:target="_blank"} project. + +If you have a Trinket account, you can click on the **Remix** button to save a copy to your **My Trinkets** library. + +--- /task --- + +### Edit the sky + +--- task --- + +The starter project has some code already written for you. + +Click **'Run'** to see a blue filled rectangle drawn from x=`0`, y=`0` (the top of the screen). This `400` x `250` pixels rectangle is the sky. + +![A blue rectangle with a black border around it, above a grey rectangle. The top left corner of the canvas is marked as x=0, y=0 this is the origin of the rectangle. The width is highlighted as 400 and the height as 250. The code rect(0, 0, 400, 250) is shown.](images/sky_stroke.png){:width="400px"} + +**Tip:** 💡 Coordinates start from (x=0, y=0) in the top left corner. This might be different to other coordinate systems you have used. + +--- /task --- + +--- task --- + +The sky has been drawn with a black border (stroke). + +To turn the stroke off for all shapes add `no_stroke()` to the `setup` function: + +--- code --- +--- +language: python filename: main.py — setup() line_numbers: true line_number_start: 11 +line_highlights: 15 +--- +def setup(): +# Setup your game here + size(400, 400) # width and height of screen frame_rate(2) no_stroke() + +--- /code --- + +--- /task --- + +--- task --- + +**Run** your code again and notice 👀 that the border (stroke) has now disappeared. + +--- /task --- + +### Draw the grass + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 17 +line_highlights: 27, 28 +--- +def draw(): +# Things to do in every frame + global wood sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 grass = color(149, 212, 122) wood = color(145, 96, 51) outer = color(0, 120, 180) + + fill(sky) +rect(0, 0, 400, 250) +fill(grass) # Set the fill color to grass rect(0, 250, 400, 150) # x, y, width, height + +--- /code --- + +**Tip:** 💡 We have added comments to our code, like `# Set the fill color to grass`, to tell you what it does. You don't need to add these comments to your code, but they can be helpful to remind you what lines of code do. + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project again to view the finished background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + diff --git a/hr-HR/step_3.md b/hr-HR/step_3.md new file mode 100644 index 000000000..39986aa1f --- /dev/null +++ b/hr-HR/step_3.md @@ -0,0 +1,152 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `wood` (brown). + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 i the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 27 +line_highlights: 29, 30 +--- + fill(grass) +rect(0, 250, 400, 150) fill(wood) # Set the stand fill colour to wood +triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `outer` (blue). + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 29 +line_highlights: 31, 32 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) # Set the circle fill colour to outer +circle(200, 200, 170) # x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front: + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +--- task --- + +👀 Find your colour variables in the `draw` function. + +Create two variables called `inner` and `middle` to store colours for the other circles. + +The `color` function expects three numbers: one each for red, green, and blue. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 17 +line_highlights: 24, 25 +--- +def draw(): +# Things to do in every frame global wood sky = color(92, 204, 206) +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) # Blue +inner = color(210, 60, 60) # Red +middle = color(220, 200, 0) # Yellow + +--- /code --- + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 35, 36, 37, 38 +--- + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) +circle(200, 200, 170) fill(inner) # Set the circle fill colour to inner +circle(200, 200, 110) # Inner circle - x, y, width of the circle +fill(middle) # Set the circle fill colour to middle +circle(200, 200, 30) # Middle circle - x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +**Debug:** 🐞 Check that you have used the American spelling of 'color' (without a 'u'). + +--- /task --- + +--- task --- + +**Choose:** 💭 Change any of the colours. + +[[[generic-theory-simple-colours]]] + +![A brown triangle with three coloured circles on grass and against a sky. The colours have changed to pinks and purples.](images/alternative-colours.png){:width="400px"} + + +--- /task --- + + + diff --git a/hr-HR/step_4.md b/hr-HR/step_4.md new file mode 100644 index 000000000..995a078e0 --- /dev/null +++ b/hr-HR/step_4.md @@ -0,0 +1,159 @@ +## Fire your arrow + +
+
+When you click or tap, an arrow will fire at the position of a moving target circle. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Draw a target circle every frame + +

Computers create the effect of movement by showing lots of images one after another. Each image is called a frame . +

+ +--- task --- + +Define your `shoot_arrow()` function under the comment **# The shoot_arrow function goes here**. + +Add code to randomly draw a brown circle within a target area: + +![A rectangle showing the target area coordinates in a semi transparent rectangle. The target area is between x=100 and y=100 to x=300 and y=300 so covers the whole target and wider.](images/target_area.png) + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 10, 11, 12, 13, 14 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) # Store a random number between 100 and 300 +arrow_y = randint(100, 300) # Store a random number between 100 and 300 +fill(wood) # Set the arrow to fill colour to wood +circle(arrow_x, arrow_y, 15) # Draw a small circle at random coordinates + +--- /code --- + +--- /task --- + +--- task --- + +Go to the `draw` function and call your new `shoot_arrow` function. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 42 +line_highlights: 44 +--- + fill(middle) +circle(200, 200, 30) +shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run you code and see the arrow appear in a random position each frame. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +The background and target will be drawn over the old arrow. This means you only see one arrow at a time. + +--- /task --- + +### Get the colour hit by the arrow + +The `get()` function returns the colour of a pixel. + +

+A pixel, short for picture element, is a single coloured dot within an image. Images are made up of lots of coloured pixels. +

+ +--- task --- + +Add code to `get` the colour of the pixel at the centre of the arrow and store it in the `hit_color` variable. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Get the hit colour fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** 💡 The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the wood colour of the arrow! + +--- /task --- + +### Print the colour when the mouse is pressed + +The `p5` library 'listens' for certain events, one of these is the press of the mouse button. When it detects that the button has been pressed, it will run whatever code it has been given in the `mouse_pressed` function. + +--- task --- + +Define your `mouse_pressed()` function under the comment **# The mouse_pressed function goes here**. + +Add code to print the amounts of red, green, and blue in the pixel the arrow lands on. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 8, 9 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +print( red(hit_color), green(hit_color), blue(hit_color) ) + +--- /code --- + +--- /task --- + +--- task --- + +Make `hit_color` a **global variable** so that it can be used throughout your code: + +--- code --- +--- +language: python filename: main.py - shoot_arrow() line_numbers: true line_number_start: 11 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +global hit_color # Can be used in other functions +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Save the colour before drawing the arrow fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. + +The project prints the `hit_color` each time the arrow is redrawn. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +**Debug:** 🐞 If you are seeing a message about `hit_color` being 'not defined', then go back to `shoot_arrow()` and check that you have the `global hit_color` line. + +**Debug:** 🐞 Check the `print` line really carefully for commas and brackets. + +--- /task --- + + diff --git a/hr-HR/step_5.md b/hr-HR/step_5.md new file mode 100644 index 000000000..e0660f134 --- /dev/null +++ b/hr-HR/step_5.md @@ -0,0 +1,169 @@ +## Score points + +
+
+Your game will add scores based on where the arrow hits. +
+
+ +![The target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Go to the `draw()` function and add `, outer, inner, middle` to the list of global variables. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 28 +--- + +def draw(): +# Things to do in every frame + global wood, outer, inner, middle +sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +middle = color(220, 200, 0) + +--- /code --- + +--- /task --- + +

+We use conditions all the time to make decisions. We could say 'if the pencil is blunt, then sharpen it'. Similarly, `if` conditions let us write code that do something different depending on whether a condition is true or false. +

+ +### Display the scores + +--- task --- + +Delete ❌ the `print( red(hit_color), green(hit_color), blue(hit_color) )` line of code. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9 +--- +# The mouse_pressed function goes here +def mouse_pressed(): + + +--- /code --- + +--- /task --- + +--- task --- + +`print` a message `if` the `hit_color` is equal to `outer` 🎯. + +Notice 👀 that the code uses two equals signs `==` to mean **equal to**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9, 10 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') # Like functions, 'if' statements are indented + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the blue outer circle to see your message. + +**Tip:** 💡 `frame_rate()`, in `setup`, controls how fast your game draws. If it's going too fast, set it to a lower number. + +![The output area with arrow touching the outer circle. The points print statement appears in the output area.](images/blue-points.png) + +**Debug:** 🐞 Make sure your code matches exactly and you indented the code inside your `if` statement. + +--- /task --- + +`elif` (else - if) can be used to add more conditions to your `if` statement. These will be read from top to bottom. As soon as a **True** condition is found, it will be actioned. The remaining conditions will be ignored. + +--- task --- + +Score points if the arrow lands on the `inner` or `middle` circles 🎯: + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11, 12, 13, 14 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the inner and middle circles to see their messages. + +![The output area with arrow touching the inner circle. The points print statement appears in the output area.](images/yellow-points.png) + +**Debug:** 🐞 Check your indentation matches the example. + +**Debug:** 🐞 If you see a message about `inner` or `middle` being 'not defined', then go back to `draw()` and check that they are on the line that declares variables global. + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? ❌ + +To do this last check, you use `else`. + +--- task --- + +Add code to `print` a message `else` none of the `if` and `elif` statements have been met. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 8 +line_highlights: 15, 16 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') +else: +print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow in the grass or sky to see the miss message. + +**Choose:** 💭 Change the number of points scored for the different colours if you like. + +![The output area with an arrow missing the target. The points print statement appears in the output area.](images/missed-points.png) + +--- /task --- + diff --git a/hr-HR/step_6.md b/hr-HR/step_6.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/hr-HR/step_6.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/hr-HR/step_7.md b/hr-HR/step_7.md new file mode 100644 index 000000000..e479b9649 --- /dev/null +++ b/hr-HR/step_7.md @@ -0,0 +1,35 @@ +## Upgrade your project + +
+
+Personalise and add more to your project. Perhaps you could change the difficulty level or add more circles to your target. +
+
+ +![The output area showing a target with five circles.](images/five_circles.png){:width="300px"} + +
+
+ +--- task --- + +You could: + ++ Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position 🟠🟣 ++ Put emoji in your print messages ([here's a list of emoji](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) 🎯 ++ Make the game easier or harder by changing the `frame_rate(2)` value 💨 ++ Use `input()` to ask the user which difficulty level they want to play at 🗣️ + +--- /task --- + +![Upgraded project ideas: one with five circles, one with a difficulty input question, one with emoji in the points message.](images/upgrade-ideas.png) + +--- collapse --- +--- +title: Completed project +--- + +You can view the [completed project here](https://trinket.io/python/f686c82d8a){:target="_blank"}. + +--- /collapse --- + diff --git a/hr-HR/step_8.md b/hr-HR/step_8.md new file mode 100644 index 000000000..867ede7b9 --- /dev/null +++ b/hr-HR/step_8.md @@ -0,0 +1,31 @@ +## What next? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png) + +--- /print-only --- + +--- no-print --- + +--- task --- + +**Try it:** Your program will adjust the animation based on how much fuel you give it and will succeed or fail in reaching orbit. How much fuel do you want to use to reach orbit but not waste too much extra fuel? + +**Tip:** Around 25,000kg should be enough, but experiment with the numbers to see what happens. + + + +![Rocket launch project](images/showcase_rocket.png) + +--- /task --- + +--- /no-print --- + +If you want to have more fun exploring Python, then you could try out any of [these projects](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + + + diff --git a/it-IT/code/target-practice-solution/main.py b/it-IT/code/target-practice-solution/main.py new file mode 100644 index 000000000..77a4ec5fd --- /dev/null +++ b/it-IT/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +# Importa la libreria di codice! + +from p5 import * +from random import randint + + +# La funzione mouse_pressed va qui +def mouse_pressed(): + global hit_colour # Può essere utilizzato in altre funzioni + if hit_colour == Color('blue').hex: # Come le funzioni, le istruzioni 'if' sono rientrate + print('Hai colpito il cerchio esterno, 50 punti!') + elif hit_colour == Color('red').hex: + print('Hai colpito il cerchio esterno, 200 punti!') + elif hit_colour == Color('yellow').hex: + print('Hai colpito il cerchio intermedio, 500 punti!') + else: + print('L\'hai mancato! Zero punti!') + + +# La funzione shoot_arrow va qui +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) # Memorizza un numero casuale compreso tra 100 e 300 + arrow_y = randint(100, 300) # Memorizza un numero casuale compreso tra 100 e 300 + hit_colour = get(arrow_x, arrow_y).hex # Ottieni il colore del risultato + # print(hit_colour) + fill('sienna') # Imposta la freccia per riempire il colore su marrone + circle(arrow_x, arrow_y, 15) # Disegna un piccolo cerchio a coordinate casuali + + +def setup(): + # Imposta il tuo gioco qui + size(400, 400) # larghezza e altezza + no_stroke() + + +def draw(): + # Cose da fare in ogni fotogramma + fill('cyan') + rect(0, 0, 400, 250) # Cielo + fill('lightgreen') + rect(0, 250, 400, 150) # Erba + fill('sienna') + triangle(150, 350, 200, 150, 250, 350) # Piedistallo + fill('blue') + circle(200, 200, 170) # Cerchio esterno + fill('red') + circle(200, 200, 110) # Cerchio interno + fill('yellow') + circle(200, 200, 30) # Cerchio intermedio + shoot_arrow() + + +# Conserva questa parte per eseguire il codice +run(frame_rate=2) diff --git a/it-IT/code/target-practice-solution/project_config.yml b/it-IT/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..438a4ba3c --- /dev/null +++ b/it-IT/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Esempio di Allenamento del Tiro al Bersaglio' +identifier: 'target-practice-solution' +type: 'python' diff --git a/it-IT/code/target-practice-starter/main.py b/it-IT/code/target-practice-starter/main.py new file mode 100644 index 000000000..81bb4e279 --- /dev/null +++ b/it-IT/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +# Importa la libreria di codice +from p5 import * +from random import randint + +# La funzione mouse_pressed va qui + + +# La funzione shoot_arrow va qui + + +def setup(): + # Imposta il tuo gioco qui + size(400, 400) # larghezza e altezza dello schermo + no_stroke() + + +def draw(): + # Cose da fare in ogni fotogramma + fill("cyan") + rect(0, 0, 400, 250) + + +# Conserva questa parte per eseguire il codice +run(frame_rate=2) diff --git a/it-IT/code/target-practice-starter/project_config.yml b/it-IT/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..f40940757 --- /dev/null +++ b/it-IT/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Allenamento di tiro al bersaglio" +identifier: 'target-practice-starter' +type: 'python' diff --git a/it-IT/images/alternative-colours.png b/it-IT/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/it-IT/images/alternative-colours.png differ diff --git a/it-IT/images/animation_bg_erase.gif b/it-IT/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/it-IT/images/animation_bg_erase.gif differ diff --git a/it-IT/images/animation_no_bg_erase.gif b/it-IT/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/it-IT/images/animation_no_bg_erase.gif differ diff --git a/it-IT/images/arrow-centre.png b/it-IT/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/it-IT/images/arrow-centre.png differ diff --git a/it-IT/images/arrow-middle.png b/it-IT/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/it-IT/images/arrow-middle.png differ diff --git a/it-IT/images/arrow-target.png b/it-IT/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/it-IT/images/arrow-target.png differ diff --git a/it-IT/images/background.png b/it-IT/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/it-IT/images/background.png differ diff --git a/it-IT/images/banner.png b/it-IT/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/it-IT/images/banner.png differ diff --git a/it-IT/images/blue-circle.png b/it-IT/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/it-IT/images/blue-circle.png differ diff --git a/it-IT/images/blue-points.png b/it-IT/images/blue-points.png new file mode 100644 index 000000000..ddfbb723d Binary files /dev/null and b/it-IT/images/blue-points.png differ diff --git a/it-IT/images/blue_circle_points.gif b/it-IT/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/it-IT/images/blue_circle_points.gif differ diff --git a/it-IT/images/bottom-right.png b/it-IT/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/it-IT/images/bottom-right.png differ diff --git a/it-IT/images/centre.png b/it-IT/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/it-IT/images/centre.png differ diff --git a/it-IT/images/circle-coords.png b/it-IT/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/it-IT/images/circle-coords.png differ diff --git a/it-IT/images/coords_animation.gif b/it-IT/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/it-IT/images/coords_animation.gif differ diff --git a/it-IT/images/difficulty-setting.png b/it-IT/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/it-IT/images/difficulty-setting.png differ diff --git a/it-IT/images/fire_arrow.gif b/it-IT/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/it-IT/images/fire_arrow.gif differ diff --git a/it-IT/images/five_circles.png b/it-IT/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/it-IT/images/five_circles.png differ diff --git a/it-IT/images/green-grass.png b/it-IT/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/it-IT/images/green-grass.png differ diff --git a/it-IT/images/grey-circle.png b/it-IT/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/it-IT/images/grey-circle.png differ diff --git a/it-IT/images/grey-points.png b/it-IT/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/it-IT/images/grey-points.png differ diff --git a/it-IT/images/initial_target.png b/it-IT/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/it-IT/images/initial_target.png differ diff --git a/it-IT/images/missed_no_points.gif b/it-IT/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/it-IT/images/missed_no_points.gif differ diff --git a/it-IT/images/outline-circles.png b/it-IT/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/it-IT/images/outline-circles.png differ diff --git a/it-IT/images/points-scored.gif b/it-IT/images/points-scored.gif new file mode 100644 index 000000000..eefd428ce Binary files /dev/null and b/it-IT/images/points-scored.gif differ diff --git a/it-IT/images/quiz-colour.png b/it-IT/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/it-IT/images/quiz-colour.png differ diff --git a/it-IT/images/random-side.png b/it-IT/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/it-IT/images/random-side.png differ diff --git a/it-IT/images/rectangle-diagram.png b/it-IT/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/it-IT/images/rectangle-diagram.png differ diff --git a/it-IT/images/showcase_rocket.png b/it-IT/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/it-IT/images/showcase_rocket.png differ diff --git a/it-IT/images/showcase_static.png b/it-IT/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/it-IT/images/showcase_static.png differ diff --git a/it-IT/images/sky_coords.png b/it-IT/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/it-IT/images/sky_coords.png differ diff --git a/it-IT/images/sky_stroke.png b/it-IT/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/it-IT/images/sky_stroke.png differ diff --git a/it-IT/images/stand_coords.png b/it-IT/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/it-IT/images/stand_coords.png differ diff --git a/it-IT/images/step_4_preview.gif b/it-IT/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/it-IT/images/step_4_preview.gif differ diff --git a/it-IT/images/step_5_preview.gif b/it-IT/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/it-IT/images/step_5_preview.gif differ diff --git a/it-IT/images/target-stand.png b/it-IT/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/it-IT/images/target-stand.png differ diff --git a/it-IT/images/target_area.png b/it-IT/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/it-IT/images/target_area.png differ diff --git a/it-IT/images/target_printed.gif b/it-IT/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/it-IT/images/target_printed.gif differ diff --git a/it-IT/images/three-circles.png b/it-IT/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/it-IT/images/three-circles.png differ diff --git a/it-IT/images/top-left.png b/it-IT/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/it-IT/images/top-left.png differ diff --git a/it-IT/images/triangles-coords.png b/it-IT/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/it-IT/images/triangles-coords.png differ diff --git a/it-IT/images/upgrade-ideas.png b/it-IT/images/upgrade-ideas.png new file mode 100644 index 000000000..b04274189 Binary files /dev/null and b/it-IT/images/upgrade-ideas.png differ diff --git a/it-IT/images/yellow-points.png b/it-IT/images/yellow-points.png new file mode 100644 index 000000000..862f53134 Binary files /dev/null and b/it-IT/images/yellow-points.png differ diff --git a/it-IT/meta.yml b/it-IT/meta.yml new file mode 100644 index 000000000..7af525303 --- /dev/null +++ b/it-IT/meta.yml @@ -0,0 +1,41 @@ +--- +title: Allenamento di tiro al bersaglio +hero_image: images/banner.png +description: Usa Python per disegnare un bersaglio e fare punti colpendolo con le frecce +meta_title: Progetti di programmazione in Python per bambini e ragazzi | Allenamento di tiro al bersaglio +meta_description: Impara Python con i progetti di codifica della Raspberry Pi Foundation per bambini e adolescenti. Usa Python per disegnare un bersaglio e segnare punti colpendolo con le frecce. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Quello che farai + - + title: Crea uno sfondo + - + title: Disegna il tuo bersaglio + completion: + - engaged + - + title: Scocca la tua freccia + - + title: Punteggio + - + title: Quiz veloce + completion: + - external + - + title: Migliora il tuo progetto + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: E adesso? + challenge: true + - + title: What can you do now? diff --git a/it-IT/python-comments-demo.txt b/it-IT/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/it-IT/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/it-IT/python-comments.txt b/it-IT/python-comments.txt new file mode 100644 index 000000000..eb1d8c3a2 --- /dev/null +++ b/it-IT/python-comments.txt @@ -0,0 +1,27 @@ +Cose da fare in ogni fotogramma + +Draw the inner circle + +Draw the middle circle + +La funzione shoot_arrow va qui + +La funzione mouse_pressed va qui + +Hai colpito il cerchio esterno, 50 punti! + +Hai colpito il cerchio interno, 200 punti! + +Hai colpito a metà bersaglio, 500 punti! + +You hit the middle, 500 points! + +Mancato! Zero punti! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/it-IT/python-translatable-demo.txt b/it-IT/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/it-IT/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/it-IT/python-translatable.txt b/it-IT/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/it-IT/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/it-IT/quiz1/question_1.md b/it-IT/quiz1/question_1.md new file mode 100644 index 000000000..9976cfe98 --- /dev/null +++ b/it-IT/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quiz veloce + +Rispondi alle tre domande. Ci sono alcuni suggerimenti per aiutarti a trovare la risposta corretta. + +Dopo aver risposto a ciascuna domanda, fai clic su **Controlla la mia risposta**. + +Divertiti! + +--- question --- +--- +legend: Domanda 1 di 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +È corretto. Se non utilizzi questa funzione verrà disegnato un bordo nero attorno alle tue forme. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Non proprio. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- ( ) Riempie la forma con un dato colore. + + --- feedback --- + + Non proprio. La funzione fill() fa questo e di solito includerà un dato colore. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Non proprio. La funzione circle() verrebbe utilizzata per disegnare un cerchio. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/it-IT/quiz1/question_2.md b/it-IT/quiz1/question_2.md new file mode 100644 index 000000000..73bb048a5 --- /dev/null +++ b/it-IT/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Domanda 2 di 3 +--- + +Nel tuo progetto, hai utilizzato le condizioni `if` , `elif`e `else` per verificare su quale colore è atterrata la freccia. + +Nell'esempio seguente, una variabile chiamata `speed` ha il numero `6` memorizzato al suo interno. Quando viene eseguita questa istruzione `if` , cosa verrà stampato nell'area di output? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super veloce') elif speed == 5: print('Abbastanza veloce') elif speed == 6: print('Molto veloce') else: print('Velocità non rilevata!') + +--- /code --- + +--- choices --- + +- (x) `Molto veloce` + + --- feedback --- + + È corretto! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Velocità non riconosciuta!` + + --- feedback --- + + Non proprio, guarda il valore assegnato alla variabile **speed**. + + --- /feedback --- + +- ( ) Non viene stampato nulla + + --- feedback --- + + Riprova, `else` viene utilizzato come opzione finale quando tutte le condizioni di cui sopra sono false. Esamina nuovamente le condizioni: qualcuna di esse è vera? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/it-IT/quiz1/question_3.md b/it-IT/quiz1/question_3.md new file mode 100644 index 000000000..3dd907d2f --- /dev/null +++ b/it-IT/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Domanda 3 di 3 +--- + +Viene disegnato un cerchio utilizzando il seguente codice: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Quale delle immagini seguenti mostra la posizione corretta di questo cerchio nell'area di output? + +--- choices --- + +- ( ) ![Un cerchio verde centrato nell'angolo inferiore destro dell'area di output.](images/bottom-right.png) + + --- feedback --- + + Non proprio, per centrare il cerchio nell'angolo in basso a destra, le coordinate dovrebbero essere le stesse della dimensione dello schermo. In questo esempio, l'ellisse sarebbe `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Un cerchio verde centrato nella zona intermedia dell'area di output.](images/centre.png) + + --- feedback --- + + Non proprio, per centrare il cerchio intermedio, le coordinate dovrebbero essere la metà della dimensione dello schermo. In questo esempio, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Un cerchio verde centrato nell'angolo superiore sinistro dell'area di output.](images/top-left.png) + + --- feedback --- + + È corretto! Questo cerchio è centrato nelle coordinate (0,0), nell'angolo in alto a sinistra dello schermo. + + --- /feedback --- + +- ( ) ![Un cerchio verde centrato nell'angolo superiore destro dell'area di output.](images/random-side.png) + + --- feedback --- + + No, per centrarlo verso l'angolo in alto a destra dello schermo, questo cerchio avrebbe il codice `circle(350, 150, 300)` . La coordinata `x` indica la distanza dell'ellisse rispetto a margine sinistro dello schermo, mentre la coordinata `y` indica dal margine superiore. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/it-IT/step_1.md b/it-IT/step_1.md new file mode 100644 index 000000000..e52a3fad9 --- /dev/null +++ b/it-IT/step_1.md @@ -0,0 +1,29 @@ +## Quello che farai + +Usa Python, con la libreria grafica `p5` , per disegnare un bersaglio e segnare punti colpendolo con le frecce. + +--- print-only --- + +![Un bersaglio per tiro con l'arco con un colpo finito sul cerchio esterno. Sotto viene visualizzato il testo "Hai colpito il cerchio esterno, 50 punti!" ](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Fai clic sul pulsante **Run** in basso per avviare il gioco. Quando appare il punto sul bersaglio 🎯, fai clic con il mouse (o tocca sul tablet) per scoccare la freccia. + + +
+
+ +--- /no-print --- + +
+ Partecipa al nostro sondaggio per contribuire a migliorare il nostro editor di codice! +
+ + + diff --git a/it-IT/step_2.md b/it-IT/step_2.md new file mode 100644 index 000000000..94f6998e6 --- /dev/null +++ b/it-IT/step_2.md @@ -0,0 +1,37 @@ +## Disegna l'erba + +--- task --- + +Apri il progetto [Target Practice Starter](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Aggiungi** il codice per disegnare un rettangolo verde nella parte inferiore dello schermo. + +![L'area di output con un rettangolo color cielo sopra un rettangolo color erba per creare lo sfondo. L'angolo in alto a sinistra del rettangolo è contrassegnato dalle coordinate x=0, y=250; questa è l'origine del rettangolo. La larghezza è indicata come 400 e l'altezza come 150. Viene visualizzato il codice rect(0, 250, 400, 150).](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 14 +line_highlights: 12 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Esegui nuovamente il progetto per visualizzare lo sfondo finito. + +![L'area di output con un rettangolo color cielo sopra un rettangolo color erba per creare lo sfondo.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/it-IT/step_3.md b/it-IT/step_3.md new file mode 100644 index 000000000..4784b2320 --- /dev/null +++ b/it-IT/step_3.md @@ -0,0 +1,117 @@ +## Disegna il tuo bersaglio + +
+
+Il tuo gioco ha bisogno di un bersaglio contro il quale lanciare le frecce. +
+
+ +![L'area di output con il bersaglio e il supporto.](images/three-circles.png){:width="300px"} + +
+
+ +### Disegna un supporto triangolare + +--- task --- + +Imposta il colore di riempimento su `sienna` (marrone). + +Disegna un triangolo utilizzando le coordinate x e y per ciascuno degli angoli. + +![Un triangolo marrone sull'erba, contro un cielo con i punti delle coordinate etichettati 150, 350 e 200, 150 e 250, 350). Anche gli angoli del nostro spazio sono etichettati come x=0, y=0 in alto a sinistra e x=400, y=400 in basso a destra.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 18 +line_highlights: 20, 21 +--- + + fill('lightgreen') # Imposta il colore di riempimento dell'erba su verde chiaro + rect(0, 250, 400, 150) # Disegna un rettangolo per il cielo con questi valori per x, y, larghezza, altezza + fill('sienna') # Colore marrone + triangle(150, 350, 200, 150, 250, 350) # Disegna un triangolo per la posizione del bersaglio + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Esegui il codice per vedere il supporto del tuo obiettivo: + +![Un triangolo marrone sull'erba e contro il cielo.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Disegna i cerchi bersaglio + +--- task --- + +La parte più grande del bersaglio è un **cerchio** blu. + +Imposta il colore di riempimento su `blu`. + +Disegna un cerchio con le coordinate x e y per il centro e una larghezza. + +![Un triangolo marrone e un cerchio blu sull'erba e sopra il cielo. Il cerchio è etichettato con le coordinate x=200, y=200 come centro e la larghezza del cerchio pari a 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 20 +line_highlights: 22, 23 +--- + + fill('sienna') # Colore marrone + triangle(150, 350, 200, 150, 250, 350) # Disegna un triangolo per la posizione del bersaglio + fill('blue') # Imposta il colore di riempimento del cerchio su blu + circle(200, 200, 170) # Disegna il cerchio esterno + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Esegui il codice per vedere il primo grande cerchio blu. + +Il cerchio blu è stato disegnato dopo il supporto, quindi appare davanti. + +![Un triangolo marrone e un cerchio blu sull'erba e sopra il cielo.](images/blue-circle.png){:width="400px"} + +--- /task --- + +Il bersaglio è composto da cerchi di diverse dimensioni ma con le stesse coordinate centrali (200, 200). + +--- task --- + +**Aggiungi** cerchi colorati per le parti interne e centrali del bersaglio. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 20 +line_highlights: 24, 25, 26, 27 +--- + + fill('sienna') # Colore marrone + triangle(150, 350, 200, 150, 250, 350) # Disegna un triangolo per la posizione del bersaglio + fill('blue') # Imposta il colore di riempimento del cerchio su blu + circle(200, 200, 170) # Disegna il cerchio esterno + fill('red') # Imposta il colore di riempimento del cerchio su rosso + circle(200, 200, 110) # Disegna il cerchio interno usando x, y, larghezza + fill('yellow') # Imposta il colore di riempimento del cerchio su giallo + circle(200, 200, 30) # Disegna il cerchio interno usando x, y, larghezza + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Esegui il tuo progetto per vedere il bersaglio con i tre cerchi colorati. + +![Un triangolo marrone e tre cerchi colorati sull'erba e sopra il cielo.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/it-IT/step_4.md b/it-IT/step_4.md new file mode 100644 index 000000000..14b4a2c1d --- /dev/null +++ b/it-IT/step_4.md @@ -0,0 +1,88 @@ +## Scocca la tua freccia + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![Il bersaglio, con una freccia circolare marrone che appare in varie posizioni.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Aggiungi il codice per disegnare casualmente un cerchio marrone all'interno di un'area target: + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 7 +line_highlights: 8-12 +--- +# La funzione shoot_arrow va qui +def shoot_arrow(): +arrow_x = randint(100, 300) # Memorizza un numero a caso fra 100 e 300 arrow_y = randint(100, 300) # Memorizza un numero a caso fra 100 e 300 fill('sienna') # Imposta la freccia in modo che il colore di riempimento sia marrone circle(arrow_x, arrow_y, 15) # Disegna un piccolo cerchio a coordinate casuali + +--- /code --- + +--- /task --- + +--- task --- + +Vai alla funzione `draw` e chiama la tua nuova funzione `shoot_arrow` . + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 31 +line_highlights: 33 +--- + + fill('yellow') # Imposta il colore di riempimento del cerchio su giallo + circle(200, 200, 30) # Disegna il cerchio interno usando x, y, larghezza + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Esegui il tuo progetto. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Definisci la tua funzione `shoot_arrow()` sotto il commento **# La funzione shoot_arrow() va qui**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 5 +line_highlights: 9, 12 +--- +def shoot_arrow(): global hit_colour # Può essere utilizzato in altre funzioni arrow_x = randint(100, 300) # Memorizza un numero a caso fra 100 e 300 arrow_y = randint(100, 300) # Memorizza un numero a caso fra 100 e 300 hit_colour = get(arrow_x, arrow_y).hex # Ottieni il colore colpito fill('sienna') # Imposta la freccia in modo che il colore di riempimento sia marrone circle(arrow_x, arrow_y, 15) # Disegna un piccolo cerchio a coordinate casuali + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** 🔄 Esegui il tuo progetto. You should see the arrow jump around the target. + +![Un'animazione del bersaglio con una freccia circolare marrone che appare in diverse posizioni.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/it-IT/step_5.md b/it-IT/step_5.md new file mode 100644 index 000000000..6832aef51 --- /dev/null +++ b/it-IT/step_5.md @@ -0,0 +1,78 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +**Debug:** 🐞Se vedi un messaggio `hit_colour` being 'not defined', torna indietro alla funzione `draw()` e controlla la riga che dichiara `hit_colour` come variabile globale. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): +if hit_colour == Color('blue').hex: # Come il codice delle funzioni, il codice delle istruzioni 'if' è rientrato print('Hai colpito il cerchio esterno, 50 punti!') + +--- /code --- + +**Debug:** 🐞 Assicurati di aver utilizzato la stringa `.hex` per i colori del **tuo cerchio**. + +--- /task --- + +--- task --- + +**Test:** 🔄 Esegui il tuo progetto. Prova a lanciare la freccia sul cerchio esterno blu per vedere il messaggio. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 6 +line_highlights: 7, 8 +--- + + Visualizza un messaggio if il hit_color è uguale al colore del cerchio esterno (blu) 🎯. + + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 5 +line_highlights: 9-12 +--- +# La funzione mouse_pressed va qui +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Esegui il tuo progetto. Prova a lanciare la freccia sul cerchio interno e su quello esterno per vedere il messaggio. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/it-IT/step_6.md b/it-IT/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/it-IT/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/it-IT/step_7.md b/it-IT/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/it-IT/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/it-IT/step_8.md b/it-IT/step_8.md new file mode 100644 index 000000000..28ae6e382 --- /dev/null +++ b/it-IT/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /no-print --- diff --git a/it-IT/step_9.md b/it-IT/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/it-IT/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/ja-JP/code/target-practice-solution/main.py b/ja-JP/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/ja-JP/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/ja-JP/code/target-practice-solution/project_config.yml b/ja-JP/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/ja-JP/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/ja-JP/code/target-practice-starter/main.py b/ja-JP/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/ja-JP/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/ja-JP/code/target-practice-starter/project_config.yml b/ja-JP/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/ja-JP/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/ja-JP/images/alternative-colours.png b/ja-JP/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/ja-JP/images/alternative-colours.png differ diff --git a/ja-JP/images/animation_bg_erase.gif b/ja-JP/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/ja-JP/images/animation_bg_erase.gif differ diff --git a/ja-JP/images/animation_no_bg_erase.gif b/ja-JP/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/ja-JP/images/animation_no_bg_erase.gif differ diff --git a/ja-JP/images/arrow-centre.png b/ja-JP/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/ja-JP/images/arrow-centre.png differ diff --git a/ja-JP/images/arrow-middle.png b/ja-JP/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/ja-JP/images/arrow-middle.png differ diff --git a/ja-JP/images/arrow-target.png b/ja-JP/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/ja-JP/images/arrow-target.png differ diff --git a/ja-JP/images/background.png b/ja-JP/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/ja-JP/images/background.png differ diff --git a/ja-JP/images/banner.png b/ja-JP/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/ja-JP/images/banner.png differ diff --git a/ja-JP/images/blue-circle.png b/ja-JP/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/ja-JP/images/blue-circle.png differ diff --git a/ja-JP/images/blue-points.png b/ja-JP/images/blue-points.png new file mode 100644 index 000000000..f8487c4e5 Binary files /dev/null and b/ja-JP/images/blue-points.png differ diff --git a/ja-JP/images/blue_circle_points.gif b/ja-JP/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/ja-JP/images/blue_circle_points.gif differ diff --git a/ja-JP/images/bottom-right.png b/ja-JP/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/ja-JP/images/bottom-right.png differ diff --git a/ja-JP/images/centre.png b/ja-JP/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/ja-JP/images/centre.png differ diff --git a/ja-JP/images/circle-coords.png b/ja-JP/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/ja-JP/images/circle-coords.png differ diff --git a/ja-JP/images/coords_animation.gif b/ja-JP/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/ja-JP/images/coords_animation.gif differ diff --git a/ja-JP/images/difficulty-setting.png b/ja-JP/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/ja-JP/images/difficulty-setting.png differ diff --git a/ja-JP/images/fire_arrow.gif b/ja-JP/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/ja-JP/images/fire_arrow.gif differ diff --git a/ja-JP/images/five_circles.png b/ja-JP/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/ja-JP/images/five_circles.png differ diff --git a/ja-JP/images/green-grass.png b/ja-JP/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/ja-JP/images/green-grass.png differ diff --git a/ja-JP/images/grey-circle.png b/ja-JP/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/ja-JP/images/grey-circle.png differ diff --git a/ja-JP/images/grey-points.png b/ja-JP/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/ja-JP/images/grey-points.png differ diff --git a/ja-JP/images/initial_target.png b/ja-JP/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/ja-JP/images/initial_target.png differ diff --git a/ja-JP/images/missed-points.png b/ja-JP/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/ja-JP/images/missed-points.png differ diff --git a/ja-JP/images/missed_no_points.gif b/ja-JP/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/ja-JP/images/missed_no_points.gif differ diff --git a/ja-JP/images/outline-circles.png b/ja-JP/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/ja-JP/images/outline-circles.png differ diff --git a/ja-JP/images/points-scored.gif b/ja-JP/images/points-scored.gif new file mode 100644 index 000000000..564a20f7a Binary files /dev/null and b/ja-JP/images/points-scored.gif differ diff --git a/ja-JP/images/quiz-colour.png b/ja-JP/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/ja-JP/images/quiz-colour.png differ diff --git a/ja-JP/images/random-side.png b/ja-JP/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/ja-JP/images/random-side.png differ diff --git a/ja-JP/images/rectangle-diagram.png b/ja-JP/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/ja-JP/images/rectangle-diagram.png differ diff --git a/ja-JP/images/showcase_rocket.png b/ja-JP/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/ja-JP/images/showcase_rocket.png differ diff --git a/ja-JP/images/showcase_static.png b/ja-JP/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/ja-JP/images/showcase_static.png differ diff --git a/ja-JP/images/sky_coords.png b/ja-JP/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/ja-JP/images/sky_coords.png differ diff --git a/ja-JP/images/sky_stroke.png b/ja-JP/images/sky_stroke.png new file mode 100644 index 000000000..0d088147f Binary files /dev/null and b/ja-JP/images/sky_stroke.png differ diff --git a/ja-JP/images/stand_coords.png b/ja-JP/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/ja-JP/images/stand_coords.png differ diff --git a/ja-JP/images/step_4_preview.gif b/ja-JP/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/ja-JP/images/step_4_preview.gif differ diff --git a/ja-JP/images/step_5_preview.gif b/ja-JP/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/ja-JP/images/step_5_preview.gif differ diff --git a/ja-JP/images/target-stand.png b/ja-JP/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/ja-JP/images/target-stand.png differ diff --git a/ja-JP/images/target_area.png b/ja-JP/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/ja-JP/images/target_area.png differ diff --git a/ja-JP/images/target_printed.gif b/ja-JP/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/ja-JP/images/target_printed.gif differ diff --git a/ja-JP/images/three-circles.png b/ja-JP/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/ja-JP/images/three-circles.png differ diff --git a/ja-JP/images/top-left.png b/ja-JP/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/ja-JP/images/top-left.png differ diff --git a/ja-JP/images/triangles-coords.png b/ja-JP/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/ja-JP/images/triangles-coords.png differ diff --git a/ja-JP/images/upgrade-ideas.png b/ja-JP/images/upgrade-ideas.png new file mode 100644 index 000000000..c41716841 Binary files /dev/null and b/ja-JP/images/upgrade-ideas.png differ diff --git a/ja-JP/images/yellow-points.png b/ja-JP/images/yellow-points.png new file mode 100644 index 000000000..54362678c Binary files /dev/null and b/ja-JP/images/yellow-points.png differ diff --git a/ja-JP/meta.yml b/ja-JP/meta.yml new file mode 100644 index 000000000..60ca5f5a9 --- /dev/null +++ b/ja-JP/meta.yml @@ -0,0 +1,41 @@ +--- +title: 射的 +hero_image: images/banner.png +description: Pythonでターゲットを描き、矢を当てて得点を表示します +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: はじめに + - + title: 背景を作成する + - + title: ターゲットを描く + completion: + - engaged + - + title: 矢を放つ + - + title: 得点 + - + title: ふりかえり + completion: + - external + - + title: プロジェクトをアップグレードする + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: 次は何をしますか? + challenge: true + - + title: What can you do now? diff --git a/ja-JP/python-comments-demo.txt b/ja-JP/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/ja-JP/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/ja-JP/python-comments.txt b/ja-JP/python-comments.txt new file mode 100644 index 000000000..4a1124176 --- /dev/null +++ b/ja-JP/python-comments.txt @@ -0,0 +1,27 @@ +すべてのフレームで行うこと + +Draw the inner circle + +Draw the middle circle + +shoot_arrow関数はここにあります + +mouse_pressed関数はここにあります + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/ja-JP/python-translatable-demo.txt b/ja-JP/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/ja-JP/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/ja-JP/python-translatable.txt b/ja-JP/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/ja-JP/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/ja-JP/quiz1/question_1.md b/ja-JP/quiz1/question_1.md new file mode 100644 index 000000000..b7bb3efb6 --- /dev/null +++ b/ja-JP/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +各質問の後、**ボタン**を押してください。 正しい答えが表示されます。 + +お楽しみください! + +--- question --- +--- +legend: 質問1/3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ja-JP/quiz1/question_2.md b/ja-JP/quiz1/question_2.md new file mode 100644 index 000000000..8f10468eb --- /dev/null +++ b/ja-JP/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: 質問2/3 +--- + +あなたのプロジェクトでは、`if` , `elif`, `else`条件を使って、矢がどの色に着地したかをチェックしましたね。 + +In the example below, a variable called `speed` has the number `6` stored in it. このコードを実行すると、出力領域には何が表示されるでしょうか? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('超高速') elif speed == 5: print('かなり速い') elif speed == 6: print('非常に速い') else: print('速度が認識されない! ') + +--- /code --- + +--- choices --- + +- (x)`非常に速い` + + --- feedback --- + + そのとおりです! **speed**変数に`6`という値が代入され、`speed == 6`という条件が**True**となり、`非常に速い`と表示されます。 + + --- /feedback --- + +- ( ) `速度が認識されない!` + + --- feedback --- + + ちょっと違います、**speed**変数に割り当てられている値を見てください。 + + --- /feedback --- + +- ( ) 何も表示されない + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ja-JP/quiz1/question_3.md b/ja-JP/quiz1/question_3.md new file mode 100644 index 000000000..7e14f0806 --- /dev/null +++ b/ja-JP/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: 質問3/3 +--- + +次のコードで楕円を描画します。 + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0,255,0) +no_stroke() + +def draw(): +ellipse(0,0,300,300) + +run() + +--- /code --- + +次の画像のうち、出力領域でのこの楕円の正しい位置を示しているのはどれですか? + +--- choices --- + +- ( ) ![出力領域の右下隅の中央にある緑色の円。](images/bottom-right.png) + + --- feedback --- + + ちょっと違います、右下の円を中央に配置するには、画面サイズと同じ座標にする必要があります。 この例では、楕円は `ellipse(400,400,300,300)`になります。 + + --- /feedback --- + +- ( ) ![出力領域の中央にある緑色の円。](images/centre.png) + + --- feedback --- + + ちょっと違います、円を中央に配置するためには、座標が画面サイズの半分になる必要があるのです。 この例では、 `ellipse(200,200,300,300)`です。 + + --- /feedback --- + +- (x) ![出力領域の左上隅の中央にある緑色の円。](images/top-left.png) + + --- feedback --- + + そのとおりです! この円の中心は、画面の左上隅の座標(0,0) です。 + + --- /feedback --- + +- ( ) ![出力領域の右上に向かって中央に配置された緑色の円。](images/random-side.png) + + --- feedback --- + + いいえ、この円のコードは `ellipse(350,150,300,300)` で、画面の右上に向かって中央に配置されます。 `x`座標は楕円が画面の横方向にどれだけあるか、`y`座標は画面の下方向にどれだけあるかを示しています。 + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ja-JP/resources/main.py b/ja-JP/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/ja-JP/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/ja-JP/resources/p5.py b/ja-JP/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/ja-JP/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/ja-JP/step_1.md b/ja-JP/step_1.md new file mode 100644 index 000000000..330dd27eb --- /dev/null +++ b/ja-JP/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Pythonと`p5`グラフィックスライブラリを使って、ターゲットを描き、そこに矢を当てて得点を表示するゲームを作成します。 + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +下の**Run**ボタンをクリックするとゲームが開始されます。 ターゲットに点が表示されたら、マウスをクリック(タブレットではタップ) して矢を放ちます。 + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/ja-JP/step_2.md b/ja-JP/step_2.md new file mode 100644 index 000000000..101f1c3e3 --- /dev/null +++ b/ja-JP/step_2.md @@ -0,0 +1,37 @@ +## Draw the grass + +--- task --- + +[アーチェリースターター](https://trinket.io/python/cbf88a8458){:target="_blank"}プロジェクトを開く。 + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png)`fill()`のコードの後に、`rect()`を左上の座標(`0`,`0`) に合わせて、幅`400`、高さ`250`で描画します。 + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 18 +line_highlights: 25 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**テスト:** プロジェクトを再度実行して、完成した背景を表示します。 + +![![草色の長方形の上に空色の長方形がある出力領域で、背景を作成する。](images/background.png)`setup()`内の`size()`関数呼び出しで、画面サイズを400ピクセル×400ピクセルに設定しています。 + +--- /task --- + +--- save --- diff --git a/ja-JP/step_3.md b/ja-JP/step_3.md new file mode 100644 index 000000000..0638e5739 --- /dev/null +++ b/ja-JP/step_3.md @@ -0,0 +1,110 @@ +## ターゲットを描く + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![ターゲットとスタンドのある出力エリア。](images/three-circles.png){:width="300px"} + +
+
+ +### スタンドを描く + +--- task --- + +Set the fill colour to `brown`. + +ここでは、それぞれ異なる座標を持つ3つの三角形の例を示します。 + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 18 +line_highlights: 24-25 +--- + + fill(wood) #スタンドフィルカラーをブラウンに設定
+ triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**テスト:** コードを実行して、ターゲットのスタンドを確認します。 + +![草の上と空を背景にした茶色の三角形。](images/target-stand.png){:width="400px"} + +--- /task --- + +### ターゲットを描く + +--- task --- + +**ヒント:**円を作るには、**幅**と**高さ**が同じである必要があります。 + +Set the fill colour to `blue`. + +Draw a circle with x and y coordinates for its centre and a width. + +![草原と空に描かれた茶色の三角形とその座標点。 The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 31-32 +--- + + 茶色の三角形:triangle(50, 150, 200, 250, 180, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** コードを実行すると、最初の大きな青い丸が表示されます。 + +青い丸は、後から描いたものなので、茶色の三角が重なる部分を覆います。 + +![草の上と空を背景にした茶色の三角形と青い円。](images/blue-circle.png){:width="400px"} + +--- /task --- + +ターゲットは、同じ中心座標(200, 200)、つまり画面の真ん中にある、大きさの異なる円でできています。 + +--- task --- + +**Test:** プロジェクトを再度実行すると、ターゲットに3色の丸が表示されます。 + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 28 +line_highlights: 33-34 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**デバッグ:** Python は 'color' のアメリカ綴り('u' がない) を使うので、同じようにしてください。 + +![草の上と空を背景に3色の円が描かれた茶色の三角形。](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/ja-JP/step_4.md b/ja-JP/step_4.md new file mode 100644 index 000000000..8dc8d3c01 --- /dev/null +++ b/ja-JP/step_4.md @@ -0,0 +1,95 @@ +## 矢を放つ + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![茶色の丸い矢が様々な位置に現れるターゲット。](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11-12 +--- +# shoot_arrow関数はここにあります +def shoot_arrow(): +global hit_color #他の機能でも使用可能 +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) #矢を描く前に色を保存する +ellipse(arrow_x, arrow_y, 15, 15) + +--- /code --- + +--- /task --- + +--- task --- + +ターゲットを作成する `draw()`コードに移動して、`fill()`を `wood`に設定するコードを最後に追加し、新しい `shoot_arrow()` 関数を呼び出します。 + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 41 +line_highlights: 44-45 +--- + + def shoot_arrow():
+ ellipse(200, 200, 15, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**テスト:**コードを実行し、矢がブルズアイに表示されることを確認します。 矢印はランダムな座標で再描画されます。 + +![背景のターゲットに茶色の丸い矢印が描かれている。](images/arrow-centre.png) + + +--- /task --- + +矢印はランダムな座標で再描画されます。 + + +--- task --- + +`shoot_arrow()`関数に行き、`arrow_x`と`arrow_y`の2つの新しい変数を追加して、`100`から`300`までの乱数を格納します。 + +--- code --- +--- +language: python filename: main.py line_numbers: true +line_highlights: 9-10 +--- +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) #矢印を描く前に色を保存する +ellipse(arrow_x, arrow_y, 15, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**テスト:** プロジェクトを実行します。 You should see the arrow jump around the target. + +![さまざまな位置に茶色の円の矢印が表示されているターゲット。](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/ja-JP/step_5.md b/ja-JP/step_5.md new file mode 100644 index 000000000..86cb246fe --- /dev/null +++ b/ja-JP/step_5.md @@ -0,0 +1,82 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +は**代入**に使用されます - `arrow_x = 200`のように、変数の値を設定します。 + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 9 +line_highlights: 28 +--- +def mouse_pressed(): +if hit_color == outer: +print('外側の円に当たった、50点! ') +elif hit_color == inner: +print('内側の円に当たった、 200点! + +--- /code --- + +は**同値**をテストするために使われます - `hit_color == bullseye` のように - もしどちらかの側のものが同じ値であれば、テストは`真`、そうでない場合`偽`になります。 + +--- /task --- + +--- task --- + +**テスト:**プロジェクトを実行します。 赤と黄色の円に矢を止めて、そのメッセージを確認してください。 + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 10-11 +--- + + def mouse_pressed():
+ if hit_color == outer:
+ print('外側の円にあたった, 50点!') + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 12-15 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**テスト:**プロジェクトを実行します。 You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/ja-JP/step_6.md b/ja-JP/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/ja-JP/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/ja-JP/step_7.md b/ja-JP/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/ja-JP/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/ja-JP/step_8.md b/ja-JP/step_8.md new file mode 100644 index 000000000..28ae6e382 --- /dev/null +++ b/ja-JP/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /no-print --- diff --git a/ja-JP/step_9.md b/ja-JP/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/ja-JP/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/kn-IN/code/target-practice-solution/main.py b/kn-IN/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/kn-IN/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/kn-IN/code/target-practice-solution/project_config.yml b/kn-IN/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/kn-IN/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/kn-IN/code/target-practice-starter/main.py b/kn-IN/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/kn-IN/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/kn-IN/code/target-practice-starter/project_config.yml b/kn-IN/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/kn-IN/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/kn-IN/images/alternative-colours.png b/kn-IN/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/kn-IN/images/alternative-colours.png differ diff --git a/kn-IN/images/animation_bg_erase.gif b/kn-IN/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/kn-IN/images/animation_bg_erase.gif differ diff --git a/kn-IN/images/animation_no_bg_erase.gif b/kn-IN/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/kn-IN/images/animation_no_bg_erase.gif differ diff --git a/kn-IN/images/arrow-centre.png b/kn-IN/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/kn-IN/images/arrow-centre.png differ diff --git a/kn-IN/images/arrow-middle.png b/kn-IN/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/kn-IN/images/arrow-middle.png differ diff --git a/kn-IN/images/arrow-target.png b/kn-IN/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/kn-IN/images/arrow-target.png differ diff --git a/kn-IN/images/background.png b/kn-IN/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/kn-IN/images/background.png differ diff --git a/kn-IN/images/banner.png b/kn-IN/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/kn-IN/images/banner.png differ diff --git a/kn-IN/images/blue-circle.png b/kn-IN/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/kn-IN/images/blue-circle.png differ diff --git a/kn-IN/images/blue-points.png b/kn-IN/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/kn-IN/images/blue-points.png differ diff --git a/kn-IN/images/blue_circle_points.gif b/kn-IN/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/kn-IN/images/blue_circle_points.gif differ diff --git a/kn-IN/images/bottom-right.png b/kn-IN/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/kn-IN/images/bottom-right.png differ diff --git a/kn-IN/images/centre.png b/kn-IN/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/kn-IN/images/centre.png differ diff --git a/kn-IN/images/circle-coords.png b/kn-IN/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/kn-IN/images/circle-coords.png differ diff --git a/kn-IN/images/coords_animation.gif b/kn-IN/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/kn-IN/images/coords_animation.gif differ diff --git a/kn-IN/images/difficulty-setting.png b/kn-IN/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/kn-IN/images/difficulty-setting.png differ diff --git a/kn-IN/images/fire_arrow.gif b/kn-IN/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/kn-IN/images/fire_arrow.gif differ diff --git a/kn-IN/images/five_circles.png b/kn-IN/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/kn-IN/images/five_circles.png differ diff --git a/kn-IN/images/green-grass.png b/kn-IN/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/kn-IN/images/green-grass.png differ diff --git a/kn-IN/images/grey-circle.png b/kn-IN/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/kn-IN/images/grey-circle.png differ diff --git a/kn-IN/images/grey-points.png b/kn-IN/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/kn-IN/images/grey-points.png differ diff --git a/kn-IN/images/initial_target.png b/kn-IN/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/kn-IN/images/initial_target.png differ diff --git a/kn-IN/images/missed-points.png b/kn-IN/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/kn-IN/images/missed-points.png differ diff --git a/kn-IN/images/missed_no_points.gif b/kn-IN/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/kn-IN/images/missed_no_points.gif differ diff --git a/kn-IN/images/outline-circles.png b/kn-IN/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/kn-IN/images/outline-circles.png differ diff --git a/kn-IN/images/points-scored.gif b/kn-IN/images/points-scored.gif new file mode 100644 index 000000000..3fbe161a8 Binary files /dev/null and b/kn-IN/images/points-scored.gif differ diff --git a/kn-IN/images/quiz-colour.png b/kn-IN/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/kn-IN/images/quiz-colour.png differ diff --git a/kn-IN/images/random-side.png b/kn-IN/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/kn-IN/images/random-side.png differ diff --git a/kn-IN/images/rectangle-diagram.png b/kn-IN/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/kn-IN/images/rectangle-diagram.png differ diff --git a/kn-IN/images/showcase_rocket.png b/kn-IN/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/kn-IN/images/showcase_rocket.png differ diff --git a/kn-IN/images/showcase_static.png b/kn-IN/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/kn-IN/images/showcase_static.png differ diff --git a/kn-IN/images/sky_coords.png b/kn-IN/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/kn-IN/images/sky_coords.png differ diff --git a/kn-IN/images/sky_stroke.png b/kn-IN/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/kn-IN/images/sky_stroke.png differ diff --git a/kn-IN/images/stand_coords.png b/kn-IN/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/kn-IN/images/stand_coords.png differ diff --git a/kn-IN/images/step_4_preview.gif b/kn-IN/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/kn-IN/images/step_4_preview.gif differ diff --git a/kn-IN/images/step_5_preview.gif b/kn-IN/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/kn-IN/images/step_5_preview.gif differ diff --git a/kn-IN/images/target-stand.png b/kn-IN/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/kn-IN/images/target-stand.png differ diff --git a/kn-IN/images/target_area.png b/kn-IN/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/kn-IN/images/target_area.png differ diff --git a/kn-IN/images/target_printed.gif b/kn-IN/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/kn-IN/images/target_printed.gif differ diff --git a/kn-IN/images/three-circles.png b/kn-IN/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/kn-IN/images/three-circles.png differ diff --git a/kn-IN/images/top-left.png b/kn-IN/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/kn-IN/images/top-left.png differ diff --git a/kn-IN/images/triangles-coords.png b/kn-IN/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/kn-IN/images/triangles-coords.png differ diff --git a/kn-IN/images/upgrade-ideas.png b/kn-IN/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/kn-IN/images/upgrade-ideas.png differ diff --git a/kn-IN/images/yellow-points.png b/kn-IN/images/yellow-points.png new file mode 100644 index 000000000..0c461812c Binary files /dev/null and b/kn-IN/images/yellow-points.png differ diff --git a/kn-IN/meta.yml b/kn-IN/meta.yml new file mode 100644 index 000000000..e56ce34a6 --- /dev/null +++ b/kn-IN/meta.yml @@ -0,0 +1,41 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: What you will make + - + title: Draw the grass + - + title: Draw your target + completion: + - engaged + - + title: Add an arrow + - + title: What colour did you hit? + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Challenge + challenge: true + - + title: What can you do now? diff --git a/kn-IN/python-comments-demo.txt b/kn-IN/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/kn-IN/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/kn-IN/python-comments.txt b/kn-IN/python-comments.txt new file mode 100644 index 000000000..35750f346 --- /dev/null +++ b/kn-IN/python-comments.txt @@ -0,0 +1,27 @@ +Things to do in every frame + +Draw the inner circle + +Draw the middle circle + +The shoot_arrow function goes here + +The mouse_pressed function goes here + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/kn-IN/python-translatable-demo.txt b/kn-IN/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/kn-IN/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/kn-IN/python-translatable.txt b/kn-IN/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/kn-IN/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/kn-IN/quiz1/question_1.md b/kn-IN/quiz1/question_1.md new file mode 100644 index 000000000..631f7888a --- /dev/null +++ b/kn-IN/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +ವಿಷಯಸೂಚಿ: ಪ್ರಶ್ನೆ 1 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/kn-IN/quiz1/question_2.md b/kn-IN/quiz1/question_2.md new file mode 100644 index 000000000..1a96cdca3 --- /dev/null +++ b/kn-IN/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +ವಿಷಯಸೂಚಿ: ಪ್ರಶ್ನೆ 2 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/kn-IN/quiz1/question_3.md b/kn-IN/quiz1/question_3.md new file mode 100644 index 000000000..9c27bd32b --- /dev/null +++ b/kn-IN/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +ವಿಷಯಸೂಚಿ: ಪ್ರಶ್ನೆ 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/kn-IN/resources/main.py b/kn-IN/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/kn-IN/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/kn-IN/resources/p5.py b/kn-IN/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/kn-IN/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/kn-IN/step_1.md b/kn-IN/step_1.md new file mode 100644 index 000000000..e3a8012cf --- /dev/null +++ b/kn-IN/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Use Python to draw a target and score points by hitting it with arrows. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/kn-IN/step_2.md b/kn-IN/step_2.md new file mode 100644 index 000000000..919a62214 --- /dev/null +++ b/kn-IN/step_2.md @@ -0,0 +1,37 @@ +## Draw the grass + +--- task --- + +Open the [Target practice starter](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"} project. + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to view the background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/kn-IN/step_3.md b/kn-IN/step_3.md new file mode 100644 index 000000000..c0895baaf --- /dev/null +++ b/kn-IN/step_3.md @@ -0,0 +1,115 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `brown`. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `blue`. + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/kn-IN/step_4.md b/kn-IN/step_4.md new file mode 100644 index 000000000..0e4f7b007 --- /dev/null +++ b/kn-IN/step_4.md @@ -0,0 +1,88 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![An animation of target with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/kn-IN/step_5.md b/kn-IN/step_5.md new file mode 100644 index 000000000..2933b68ca --- /dev/null +++ b/kn-IN/step_5.md @@ -0,0 +1,80 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/kn-IN/step_6.md b/kn-IN/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/kn-IN/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/kn-IN/step_7.md b/kn-IN/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/kn-IN/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/kn-IN/step_8.md b/kn-IN/step_8.md new file mode 100644 index 000000000..910635d28 --- /dev/null +++ b/kn-IN/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/kn-IN/step_9.md b/kn-IN/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/kn-IN/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/mr-IN/code/target-practice-solution/main.py b/mr-IN/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/mr-IN/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/mr-IN/code/target-practice-solution/project_config.yml b/mr-IN/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/mr-IN/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/mr-IN/code/target-practice-starter/main.py b/mr-IN/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/mr-IN/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/mr-IN/code/target-practice-starter/project_config.yml b/mr-IN/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/mr-IN/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/mr-IN/images/alternative-colours.png b/mr-IN/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/mr-IN/images/alternative-colours.png differ diff --git a/mr-IN/images/animation_bg_erase.gif b/mr-IN/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/mr-IN/images/animation_bg_erase.gif differ diff --git a/mr-IN/images/animation_no_bg_erase.gif b/mr-IN/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/mr-IN/images/animation_no_bg_erase.gif differ diff --git a/mr-IN/images/arrow-centre.png b/mr-IN/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/mr-IN/images/arrow-centre.png differ diff --git a/mr-IN/images/arrow-middle.png b/mr-IN/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/mr-IN/images/arrow-middle.png differ diff --git a/mr-IN/images/arrow-target.png b/mr-IN/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/mr-IN/images/arrow-target.png differ diff --git a/mr-IN/images/background.png b/mr-IN/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/mr-IN/images/background.png differ diff --git a/mr-IN/images/banner.png b/mr-IN/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/mr-IN/images/banner.png differ diff --git a/mr-IN/images/blue-circle.png b/mr-IN/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/mr-IN/images/blue-circle.png differ diff --git a/mr-IN/images/blue-points.png b/mr-IN/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/mr-IN/images/blue-points.png differ diff --git a/mr-IN/images/blue_circle_points.gif b/mr-IN/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/mr-IN/images/blue_circle_points.gif differ diff --git a/mr-IN/images/bottom-right.png b/mr-IN/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/mr-IN/images/bottom-right.png differ diff --git a/mr-IN/images/centre.png b/mr-IN/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/mr-IN/images/centre.png differ diff --git a/mr-IN/images/circle-coords.png b/mr-IN/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/mr-IN/images/circle-coords.png differ diff --git a/mr-IN/images/coords_animation.gif b/mr-IN/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/mr-IN/images/coords_animation.gif differ diff --git a/mr-IN/images/difficulty-setting.png b/mr-IN/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/mr-IN/images/difficulty-setting.png differ diff --git a/mr-IN/images/fire_arrow.gif b/mr-IN/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/mr-IN/images/fire_arrow.gif differ diff --git a/mr-IN/images/five_circles.png b/mr-IN/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/mr-IN/images/five_circles.png differ diff --git a/mr-IN/images/green-grass.png b/mr-IN/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/mr-IN/images/green-grass.png differ diff --git a/mr-IN/images/grey-circle.png b/mr-IN/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/mr-IN/images/grey-circle.png differ diff --git a/mr-IN/images/grey-points.png b/mr-IN/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/mr-IN/images/grey-points.png differ diff --git a/mr-IN/images/initial_target.png b/mr-IN/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/mr-IN/images/initial_target.png differ diff --git a/mr-IN/images/missed-points.png b/mr-IN/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/mr-IN/images/missed-points.png differ diff --git a/mr-IN/images/missed_no_points.gif b/mr-IN/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/mr-IN/images/missed_no_points.gif differ diff --git a/mr-IN/images/outline-circles.png b/mr-IN/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/mr-IN/images/outline-circles.png differ diff --git a/mr-IN/images/points-scored.gif b/mr-IN/images/points-scored.gif new file mode 100644 index 000000000..3fbe161a8 Binary files /dev/null and b/mr-IN/images/points-scored.gif differ diff --git a/mr-IN/images/quiz-colour.png b/mr-IN/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/mr-IN/images/quiz-colour.png differ diff --git a/mr-IN/images/random-side.png b/mr-IN/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/mr-IN/images/random-side.png differ diff --git a/mr-IN/images/rectangle-diagram.png b/mr-IN/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/mr-IN/images/rectangle-diagram.png differ diff --git a/mr-IN/images/showcase_rocket.png b/mr-IN/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/mr-IN/images/showcase_rocket.png differ diff --git a/mr-IN/images/showcase_static.png b/mr-IN/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/mr-IN/images/showcase_static.png differ diff --git a/mr-IN/images/sky_coords.png b/mr-IN/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/mr-IN/images/sky_coords.png differ diff --git a/mr-IN/images/sky_stroke.png b/mr-IN/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/mr-IN/images/sky_stroke.png differ diff --git a/mr-IN/images/stand_coords.png b/mr-IN/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/mr-IN/images/stand_coords.png differ diff --git a/mr-IN/images/step_4_preview.gif b/mr-IN/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/mr-IN/images/step_4_preview.gif differ diff --git a/mr-IN/images/step_5_preview.gif b/mr-IN/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/mr-IN/images/step_5_preview.gif differ diff --git a/mr-IN/images/target-stand.png b/mr-IN/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/mr-IN/images/target-stand.png differ diff --git a/mr-IN/images/target_area.png b/mr-IN/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/mr-IN/images/target_area.png differ diff --git a/mr-IN/images/target_printed.gif b/mr-IN/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/mr-IN/images/target_printed.gif differ diff --git a/mr-IN/images/three-circles.png b/mr-IN/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/mr-IN/images/three-circles.png differ diff --git a/mr-IN/images/top-left.png b/mr-IN/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/mr-IN/images/top-left.png differ diff --git a/mr-IN/images/triangles-coords.png b/mr-IN/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/mr-IN/images/triangles-coords.png differ diff --git a/mr-IN/images/upgrade-ideas.png b/mr-IN/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/mr-IN/images/upgrade-ideas.png differ diff --git a/mr-IN/images/yellow-points.png b/mr-IN/images/yellow-points.png new file mode 100644 index 000000000..0c461812c Binary files /dev/null and b/mr-IN/images/yellow-points.png differ diff --git a/mr-IN/meta.yml b/mr-IN/meta.yml new file mode 100644 index 000000000..e56ce34a6 --- /dev/null +++ b/mr-IN/meta.yml @@ -0,0 +1,41 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: What you will make + - + title: Draw the grass + - + title: Draw your target + completion: + - engaged + - + title: Add an arrow + - + title: What colour did you hit? + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Challenge + challenge: true + - + title: What can you do now? diff --git a/mr-IN/python-comments-demo.txt b/mr-IN/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/mr-IN/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/mr-IN/python-comments.txt b/mr-IN/python-comments.txt new file mode 100644 index 000000000..35750f346 --- /dev/null +++ b/mr-IN/python-comments.txt @@ -0,0 +1,27 @@ +Things to do in every frame + +Draw the inner circle + +Draw the middle circle + +The shoot_arrow function goes here + +The mouse_pressed function goes here + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/mr-IN/python-translatable-demo.txt b/mr-IN/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/mr-IN/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/mr-IN/python-translatable.txt b/mr-IN/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/mr-IN/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/mr-IN/quiz1/question_1.md b/mr-IN/quiz1/question_1.md new file mode 100644 index 000000000..edbef020a --- /dev/null +++ b/mr-IN/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: प्रश्न 3 पैकी 1 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/mr-IN/quiz1/question_2.md b/mr-IN/quiz1/question_2.md new file mode 100644 index 000000000..4824cfb72 --- /dev/null +++ b/mr-IN/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: प्रश्न 3 पैकी 2 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/mr-IN/quiz1/question_3.md b/mr-IN/quiz1/question_3.md new file mode 100644 index 000000000..13e9cc0f6 --- /dev/null +++ b/mr-IN/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: प्रश्न 3 पैकी 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/mr-IN/resources/main.py b/mr-IN/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/mr-IN/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/mr-IN/resources/p5.py b/mr-IN/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/mr-IN/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/mr-IN/step_1.md b/mr-IN/step_1.md new file mode 100644 index 000000000..e3a8012cf --- /dev/null +++ b/mr-IN/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Use Python to draw a target and score points by hitting it with arrows. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/mr-IN/step_2.md b/mr-IN/step_2.md new file mode 100644 index 000000000..919a62214 --- /dev/null +++ b/mr-IN/step_2.md @@ -0,0 +1,37 @@ +## Draw the grass + +--- task --- + +Open the [Target practice starter](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"} project. + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to view the background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/mr-IN/step_3.md b/mr-IN/step_3.md new file mode 100644 index 000000000..c0895baaf --- /dev/null +++ b/mr-IN/step_3.md @@ -0,0 +1,115 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `brown`. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `blue`. + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/mr-IN/step_4.md b/mr-IN/step_4.md new file mode 100644 index 000000000..0e4f7b007 --- /dev/null +++ b/mr-IN/step_4.md @@ -0,0 +1,88 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![An animation of target with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/mr-IN/step_5.md b/mr-IN/step_5.md new file mode 100644 index 000000000..2933b68ca --- /dev/null +++ b/mr-IN/step_5.md @@ -0,0 +1,80 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/mr-IN/step_6.md b/mr-IN/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/mr-IN/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/mr-IN/step_7.md b/mr-IN/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/mr-IN/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/mr-IN/step_8.md b/mr-IN/step_8.md new file mode 100644 index 000000000..910635d28 --- /dev/null +++ b/mr-IN/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/mr-IN/step_9.md b/mr-IN/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/mr-IN/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/nl-NL/code/target-practice-solution/main.py b/nl-NL/code/target-practice-solution/main.py new file mode 100644 index 000000000..31763538a --- /dev/null +++ b/nl-NL/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +# Bibliotheekcode importeren! + +from p5 import * +from random import randint + + +# De mouse_pressed functie komt hier +def mouse_pressed(): + # print('🎯') + if raak_kleur == Color("blue").hex: + print("Je hebt de buitenste cirkel geraakt, 50 punten!") + elif raak_kleur == Color("red").hex: + print("Je hebt de binnenste cirkel geraakt, 200 punten!") + elif raak_kleur == Color("yellow").hex: + print("In de roos, 500 punten!") + else: + print("Je hebt gemist! Geen punten!") + + +# De schiet_pijl functie komt hier +def schiet_pijl(): + global raak_kleur + pijl_x = randint(100, 300) + pijl_y = randint(100, 300) + raak_kleur = get(pijl_x, pijl_y).hex + # print(raak_kleur) + fill("brown") + circle(pijl_x, pijl_y, 15) + + +def setup(): + # Stel je spel hier in + size(400, 400) + no_stroke() + + +def draw(): + # Dingen om te doen in elk frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Binnenste cirkel + fill("yellow") + circle(200, 200, 30) # Middelste cirkel + schiet_pijl() + + +# Bewaar dit om je code uit te voeren +run(frame_rate=2) diff --git a/nl-NL/code/target-practice-solution/project_config.yml b/nl-NL/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..85cfec00f --- /dev/null +++ b/nl-NL/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Voorbeeld Oefening doelwit schieten' +identifier: 'target-practice-solution' +type: 'python' diff --git a/nl-NL/code/target-practice-starter/main.py b/nl-NL/code/target-practice-starter/main.py new file mode 100644 index 000000000..916b0dce1 --- /dev/null +++ b/nl-NL/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +# Bibliotheekcode importeren +from p5 import * +from random import randint + +# De mouse_pressed functie komt hier + + +# De schiet_pijl functie komt hier + + +def setup(): + # Stel je spel hier in + size(400, 400) + no_stroke() + + +def draw(): + # Dingen om te doen in elk frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Bewaar dit om je code uit te voeren +run(frame_rate=2) diff --git a/nl-NL/code/target-practice-starter/project_config.yml b/nl-NL/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..0e7e4b860 --- /dev/null +++ b/nl-NL/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Oefening doelwit schieten" +identifier: 'target-practice-starter' +type: 'python' diff --git a/nl-NL/images/alternative-colours.png b/nl-NL/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/nl-NL/images/alternative-colours.png differ diff --git a/nl-NL/images/animation_bg_erase.gif b/nl-NL/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/nl-NL/images/animation_bg_erase.gif differ diff --git a/nl-NL/images/animation_no_bg_erase.gif b/nl-NL/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/nl-NL/images/animation_no_bg_erase.gif differ diff --git a/nl-NL/images/arrow-centre.png b/nl-NL/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/nl-NL/images/arrow-centre.png differ diff --git a/nl-NL/images/arrow-middle.png b/nl-NL/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/nl-NL/images/arrow-middle.png differ diff --git a/nl-NL/images/arrow-target.png b/nl-NL/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/nl-NL/images/arrow-target.png differ diff --git a/nl-NL/images/background.png b/nl-NL/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/nl-NL/images/background.png differ diff --git a/nl-NL/images/banner.png b/nl-NL/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/nl-NL/images/banner.png differ diff --git a/nl-NL/images/blue-circle.png b/nl-NL/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/nl-NL/images/blue-circle.png differ diff --git a/nl-NL/images/blue-points.png b/nl-NL/images/blue-points.png new file mode 100644 index 000000000..9e0e73ff9 Binary files /dev/null and b/nl-NL/images/blue-points.png differ diff --git a/nl-NL/images/blue_circle_points.gif b/nl-NL/images/blue_circle_points.gif new file mode 100644 index 000000000..086b59da7 Binary files /dev/null and b/nl-NL/images/blue_circle_points.gif differ diff --git a/nl-NL/images/bottom-right.png b/nl-NL/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/nl-NL/images/bottom-right.png differ diff --git a/nl-NL/images/centre.png b/nl-NL/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/nl-NL/images/centre.png differ diff --git a/nl-NL/images/circle-coords.png b/nl-NL/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/nl-NL/images/circle-coords.png differ diff --git a/nl-NL/images/coords_animation.gif b/nl-NL/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/nl-NL/images/coords_animation.gif differ diff --git a/nl-NL/images/difficulty-setting.png b/nl-NL/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/nl-NL/images/difficulty-setting.png differ diff --git a/nl-NL/images/fire_arrow.gif b/nl-NL/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/nl-NL/images/fire_arrow.gif differ diff --git a/nl-NL/images/five_circles.png b/nl-NL/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/nl-NL/images/five_circles.png differ diff --git a/nl-NL/images/green-grass.png b/nl-NL/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/nl-NL/images/green-grass.png differ diff --git a/nl-NL/images/grey-circle.png b/nl-NL/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/nl-NL/images/grey-circle.png differ diff --git a/nl-NL/images/grey-points.png b/nl-NL/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/nl-NL/images/grey-points.png differ diff --git a/nl-NL/images/initial_target.png b/nl-NL/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/nl-NL/images/initial_target.png differ diff --git a/nl-NL/images/missed-points.png b/nl-NL/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/nl-NL/images/missed-points.png differ diff --git a/nl-NL/images/missed_no_points.gif b/nl-NL/images/missed_no_points.gif new file mode 100644 index 000000000..b4ce1d3d8 Binary files /dev/null and b/nl-NL/images/missed_no_points.gif differ diff --git a/nl-NL/images/outline-circles.png b/nl-NL/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/nl-NL/images/outline-circles.png differ diff --git a/nl-NL/images/points-scored.gif b/nl-NL/images/points-scored.gif new file mode 100644 index 000000000..a45594896 Binary files /dev/null and b/nl-NL/images/points-scored.gif differ diff --git a/nl-NL/images/quiz-colour.png b/nl-NL/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/nl-NL/images/quiz-colour.png differ diff --git a/nl-NL/images/random-side.png b/nl-NL/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/nl-NL/images/random-side.png differ diff --git a/nl-NL/images/rectangle-diagram.png b/nl-NL/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/nl-NL/images/rectangle-diagram.png differ diff --git a/nl-NL/images/showcase_rocket.png b/nl-NL/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/nl-NL/images/showcase_rocket.png differ diff --git a/nl-NL/images/showcase_static.png b/nl-NL/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/nl-NL/images/showcase_static.png differ diff --git a/nl-NL/images/sky_coords.png b/nl-NL/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/nl-NL/images/sky_coords.png differ diff --git a/nl-NL/images/sky_stroke.png b/nl-NL/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/nl-NL/images/sky_stroke.png differ diff --git a/nl-NL/images/stand_coords.png b/nl-NL/images/stand_coords.png new file mode 100644 index 000000000..98550a379 Binary files /dev/null and b/nl-NL/images/stand_coords.png differ diff --git a/nl-NL/images/step_4_preview.gif b/nl-NL/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/nl-NL/images/step_4_preview.gif differ diff --git a/nl-NL/images/step_5_preview.gif b/nl-NL/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/nl-NL/images/step_5_preview.gif differ diff --git a/nl-NL/images/target-stand.png b/nl-NL/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/nl-NL/images/target-stand.png differ diff --git a/nl-NL/images/target_area.png b/nl-NL/images/target_area.png new file mode 100644 index 000000000..c6633448f Binary files /dev/null and b/nl-NL/images/target_area.png differ diff --git a/nl-NL/images/target_printed.gif b/nl-NL/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/nl-NL/images/target_printed.gif differ diff --git a/nl-NL/images/three-circles.png b/nl-NL/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/nl-NL/images/three-circles.png differ diff --git a/nl-NL/images/top-left.png b/nl-NL/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/nl-NL/images/top-left.png differ diff --git a/nl-NL/images/triangles-coords.png b/nl-NL/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/nl-NL/images/triangles-coords.png differ diff --git a/nl-NL/images/upgrade-ideas.png b/nl-NL/images/upgrade-ideas.png new file mode 100644 index 000000000..16d7d8079 Binary files /dev/null and b/nl-NL/images/upgrade-ideas.png differ diff --git a/nl-NL/images/yellow-points.png b/nl-NL/images/yellow-points.png new file mode 100644 index 000000000..dc0315ac4 Binary files /dev/null and b/nl-NL/images/yellow-points.png differ diff --git a/nl-NL/meta.yml b/nl-NL/meta.yml new file mode 100644 index 000000000..db79a8faf --- /dev/null +++ b/nl-NL/meta.yml @@ -0,0 +1,41 @@ +--- +title: Oefening doelwit schieten +hero_image: images/banner.png +description: Gebruik Python om een doel te tekenen en punten te scoren door het met pijlen te raken +meta_title: Python programmeer projecten voor kinderen en tieners | Oefening doelwit schieten +meta_description: Leer Python met de codeerprojecten van de Raspberry Pi Foundation voor kinderen en tieners. Gebruik Python om een doelwit te tekenen en punten te scoren door er met pijlen op te mikken. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Wat ga je maken + - + title: Teken het gras + - + title: Teken je doelwit + completion: + - engaged + - + title: Schiet de pijl af + - + title: Welke kleur heb je geraakt? + - + title: Punten scoren + completion: + - internal + - + title: Snelle quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Uitdaging + challenge: true + - + title: Wat kun je verder nog doen? diff --git a/nl-NL/python-comments-demo.txt b/nl-NL/python-comments-demo.txt new file mode 100644 index 000000000..7604e4472 --- /dev/null +++ b/nl-NL/python-comments-demo.txt @@ -0,0 +1,73 @@ +Stel je spel hier in + +breedte en hoogte van het scherm + +Dingen om te doen in elk frame + +Rood = 92, Groen = 204, Blauw = 206 + +Stel de vulkleur in op gras + +x, y, breedte, hoogte + +Stel de vulkleur van de standaard in op hout + +Stel de kleur van de cirkelvulling in op buitenste + +x, y, breedte van de cirkel + +Blauw + +Rood + +Geel + +Zet de kleur van de cirkelvulling op de binnenste + +Binnenste cirkel - x, y, breedte van de cirkel + +Zet de kleur van de cirkelvulling in op midden + +Middelste cirkel - x, y, breedte van de cirkel + +De schiet_pijl functie komt hier + +Sla een willekeurig getal op tussen 100 en 300 + +Stel de pijl in om met kleur hout te vullen + +Teken een kleine cirkel op willekeurige coördinaten + +Pak de kleur van de hit + +De muis_ingedrukt functie komt hier + +Kan ook gebruikt worden in andere functies + +Sla de kleur op voordat je de pijl tekent + +Net als functies, zijn 'if'-statements ingesprongen + +Bibliotheekcode importeren + +Bewaar dit om je code uit te voeren + +Definities voor compatibiliteit met de p5py-processing-bibliotheek + +Vorm + +Lettertypen + +Tekst + +Kleur + +Afbeeldingen + +Omgeving + +Omzetten + +Toetsenbord + +Stel de vulkleur in op gras diff --git a/nl-NL/python-comments.txt b/nl-NL/python-comments.txt new file mode 100644 index 000000000..667891143 --- /dev/null +++ b/nl-NL/python-comments.txt @@ -0,0 +1,27 @@ +Dingen om te doen in elk frame + +Teken de binnenste cirkel + +Teken de middelste cirkel + +De schiet_pijl functie komt hier + +De mouse_pressed functie komt hier + +Je raakt de buitenste cirkel, 50 punten! + +Je hebt de binnenste cirkel geraakt, 200 punten! + +Je raakt het midden, 500 punten! + +Je hebt het midden geraakt, 500 punten! + +Je hebt gemist! Geen punten! + +Supersnel + +Vrij snel + +Zeer snel + +Snelheid niet herkend! \ No newline at end of file diff --git a/nl-NL/python-translatable-demo.txt b/nl-NL/python-translatable-demo.txt new file mode 100644 index 000000000..84c32d312 --- /dev/null +++ b/nl-NL/python-translatable-demo.txt @@ -0,0 +1,37 @@ +hout + +lucht + +gras + +buitenste + +binnenste + +midden + +schiet_pijl + +pijl_x + +pijl_y + +raak_kleur + +Je hebt de buitenste cirkel geraakt, 50 punten! + +Je hebt de binnenste cirkel geraakt, 200 punten! + +Je hebt het midden geraakt, 500 punten! + +Je hebt gemist! Geen punten! + +Supersnel + +Vrij snel + +Zeer snel + +Snelheid niet herkend! + +snelheid diff --git a/nl-NL/python-translatable.txt b/nl-NL/python-translatable.txt new file mode 100644 index 000000000..ed3fd4ba6 --- /dev/null +++ b/nl-NL/python-translatable.txt @@ -0,0 +1,9 @@ +schiet_pijl + +pijl_x + +pijl_y + +raak_kleur + +snelheid \ No newline at end of file diff --git a/nl-NL/quiz1/question_1.md b/nl-NL/quiz1/question_1.md new file mode 100644 index 000000000..2bc938558 --- /dev/null +++ b/nl-NL/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Snelle quiz + +Beantwoord de drie vragen. Je wordt naar het juiste antwoord geleid. + +Klik na het beantwoorden van elke vraag op **Controleer mijn antwoord**. + +Veel plezier! + +--- question --- +--- +legend: Vraag 1 van 3 +--- +In je project heb je `randint(100, 300)` toegevoegd aan je `schiet_pijl()` functie. Wat doet `randint(100, 300)`? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) Er wordt een willekeurig geheel getal tussen 100 en 300 gekozen. + + --- feedback --- + +Dat klopt. Hiermee kies je een willekeurige x-coördinaat voor jouw pijl. + + --- /feedback --- + +- ( ) Hierdoor beweegt de pijl willekeurig over het scherm. + + --- feedback --- + +Niet helemaal. Deze code bepaalt gedeeltelijk hoe de pijl willekeurig beweegt, maar om dat doel te bereiken, heb je ook nog andere code nodig. + + --- /feedback --- + +- () Het haalt de kleur op die door de pijl werd geraakt. + + --- feedback --- + + Niet helemaal. De functie get() wordt gebruikt om de kleur op te halen. + + --- /feedback --- + +- ( ) Er wordt een cirkelvorm in jouw programma getekend. + + --- feedback --- + + Niet helemaal. De functie circle() zou worden gebruikt om een cirkel te tekenen. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/nl-NL/quiz1/question_2.md b/nl-NL/quiz1/question_2.md new file mode 100644 index 000000000..ddf7b3471 --- /dev/null +++ b/nl-NL/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legenda: Vraag 2 van 3 +--- + +In je project heb je `if`, `elif`en `else` condities gebruikt om te controleren op welke kleur de pijl terechtkwam. + +In het onderstaande voorbeeld is in een variabele met de naam `snelheid` het getal `6` opgeslagen. Als dit `if` commando wordt uitgevoerd, wat wordt er dan afgedrukt in het uitvoergebied? + +--- code --- +--- +language: python +--- +snelheid = 6 + +if snelheid == 7: print('Super snel') elif snelheid == 5: print('Aardig snel') elif snelheid == 6: print('Zeer snel') else: print( 'Snelheid niet herkend!') + +--- /code --- + +--- choices --- + +- (x) `Zeer snel` + + --- feedback --- + + Dat is correct! De **snelheid** variabele heeft de waarde `6`gekregen, waardoor de voorwaarde `snelheid == 6` **Waar** is en `Zeer snel` wordt afgedrukt. + + --- /feedback --- + +- ( ) `Snelheid niet herkend!` + + --- feedback --- + + Niet helemaal, kijk naar de waarde die is toegewezen aan de variabele **snelheid**. + + --- /feedback --- + +- ( ) Er wordt niets afgedrukt + + --- feedback --- + + Probeer het opnieuw, `else` wordt gebruikt als laatste optie voor wanneer alle bovenstaande voorwaarden onwaar zijn. Kijk nog eens naar de voorwaarden. Is een van de voorwaarden waar? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/nl-NL/quiz1/question_3.md b/nl-NL/quiz1/question_3.md new file mode 100644 index 000000000..052c790ee --- /dev/null +++ b/nl-NL/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legenda: Vraag 3 van 3 +--- + +Een cirkel wordt getekend met behulp van de volgende code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Welke van de onderstaande afbeeldingen toont de juiste positie van deze cirkel in het uitvoergebied? + +--- choices --- + +- ( ) ![Een groene cirkel in het midden van de rechterbenedenhoek van het uitvoergebied.](images/bottom-right.png) + + --- feedback --- + + Niet helemaal, om de cirkel in de rechterbenedenhoek te centreren, zouden de coördinaten hetzelfde moeten zijn als de schermgrootte. In dit voorbeeld zou de ellips `circle(400, 400, 300)`zijn. + + --- /feedback --- + +- ( ) ![Een groene cirkel in het midden van het uitvoergebied.](images/centre.png) + + --- feedback --- + + Niet helemaal, om de cirkel in het midden te centreren, zouden de coördinaten de helft van de schermgrootte moeten zijn. In dit voorbeeld `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Een groene cirkel in het midden van de linkerbovenhoek van het uitvoergebied.](images/top-left.png) + + --- feedback --- + + Dat is correct! Deze cirkel is gecentreerd op coördinaten (0,0), de linkerbovenhoek van het scherm. + + --- /feedback --- + +- ( ) ![Een groene cirkel gecentreerd bij de rechterbovenhoek van het uitvoergebied.](images/random-side.png) + + --- feedback --- + + Nee, deze cirkel zou de code `circle(350, 150, 300)` hebben om deze bij de rechterbovenhoek van het scherm te centreren. De `x` coördinaat is hoe ver naar rechts over het scherm de ellips is, en de `y` coördinaat is hoe ver het naar beneden op het scherm is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/nl-NL/resources/main.py b/nl-NL/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/nl-NL/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/nl-NL/resources/p5.py b/nl-NL/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/nl-NL/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/nl-NL/step_1.md b/nl-NL/step_1.md new file mode 100644 index 000000000..7dc835c6a --- /dev/null +++ b/nl-NL/step_1.md @@ -0,0 +1,29 @@ +## Wat ga je maken + +Gebruik Python om een doel te tekenen en punten te scoren door het met pijlen te raken. + +--- print-only --- + +![Een boogschietdoel met een trefpunt op de buitenste cirkel. De tekst 'Je raakt de buitenste cirkel, 50 punten!' wordt eronder weergegeven](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Klik op de knop **Run** hieronder om het spel te starten. Wanneer de stip op het doel 🎯 komt, klik je met de muis (of tik je op je tablet) om je pijl af te schieten. + + +
+
+ +--- /no-print --- + +
+ Vul onze enquête in om onze Code Editor te helpen verbeteren! +
+ + + diff --git a/nl-NL/step_2.md b/nl-NL/step_2.md new file mode 100644 index 000000000..8d06aced2 --- /dev/null +++ b/nl-NL/step_2.md @@ -0,0 +1,37 @@ +## Teken het gras + +--- task --- + +Open het project [Doelpraktijk-start](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Voeg** code toe om een groene rechthoek onder aan het scherm te tekenen. + +![Het uitvoergebied met een luchkleurige rechthoek boven een graskleurige rechthoek om de achtergrond te creëren. De linkerbovenhoek van de rechthoek is gemarkeerd als x=0, y=250 dit is de oorsprong van de rechthoek. De breedte wordt gemarkeerd als 400 en de hoogte als 150. De code rect(0, 250, 400, 150) wordt weergegeven.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Voer je project opnieuw uit om de voltooide achtergrond te bekijken. + +![Het uitvoergebied met een luchtkleurige rechthoek boven een graskleurige rechthoek om de achtergrond te creëren.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/nl-NL/step_3.md b/nl-NL/step_3.md new file mode 100644 index 000000000..e12865386 --- /dev/null +++ b/nl-NL/step_3.md @@ -0,0 +1,115 @@ +## Teken je doelwit + +
+
+Je spel heeft een doel nodig om pijlen op te schieten. +
+
+ +![Het uitvoergebied met het doel en de standaard.](images/three-circles.png){:width="300px"} + +
+
+ +### Teken een driehoekige standaard + +--- task --- + +Stel de vulkleur in op `brown` (bruin). + +Teken een driehoek met de x- en y-coördinaten voor elk van de hoeken. + +![Een bruine driehoek op gras en tegen een lucht met de coördinatenpunten gelabeld op 150, 350 en 200, 150 en 250, 350). De hoeken van het canvas zijn ook gelabeld als x=0, y=0 linksboven en x=400, y=400 rechtsonder.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Voer je code uit om de standaard voor je doelwit te zien: + +![Een bruine driehoek op gras en tegen een lucht.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Teken de doelcirkels + +--- task --- + +Het grootste deel van het doel is een blauwe **cirkel**. + +Stel de vulkleur in op `blue` (blauw). + +Teken een cirkel met x- en y-coördinaten voor het midden en de breedte. + +![Een bruine driehoek en blauwe cirkel op gras en tegen een lucht. De cirkel is gelabeld met de coördinaten x=200, y=200 als het midden en de cirkelbreedte van 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Voer je code uit om de eerste grote blauwe cirkel te zien. + +De blauwe cirkel is na de standaard getekend, dus deze staat vooraan. + +![Een bruine driehoek en blauwe cirkel op gras en tegen een lucht.](images/blue-circle.png){:width="400px"} + +--- /task --- + +Het doel is gemaakt van cirkels van verschillende grootte met dezelfde centrale coördinaten (200, 200). + +--- task --- + +**Voeg** gekleurde cirkels toe voor de binnenste en middelste delen van het doel. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Voer je project uit om het doel met drie gekleurde cirkels te zien. + +![Een bruine driehoek met drie gekleurde cirkels op gras en tegen een lucht.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/nl-NL/step_4.md b/nl-NL/step_4.md new file mode 100644 index 000000000..c9a2c1692 --- /dev/null +++ b/nl-NL/step_4.md @@ -0,0 +1,88 @@ +## Schiet de pijl af + +
+
+Voeg een nog kleinere cirkel toe die een pijlt voorstelt. +
+
+ +![Het doelwit, met een bruine cirkelpijl die op verschillende posities verschijnt.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Waar ga je schieten? + +--- task --- + +Voeg een functie toe om een bruine cirkel te tekenen op de coördinaten `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# De schiet_pijl functie komt hier +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Roep je nieuwe `schiet_pijl()`{:.language-python} functie aan het einde van jouw `draw()`{:.language-python} functie aan. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klik op de knop **Run**. Je zou de pijl in het midden moeten zien. + +![een bruine pijlcirkel in het midden van het doel](images/arrow-centre.png) + + +--- /task --- + +De pijl moet willekeurig bewegen. + + +--- task --- + +Wijzig de `pijl_x`{:.language-python} en `pijl_y`{:.language-python} variabelen om een willekeurig getal tussen 100 en 300 te kiezen. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Klik op de knop **Run**. Je zou de pijl rond het doel moeten zien springen. + +![Een animatie van een doelwit met een bruine cirkelpijl die in verschillende posities verschijnt.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/nl-NL/step_5.md b/nl-NL/step_5.md new file mode 100644 index 000000000..028cabac6 --- /dev/null +++ b/nl-NL/step_5.md @@ -0,0 +1,80 @@ +## Welke kleur heb je geraakt? + +Vervolgens voeg je wat code toe om de kleur op de plek van de pijl op te halen. + +### Haal de kleur op die door de pijl wordt geraakt + +--- task --- + +Voeg een nieuwe **globale variabele** toe met de naam `raak_kleur`. + +Voeg code toe om de kleur in het midden van de pijl `op te halen` en sla deze op in de variabele `raak_kleur`. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** 💡 De `get`-code om de kleur op te halen en op te slaan moet **vóór** de code om de `cirkel` te tekenen staan, anders bewaar je altijd de bruin kleur van de pijl! + +--- /task --- + +--- task --- + +**Test:** Klik op de knop **Run**. Je zou kleuren moeten zien afgedrukt in de **Tekstuitvoer**, in hexadecimaal formaat. + +--- /task --- + +### Code uitvoeren wanneer de muis wordt ingedrukt + +--- task --- + +Maak een comment van de regel die de kleur print. Dit betekent dat het niet zal werken. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Voeg code toe om de doel-emoji 🎯 af te drukken ** wanneer met de muis wordt geklikt**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# De mouse_pressed functie komt hier +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klik op de knop **Run**. Wanneer je met de muis op het doel klikt, zou je het teken 🎯 moeten zien. + +![doel-emoji geprint wanneer met de muis wordt geklikt](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/nl-NL/step_6.md b/nl-NL/step_6.md new file mode 100644 index 000000000..462b52f70 --- /dev/null +++ b/nl-NL/step_6.md @@ -0,0 +1,112 @@ +## Punten scoren + +
+
+Afhankelijk van waar de pijl terechtkomt, wordt er een score toegekend. +
+
+ +![Een animatie van het doel, waarbij de pijl in verschillende posities verschijnt en de scores als tekst onder het spel verschijnen.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Maak een comment van de regel die het teken 🎯 print, zodat deze niet meer wordt uitgevoerd. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Geef een bericht weer **als** de `raak_kleur`{:.language-python} gelijk is aan de `buitenste` cirkelkleur (blauw). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** Als je de kleur van je buitenste cirkel hebt gewijzigd, moet je `'blue'` vervangen door de kleurnaam die je hebt gekozen. + +--- /task --- + +--- task --- + +**Test:** Klik op de knop **Run**. Wacht tot de pijl in de blauwe cirkel terechtkomt en klik vervolgens op de linkermuisknop. ![punten gescoord toen op de blauwe cirkel werd geklikt](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} kan worden gebruikt om meer voorwaarden toe te voegen aan je `if`{:.language-python} statement. + +--- task --- + +Voeg wat meer code toe om punten te scoren als de pijl op de **binnenste** of **middelste** cirkel terechtkomt. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klik op de knop **Run**. Je zou punten moeten scoren wanneer je het doel raakt. + +![punten die op een willekeurig gebied van het doel worden gescoord](images/yellow-points.png) + +--- /task --- + +### Het doel missen + +Er is nog een beslissing die je moet nemen: wat gebeurt er als de pijl niet op een van de doelcirkels landt? + +Om deze laatste controle uit te voeren, gebruikt je `else`{:.language-python}. + +--- task --- + +Voeg code toe aan het `print` commando om een bericht weer te geven wanneer geen van de `if` en `elif` statements waar zijn. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Klik op de knop **Run**. Probeer de pijl in het gras of de lucht te laten landen om het gemist bericht te zien. + +![geen punten weergegeven wanneer buiten het doelgebied](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/nl-NL/step_7.md b/nl-NL/step_7.md new file mode 100644 index 000000000..2097d0e6f --- /dev/null +++ b/nl-NL/step_7.md @@ -0,0 +1 @@ +## Snelle quiz \ No newline at end of file diff --git a/nl-NL/step_8.md b/nl-NL/step_8.md new file mode 100644 index 000000000..ac37fce08 --- /dev/null +++ b/nl-NL/step_8.md @@ -0,0 +1,36 @@ +## Uitdaging + +--- challenge --- + + +Je kunt: + + +--- task --- + +Een `vierde` en `vijfde` cirkel toevoegen, in nieuwe kleuren, die verschillende punten scoren op basis van hun positie + +--- /task --- + +--- task --- + +Emoji in je geprinte berichten zetten ([hier is een lijst met emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} waaruit je kunt kopiëren) + +--- /task --- + +--- task --- + +Het spel gemakkelijker of moeilijker maken door de waarde van `frame_rate=2` te wijzigen + + +--- /task --- + +--- task --- + +Voeg een variabele toe om de totaalscore bij te houden en tel er elke keer het juiste aantal punten bij op. + +--- /task --- + + + +--- /challenge --- diff --git a/nl-NL/step_9.md b/nl-NL/step_9.md new file mode 100644 index 000000000..c425daec9 --- /dev/null +++ b/nl-NL/step_9.md @@ -0,0 +1,21 @@ +## Wat kun je verder nog doen? + +Als je het [Inleiding tot Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pad volgt, kun je doorgaan naar het [Raket lanceren](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In dit project maak je een interactieve animatie van een raket die een satelliet in een baan om de aarde lanceert. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Klik op de knop **Run** om een voorbeeld van dit project te bekijken. + + + +\--- /no-print --- + +Of waarom probeer je geen ander [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project? + diff --git a/or-IN/images/alternative-colours.png b/or-IN/images/alternative-colours.png new file mode 100644 index 000000000..a688ac942 Binary files /dev/null and b/or-IN/images/alternative-colours.png differ diff --git a/or-IN/images/animation_bg_erase.gif b/or-IN/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/or-IN/images/animation_bg_erase.gif differ diff --git a/or-IN/images/animation_no_bg_erase.gif b/or-IN/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/or-IN/images/animation_no_bg_erase.gif differ diff --git a/or-IN/images/arrow-middle.png b/or-IN/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/or-IN/images/arrow-middle.png differ diff --git a/or-IN/images/arrow-target.png b/or-IN/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/or-IN/images/arrow-target.png differ diff --git a/or-IN/images/background.png b/or-IN/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/or-IN/images/background.png differ diff --git a/or-IN/images/banner.png b/or-IN/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/or-IN/images/banner.png differ diff --git a/or-IN/images/blue-circle.png b/or-IN/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/or-IN/images/blue-circle.png differ diff --git a/or-IN/images/blue-points.png b/or-IN/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/or-IN/images/blue-points.png differ diff --git a/or-IN/images/bottom-right.png b/or-IN/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/or-IN/images/bottom-right.png differ diff --git a/or-IN/images/centre.png b/or-IN/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/or-IN/images/centre.png differ diff --git a/or-IN/images/circle-coords.png b/or-IN/images/circle-coords.png new file mode 100644 index 000000000..6c0d2c78b Binary files /dev/null and b/or-IN/images/circle-coords.png differ diff --git a/or-IN/images/coords_animation.gif b/or-IN/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/or-IN/images/coords_animation.gif differ diff --git a/or-IN/images/difficulty-setting.png b/or-IN/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/or-IN/images/difficulty-setting.png differ diff --git a/or-IN/images/fire_arrow.gif b/or-IN/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/or-IN/images/fire_arrow.gif differ diff --git a/or-IN/images/five_circles.png b/or-IN/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/or-IN/images/five_circles.png differ diff --git a/or-IN/images/green-grass.png b/or-IN/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/or-IN/images/green-grass.png differ diff --git a/or-IN/images/grey-circle.png b/or-IN/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/or-IN/images/grey-circle.png differ diff --git a/or-IN/images/grey-points.png b/or-IN/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/or-IN/images/grey-points.png differ diff --git a/or-IN/images/initial_target.png b/or-IN/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/or-IN/images/initial_target.png differ diff --git a/or-IN/images/missed-points.png b/or-IN/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/or-IN/images/missed-points.png differ diff --git a/or-IN/images/outline-circles.png b/or-IN/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/or-IN/images/outline-circles.png differ diff --git a/or-IN/images/points-scored.gif b/or-IN/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/or-IN/images/points-scored.gif differ diff --git a/or-IN/images/quiz-colour.png b/or-IN/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/or-IN/images/quiz-colour.png differ diff --git a/or-IN/images/random-side.png b/or-IN/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/or-IN/images/random-side.png differ diff --git a/or-IN/images/rectangle-diagram.png b/or-IN/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/or-IN/images/rectangle-diagram.png differ diff --git a/or-IN/images/showcase_rocket.png b/or-IN/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/or-IN/images/showcase_rocket.png differ diff --git a/or-IN/images/showcase_static.png b/or-IN/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/or-IN/images/showcase_static.png differ diff --git a/or-IN/images/sky_coords.png b/or-IN/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/or-IN/images/sky_coords.png differ diff --git a/or-IN/images/sky_stroke.png b/or-IN/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/or-IN/images/sky_stroke.png differ diff --git a/or-IN/images/stand_coords.png b/or-IN/images/stand_coords.png new file mode 100644 index 000000000..28e151045 Binary files /dev/null and b/or-IN/images/stand_coords.png differ diff --git a/or-IN/images/step_4_preview.gif b/or-IN/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/or-IN/images/step_4_preview.gif differ diff --git a/or-IN/images/step_5_preview.gif b/or-IN/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/or-IN/images/step_5_preview.gif differ diff --git a/or-IN/images/target-stand.png b/or-IN/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/or-IN/images/target-stand.png differ diff --git a/or-IN/images/target_area.png b/or-IN/images/target_area.png new file mode 100644 index 000000000..72d80ba1d Binary files /dev/null and b/or-IN/images/target_area.png differ diff --git a/or-IN/images/three-circles.png b/or-IN/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/or-IN/images/three-circles.png differ diff --git a/or-IN/images/top-left.png b/or-IN/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/or-IN/images/top-left.png differ diff --git a/or-IN/images/triangles-coords.png b/or-IN/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/or-IN/images/triangles-coords.png differ diff --git a/or-IN/images/upgrade-ideas.png b/or-IN/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/or-IN/images/upgrade-ideas.png differ diff --git a/or-IN/images/yellow-points.png b/or-IN/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/or-IN/images/yellow-points.png differ diff --git a/or-IN/meta.yml b/or-IN/meta.yml new file mode 100644 index 000000000..d4420e902 --- /dev/null +++ b/or-IN/meta.yml @@ -0,0 +1,36 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: You will make + - + title: Create a background + - + title: Draw your target + completion: + - engaged + - + title: Fire your arrow + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Upgrade your project + - + title: What next? diff --git a/or-IN/python-comments-demo.txt b/or-IN/python-comments-demo.txt new file mode 100644 index 000000000..cb2eb5621 --- /dev/null +++ b/or-IN/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill color to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill color to grass diff --git a/or-IN/python-comments.txt b/or-IN/python-comments.txt new file mode 100644 index 000000000..160666a85 --- /dev/null +++ b/or-IN/python-comments.txt @@ -0,0 +1,87 @@ +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Start x, start y, width, height + +x, y, width, height + +Set the stand fill colour to wood + +Set the arrow to fill colour to wood + +Set the stand fill colour to grass + +Set the circle fill colour to outer + +Set the circle fill colour to inner + +Set the circle fill colour to middle + +x, y, width of the circle + +Inner circle - x, y, width of the circle + +Middle circle - x, y, width of the circle + +Outer circle.200, 200 is the middle of the screen + +Blue + +Red + +Yellow + +Stand + +Outer circle + +Inner circle + +Bullseye + +The shoot_arrow function goes here + +Import library code + +Update to random coordinates + +Save the colour before drawing the arrow + +The mouse_pressed function goes here + +Can be used in other functions + +Like functions, 'if' statements are indented + +Setup your game here + +width and height + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Keep this to run your code + +Store a random number between 100 and 300 + +Get the hit colour + +Draw a small circle at random coordinates + +width and height of screen diff --git a/or-IN/python-translatable-demo.txt b/or-IN/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/or-IN/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/or-IN/python-translatable.txt b/or-IN/python-translatable.txt new file mode 100644 index 000000000..75c0058cc --- /dev/null +++ b/or-IN/python-translatable.txt @@ -0,0 +1,43 @@ +sky + +grass + +wood + +outer + +inner + +bullseye + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the bullseye, 500 points! + +You missed! No points! + +How fast do you want the arrow? slow, medium, fast + +You hit red, 200 points! + +speed + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! diff --git a/or-IN/quiz1/question_1.md b/or-IN/quiz1/question_1.md new file mode 100644 index 000000000..7413e69a7 --- /dev/null +++ b/or-IN/quiz1/question_1.md @@ -0,0 +1,53 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +Here is a blue square, what are the RGB values that will create it? + +![A single block of blue colour.](images/quiz-colour.png) + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +Not quite, when all the colour values are set to `0`, the color is **black**. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite, colours follow the RGB model. This colour has maximum R value and no G or B, so will be **red**. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + That's correct! Colours follow the RGB model. This colour has no R or G, but maximum B, so will be **blue**. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite, when all the colour values are set to the `255` maximum, the color is **white**. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/or-IN/quiz1/question_2.md b/or-IN/quiz1/question_2.md new file mode 100644 index 000000000..cb8b743b2 --- /dev/null +++ b/or-IN/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/or-IN/quiz1/question_3.md b/or-IN/quiz1/question_3.md new file mode 100644 index 000000000..de44b3b7f --- /dev/null +++ b/or-IN/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/or-IN/step_1.md b/or-IN/step_1.md new file mode 100644 index 000000000..21a69d6b9 --- /dev/null +++ b/or-IN/step_1.md @@ -0,0 +1,40 @@ +## You will make + +Use Python, with the `p5` graphics library, to draw a target and score points by hitting it with arrows. + +You will: + + Personalise your game with **RGB colours** + + Use **conditional statements** (`if`, `elif`, `else`) to make decisions + + Position shapes with **x, y coordinates** + +--- no-print --- + +### Play ▶️ + +--- task --- + +
+
+Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + +Have a few goes. Your score appears in the output area below the target. How does your score change when the arrow lands on the different colours? + +
+
+ +--- /task --- + +--- /no-print --- + +--- print-only --- + +![Completed project.](images/yellow-points.png) + +--- /print-only --- + +

+The oldest evidence of archery comes from the Sibudu Cave in KwaZulu-Natal, South Africa. Remains of stone and bone arrowheads have been found, which date to between 60,000 and 70,000 years ago. +

+ +![](http://code.org/api/hour/begin_coderdojo_target.png) diff --git a/or-IN/step_2.md b/or-IN/step_2.md new file mode 100644 index 000000000..b03ac80cf --- /dev/null +++ b/or-IN/step_2.md @@ -0,0 +1,97 @@ +## Create a background + +
+
+Your game needs a colourful background. +
+
+ +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="300px"} + +
+
+ +### Open the starter project + +--- task --- + +Open the [Target practice starter](https://trinket.io/python/9973649e5c){:target="_blank"} project. + +If you have a Trinket account, you can click on the **Remix** button to save a copy to your **My Trinkets** library. + +--- /task --- + +### Edit the sky + +--- task --- + +The starter project has some code already written for you. + +Click **'Run'** to see a blue filled rectangle drawn from x=`0`, y=`0` (the top of the screen). This `400` x `250` pixels rectangle is the sky. + +![A blue rectangle with a black border around it, above a grey rectangle. The top left corner of the canvas is marked as x=0, y=0 this is the origin of the rectangle. The width is highlighted as 400 and the height as 250. The code rect(0, 0, 400, 250) is shown.](images/sky_stroke.png){:width="400px"} + +**Tip:** 💡 Coordinates start from (x=0, y=0) in the top left corner. This might be different to other coordinate systems you have used. + +--- /task --- + +--- task --- + +The sky has been drawn with a black border (stroke). + +To turn the stroke off for all shapes add `no_stroke()` to the `setup` function: + +--- code --- +--- +language: python filename: main.py — setup() line_numbers: true line_number_start: 11 +line_highlights: 15 +--- +def setup(): +# Setup your game here + size(400, 400) # width and height of screen frame_rate(2) no_stroke() + +--- /code --- + +--- /task --- + +--- task --- + +**Run** your code again and notice 👀 that the border (stroke) has now disappeared. + +--- /task --- + +### Draw the grass + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 17 +line_highlights: 27, 28 +--- +def draw(): +# Things to do in every frame + global wood sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 grass = color(149, 212, 122) wood = color(145, 96, 51) outer = color(0, 120, 180) + + fill(sky) +rect(0, 0, 400, 250) +fill(grass) # Set the fill color to grass rect(0, 250, 400, 150) # x, y, width, height + +--- /code --- + +**Tip:** 💡 We have added comments to our code, like `# Set the fill color to grass`, to tell you what it does. You don't need to add these comments to your code, but they can be helpful to remind you what lines of code do. + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project again to view the finished background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + diff --git a/or-IN/step_3.md b/or-IN/step_3.md new file mode 100644 index 000000000..39986aa1f --- /dev/null +++ b/or-IN/step_3.md @@ -0,0 +1,152 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `wood` (brown). + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 i the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 27 +line_highlights: 29, 30 +--- + fill(grass) +rect(0, 250, 400, 150) fill(wood) # Set the stand fill colour to wood +triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `outer` (blue). + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 29 +line_highlights: 31, 32 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) # Set the circle fill colour to outer +circle(200, 200, 170) # x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front: + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +--- task --- + +👀 Find your colour variables in the `draw` function. + +Create two variables called `inner` and `middle` to store colours for the other circles. + +The `color` function expects three numbers: one each for red, green, and blue. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 17 +line_highlights: 24, 25 +--- +def draw(): +# Things to do in every frame global wood sky = color(92, 204, 206) +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) # Blue +inner = color(210, 60, 60) # Red +middle = color(220, 200, 0) # Yellow + +--- /code --- + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 35, 36, 37, 38 +--- + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) +circle(200, 200, 170) fill(inner) # Set the circle fill colour to inner +circle(200, 200, 110) # Inner circle - x, y, width of the circle +fill(middle) # Set the circle fill colour to middle +circle(200, 200, 30) # Middle circle - x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +**Debug:** 🐞 Check that you have used the American spelling of 'color' (without a 'u'). + +--- /task --- + +--- task --- + +**Choose:** 💭 Change any of the colours. + +[[[generic-theory-simple-colours]]] + +![A brown triangle with three coloured circles on grass and against a sky. The colours have changed to pinks and purples.](images/alternative-colours.png){:width="400px"} + + +--- /task --- + + + diff --git a/or-IN/step_4.md b/or-IN/step_4.md new file mode 100644 index 000000000..995a078e0 --- /dev/null +++ b/or-IN/step_4.md @@ -0,0 +1,159 @@ +## Fire your arrow + +
+
+When you click or tap, an arrow will fire at the position of a moving target circle. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Draw a target circle every frame + +

Computers create the effect of movement by showing lots of images one after another. Each image is called a frame . +

+ +--- task --- + +Define your `shoot_arrow()` function under the comment **# The shoot_arrow function goes here**. + +Add code to randomly draw a brown circle within a target area: + +![A rectangle showing the target area coordinates in a semi transparent rectangle. The target area is between x=100 and y=100 to x=300 and y=300 so covers the whole target and wider.](images/target_area.png) + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 10, 11, 12, 13, 14 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) # Store a random number between 100 and 300 +arrow_y = randint(100, 300) # Store a random number between 100 and 300 +fill(wood) # Set the arrow to fill colour to wood +circle(arrow_x, arrow_y, 15) # Draw a small circle at random coordinates + +--- /code --- + +--- /task --- + +--- task --- + +Go to the `draw` function and call your new `shoot_arrow` function. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 42 +line_highlights: 44 +--- + fill(middle) +circle(200, 200, 30) +shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run you code and see the arrow appear in a random position each frame. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +The background and target will be drawn over the old arrow. This means you only see one arrow at a time. + +--- /task --- + +### Get the colour hit by the arrow + +The `get()` function returns the colour of a pixel. + +

+A pixel, short for picture element, is a single coloured dot within an image. Images are made up of lots of coloured pixels. +

+ +--- task --- + +Add code to `get` the colour of the pixel at the centre of the arrow and store it in the `hit_color` variable. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Get the hit colour fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** 💡 The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the wood colour of the arrow! + +--- /task --- + +### Print the colour when the mouse is pressed + +The `p5` library 'listens' for certain events, one of these is the press of the mouse button. When it detects that the button has been pressed, it will run whatever code it has been given in the `mouse_pressed` function. + +--- task --- + +Define your `mouse_pressed()` function under the comment **# The mouse_pressed function goes here**. + +Add code to print the amounts of red, green, and blue in the pixel the arrow lands on. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 8, 9 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +print( red(hit_color), green(hit_color), blue(hit_color) ) + +--- /code --- + +--- /task --- + +--- task --- + +Make `hit_color` a **global variable** so that it can be used throughout your code: + +--- code --- +--- +language: python filename: main.py - shoot_arrow() line_numbers: true line_number_start: 11 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +global hit_color # Can be used in other functions +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Save the colour before drawing the arrow fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. + +The project prints the `hit_color` each time the arrow is redrawn. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +**Debug:** 🐞 If you are seeing a message about `hit_color` being 'not defined', then go back to `shoot_arrow()` and check that you have the `global hit_color` line. + +**Debug:** 🐞 Check the `print` line really carefully for commas and brackets. + +--- /task --- + + diff --git a/or-IN/step_5.md b/or-IN/step_5.md new file mode 100644 index 000000000..e0660f134 --- /dev/null +++ b/or-IN/step_5.md @@ -0,0 +1,169 @@ +## Score points + +
+
+Your game will add scores based on where the arrow hits. +
+
+ +![The target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Go to the `draw()` function and add `, outer, inner, middle` to the list of global variables. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 28 +--- + +def draw(): +# Things to do in every frame + global wood, outer, inner, middle +sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +middle = color(220, 200, 0) + +--- /code --- + +--- /task --- + +

+We use conditions all the time to make decisions. We could say 'if the pencil is blunt, then sharpen it'. Similarly, `if` conditions let us write code that do something different depending on whether a condition is true or false. +

+ +### Display the scores + +--- task --- + +Delete ❌ the `print( red(hit_color), green(hit_color), blue(hit_color) )` line of code. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9 +--- +# The mouse_pressed function goes here +def mouse_pressed(): + + +--- /code --- + +--- /task --- + +--- task --- + +`print` a message `if` the `hit_color` is equal to `outer` 🎯. + +Notice 👀 that the code uses two equals signs `==` to mean **equal to**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9, 10 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') # Like functions, 'if' statements are indented + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the blue outer circle to see your message. + +**Tip:** 💡 `frame_rate()`, in `setup`, controls how fast your game draws. If it's going too fast, set it to a lower number. + +![The output area with arrow touching the outer circle. The points print statement appears in the output area.](images/blue-points.png) + +**Debug:** 🐞 Make sure your code matches exactly and you indented the code inside your `if` statement. + +--- /task --- + +`elif` (else - if) can be used to add more conditions to your `if` statement. These will be read from top to bottom. As soon as a **True** condition is found, it will be actioned. The remaining conditions will be ignored. + +--- task --- + +Score points if the arrow lands on the `inner` or `middle` circles 🎯: + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11, 12, 13, 14 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the inner and middle circles to see their messages. + +![The output area with arrow touching the inner circle. The points print statement appears in the output area.](images/yellow-points.png) + +**Debug:** 🐞 Check your indentation matches the example. + +**Debug:** 🐞 If you see a message about `inner` or `middle` being 'not defined', then go back to `draw()` and check that they are on the line that declares variables global. + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? ❌ + +To do this last check, you use `else`. + +--- task --- + +Add code to `print` a message `else` none of the `if` and `elif` statements have been met. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 8 +line_highlights: 15, 16 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') +else: +print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow in the grass or sky to see the miss message. + +**Choose:** 💭 Change the number of points scored for the different colours if you like. + +![The output area with an arrow missing the target. The points print statement appears in the output area.](images/missed-points.png) + +--- /task --- + diff --git a/or-IN/step_6.md b/or-IN/step_6.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/or-IN/step_6.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/or-IN/step_7.md b/or-IN/step_7.md new file mode 100644 index 000000000..e479b9649 --- /dev/null +++ b/or-IN/step_7.md @@ -0,0 +1,35 @@ +## Upgrade your project + +
+
+Personalise and add more to your project. Perhaps you could change the difficulty level or add more circles to your target. +
+
+ +![The output area showing a target with five circles.](images/five_circles.png){:width="300px"} + +
+
+ +--- task --- + +You could: + ++ Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position 🟠🟣 ++ Put emoji in your print messages ([here's a list of emoji](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) 🎯 ++ Make the game easier or harder by changing the `frame_rate(2)` value 💨 ++ Use `input()` to ask the user which difficulty level they want to play at 🗣️ + +--- /task --- + +![Upgraded project ideas: one with five circles, one with a difficulty input question, one with emoji in the points message.](images/upgrade-ideas.png) + +--- collapse --- +--- +title: Completed project +--- + +You can view the [completed project here](https://trinket.io/python/f686c82d8a){:target="_blank"}. + +--- /collapse --- + diff --git a/or-IN/step_8.md b/or-IN/step_8.md new file mode 100644 index 000000000..867ede7b9 --- /dev/null +++ b/or-IN/step_8.md @@ -0,0 +1,31 @@ +## What next? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png) + +--- /print-only --- + +--- no-print --- + +--- task --- + +**Try it:** Your program will adjust the animation based on how much fuel you give it and will succeed or fail in reaching orbit. How much fuel do you want to use to reach orbit but not waste too much extra fuel? + +**Tip:** Around 25,000kg should be enough, but experiment with the numbers to see what happens. + + + +![Rocket launch project](images/showcase_rocket.png) + +--- /task --- + +--- /no-print --- + +If you want to have more fun exploring Python, then you could try out any of [these projects](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + + + diff --git a/pl-PL/code/target-practice-solution/main.py b/pl-PL/code/target-practice-solution/main.py new file mode 100644 index 000000000..c4066550d --- /dev/null +++ b/pl-PL/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# Funkcja mouse_pressed pojawi się tutaj +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# Funkcja shoot_arrow pojawia się tutaj +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Rzeczy do zrobienia w każdej klatce + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + strzałka_strzałka() + + +# Zatrzymaj to, aby uruchomić swój kod +run(frame_rate=2) diff --git a/pl-PL/code/target-practice-solution/project_config.yml b/pl-PL/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..16159cfe0 --- /dev/null +++ b/pl-PL/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Przykład praktyki docelowej' +identifier: 'target-practice-solution' +type: 'python' diff --git a/pl-PL/code/target-practice-starter/main.py b/pl-PL/code/target-practice-starter/main.py new file mode 100644 index 000000000..929006b47 --- /dev/null +++ b/pl-PL/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# Funkcja mouse_pressed pojawi się tutaj + + +# Funkcja shoot_arrow pojawia się tutaj + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Rzeczy do zrobienia w każdej klatce + fill("cyan") + rect(0, 0, 400, 250) + + +# Zatrzymaj to, aby uruchomić swój kod +run(frame_rate=2) diff --git a/pl-PL/code/target-practice-starter/project_config.yml b/pl-PL/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..7bd406455 --- /dev/null +++ b/pl-PL/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Praktyka docelowa" +identifier: 'target-practice-starter' +type: 'python' diff --git a/pl-PL/images/alternative-colours.png b/pl-PL/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/pl-PL/images/alternative-colours.png differ diff --git a/pl-PL/images/animation_bg_erase.gif b/pl-PL/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/pl-PL/images/animation_bg_erase.gif differ diff --git a/pl-PL/images/animation_no_bg_erase.gif b/pl-PL/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/pl-PL/images/animation_no_bg_erase.gif differ diff --git a/pl-PL/images/arrow-centre.png b/pl-PL/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/pl-PL/images/arrow-centre.png differ diff --git a/pl-PL/images/arrow-middle.png b/pl-PL/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/pl-PL/images/arrow-middle.png differ diff --git a/pl-PL/images/arrow-target.png b/pl-PL/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/pl-PL/images/arrow-target.png differ diff --git a/pl-PL/images/background.png b/pl-PL/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/pl-PL/images/background.png differ diff --git a/pl-PL/images/banner.png b/pl-PL/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/pl-PL/images/banner.png differ diff --git a/pl-PL/images/blue-circle.png b/pl-PL/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/pl-PL/images/blue-circle.png differ diff --git a/pl-PL/images/blue-points.png b/pl-PL/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/pl-PL/images/blue-points.png differ diff --git a/pl-PL/images/blue_circle_points.gif b/pl-PL/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/pl-PL/images/blue_circle_points.gif differ diff --git a/pl-PL/images/bottom-right.png b/pl-PL/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/pl-PL/images/bottom-right.png differ diff --git a/pl-PL/images/centre.png b/pl-PL/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/pl-PL/images/centre.png differ diff --git a/pl-PL/images/circle-coords.png b/pl-PL/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/pl-PL/images/circle-coords.png differ diff --git a/pl-PL/images/coords_animation.gif b/pl-PL/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/pl-PL/images/coords_animation.gif differ diff --git a/pl-PL/images/difficulty-setting.png b/pl-PL/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/pl-PL/images/difficulty-setting.png differ diff --git a/pl-PL/images/fire_arrow.gif b/pl-PL/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/pl-PL/images/fire_arrow.gif differ diff --git a/pl-PL/images/five_circles.png b/pl-PL/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/pl-PL/images/five_circles.png differ diff --git a/pl-PL/images/green-grass.png b/pl-PL/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/pl-PL/images/green-grass.png differ diff --git a/pl-PL/images/grey-circle.png b/pl-PL/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/pl-PL/images/grey-circle.png differ diff --git a/pl-PL/images/grey-points.png b/pl-PL/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/pl-PL/images/grey-points.png differ diff --git a/pl-PL/images/initial_target.png b/pl-PL/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/pl-PL/images/initial_target.png differ diff --git a/pl-PL/images/missed-points.png b/pl-PL/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/pl-PL/images/missed-points.png differ diff --git a/pl-PL/images/missed_no_points.gif b/pl-PL/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/pl-PL/images/missed_no_points.gif differ diff --git a/pl-PL/images/outline-circles.png b/pl-PL/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/pl-PL/images/outline-circles.png differ diff --git a/pl-PL/images/points-scored.gif b/pl-PL/images/points-scored.gif new file mode 100644 index 000000000..3fbe161a8 Binary files /dev/null and b/pl-PL/images/points-scored.gif differ diff --git a/pl-PL/images/quiz-colour.png b/pl-PL/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/pl-PL/images/quiz-colour.png differ diff --git a/pl-PL/images/random-side.png b/pl-PL/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/pl-PL/images/random-side.png differ diff --git a/pl-PL/images/rectangle-diagram.png b/pl-PL/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/pl-PL/images/rectangle-diagram.png differ diff --git a/pl-PL/images/showcase_rocket.png b/pl-PL/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/pl-PL/images/showcase_rocket.png differ diff --git a/pl-PL/images/showcase_static.png b/pl-PL/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/pl-PL/images/showcase_static.png differ diff --git a/pl-PL/images/sky_coords.png b/pl-PL/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/pl-PL/images/sky_coords.png differ diff --git a/pl-PL/images/sky_stroke.png b/pl-PL/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/pl-PL/images/sky_stroke.png differ diff --git a/pl-PL/images/stand_coords.png b/pl-PL/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/pl-PL/images/stand_coords.png differ diff --git a/pl-PL/images/step_4_preview.gif b/pl-PL/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/pl-PL/images/step_4_preview.gif differ diff --git a/pl-PL/images/step_5_preview.gif b/pl-PL/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/pl-PL/images/step_5_preview.gif differ diff --git a/pl-PL/images/target-stand.png b/pl-PL/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/pl-PL/images/target-stand.png differ diff --git a/pl-PL/images/target_area.png b/pl-PL/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/pl-PL/images/target_area.png differ diff --git a/pl-PL/images/target_printed.gif b/pl-PL/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/pl-PL/images/target_printed.gif differ diff --git a/pl-PL/images/three-circles.png b/pl-PL/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/pl-PL/images/three-circles.png differ diff --git a/pl-PL/images/top-left.png b/pl-PL/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/pl-PL/images/top-left.png differ diff --git a/pl-PL/images/triangles-coords.png b/pl-PL/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/pl-PL/images/triangles-coords.png differ diff --git a/pl-PL/images/upgrade-ideas.png b/pl-PL/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/pl-PL/images/upgrade-ideas.png differ diff --git a/pl-PL/images/yellow-points.png b/pl-PL/images/yellow-points.png new file mode 100644 index 000000000..0c461812c Binary files /dev/null and b/pl-PL/images/yellow-points.png differ diff --git a/pl-PL/meta.yml b/pl-PL/meta.yml new file mode 100644 index 000000000..bfc4b64f6 --- /dev/null +++ b/pl-PL/meta.yml @@ -0,0 +1,41 @@ +--- +title: Praktyka docelowa +hero_image: images/banner.png +description: Użyj Pythona, aby narysować cel i zdobywać punkty, uderzając go strzałkami +meta_title: Projekty kodowania w Pythonie dla dzieci i młodzieży | Praktyka docelowa +meta_description: Naucz się języka Python z projektami programistycznymi Fundacji Raspberry Pi dla dzieci i młodzieży. Użyj Pythona, aby narysować cel i zdobywać punkty, uderzając go strzałkami. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: What you will make + - + title: Draw the grass + - + title: Narysuj swój cel + completion: + - engaged + - + title: Add an arrow + - + title: What colour did you hit? + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Challenge + challenge: true + - + title: What can you do now? diff --git a/pl-PL/python-comments-demo.txt b/pl-PL/python-comments-demo.txt new file mode 100644 index 000000000..61c071425 --- /dev/null +++ b/pl-PL/python-comments-demo.txt @@ -0,0 +1,73 @@ +Tutaj skonfiguruj swoją grę + +szerokość i wysokość ekranu + +Rzeczy do zrobienia w każdej klatce + +Czerwony = 92, zielony = 204, niebieski = 206 + +Ustaw kolor wypełnienia na trawę + +x, y, szerokość, wysokość + +Ustaw kolor wypełnienia stojaka na drewno + +Ustaw kolor wypełnienia okręgu na zewnętrzny + +x, y, szerokość okręgu + +Niebieski + +Czerwony + +Żółty + +Ustaw kolor wypełnienia okręgu na wewnętrzny + +Wewnętrzny okrąg - x, y, szerokość okręgu + +Ustaw kolor wypełnienia okręgu na środkowy + +Środkowe koło - x, y, szerokość okręgu + +Pojawi się tutaj funkcja shoot_arrow + +Przechowuj losową liczbę z zakresu od 100 do 300 + +Ustaw strzałkę, aby wypełnić kolor na drewno + +Narysuj małe kółko o losowych współrzędnych + +Zdobądź kolor uderzenia + +Tutaj pojawi się funkcja Mouse_pressed + +Może być używany w innych funkcjach + +Zapisz kolor przed narysowaniem strzałki + +Podobnie jak funkcje, polecenia „jeśli” są wcięte + +Importuj kod biblioteki + +Zachowaj to, aby uruchomić swój kod + +Definicje zgodności z biblioteką przetwarzania p5py + +Kształt + +Czcionki + +Tekst + +Kolor + +Obrazy + +Środowisko + +Przekształć + +Klawiatura + +Ustaw kolor wypełnienia na trawę diff --git a/pl-PL/python-comments.txt b/pl-PL/python-comments.txt new file mode 100644 index 000000000..d356f900b --- /dev/null +++ b/pl-PL/python-comments.txt @@ -0,0 +1,27 @@ +Rzeczy do zrobienia w każdej klatce + +Draw the inner circle + +Draw the middle circle + +Pojawi się tutaj funkcja shoot_arrow + +Tutaj pojawi się funkcja Mouse_pressed + +Trafiłeś w zewnętrzne koło, 50 punktów! + +Trafiłeś w wewnętrzne koło, 200 punktów! + +Trafiłeś na środek, 500 punktów! + +You hit the middle, 500 points! + +Przegapiłeś! Brak punktów! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/pl-PL/python-translatable-demo.txt b/pl-PL/python-translatable-demo.txt new file mode 100644 index 000000000..a40a5f14f --- /dev/null +++ b/pl-PL/python-translatable-demo.txt @@ -0,0 +1,37 @@ +drewno + +niebo + +trawa + +zewnętrzny + +wewnętrzny + +środkowy + +strzałka_strzałka + +arrow_x + +arrow_y + +hit_color + +Trafiłeś w zewnętrzne koło, 50 punktów! + +Trafiłeś w wewnętrzne koło, 200 punktów! + +Trafiłeś na środek, 500 punktów! + +Przegapiłeś! Brak punktów! + +Super szybki + +Dość szybko + +Bardzo szybko + +Prędkość nie rozpoznana! + +prędkość diff --git a/pl-PL/python-translatable.txt b/pl-PL/python-translatable.txt new file mode 100644 index 000000000..ec359d075 --- /dev/null +++ b/pl-PL/python-translatable.txt @@ -0,0 +1,9 @@ +strzałka_strzałka + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/pl-PL/quiz1/question_1.md b/pl-PL/quiz1/question_1.md new file mode 100644 index 000000000..b52c1ec43 --- /dev/null +++ b/pl-PL/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Szybki quiz + +Odpowiedz na trzy pytania. Istnieją wskazówki, które poprowadzą Cię do prawidłowej odpowiedzi. + +Po udzieleniu odpowiedzi na każde pytanie kliknij ** Sprawdź moją odpowiedź **. + +Miłej zabawy! + +--- question --- +--- +legend: Pytanie 1 z 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +Zgadza się. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Nie do końca. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Nie do końca. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Nie do końca. Funkcja circle() zostanie użyta do narysowania koła. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/pl-PL/quiz1/question_2.md b/pl-PL/quiz1/question_2.md new file mode 100644 index 000000000..19b4352e1 --- /dev/null +++ b/pl-PL/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Pytanie 2 z 3 +--- + +W swoim projekcie użyłeś warunków ` ` , ` ` i ` ` , aby sprawdzić, na którym kolorze wylądowała strzałka. + +W poniższym przykładzie zmienna o nazwie ` ` ma zapisaną w niej liczbę ` `. Co zostanie wydrukowane w obszarze wydruku po uruchomieniu polecenia ` `? + +--- code --- +--- +language: python +--- +prędkość = 6 + +if prędkość == 7: Print('Super szybki') prędkość elif == 5: Print('dość szybko') prędkość elif == 6: Print('bardzo szybko') inaczej: Print('Prędkość nierozpoznana!') + +--- /code --- + +--- choices --- + +- (X) ` bardzo szybki ` + + --- feedback --- + + Zgadza się! Zmienna ** ** została przypisana wartość ` 6 `, która sprawia, że ` speed == 6 ` warunek ** ** i drukuje ` bardzo szybko `. + + --- /feedback --- + +- ( ) Prędkość ` nie została rozpoznana!` + + --- feedback --- + + Nie do końca, spójrz na wartość przypisaną do zmiennej ** **. + + --- /feedback --- + +- ( ) Nic nie zostanie wydrukowane + + --- feedback --- + + Spróbuj ponownie, ` ` jest używany jako ostateczna opcja, gdy wszystkie powyższe warunki są fałszywe. Sprawdź ponownie warunki, czy któryś z warunków jest prawdziwy? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/pl-PL/quiz1/question_3.md b/pl-PL/quiz1/question_3.md new file mode 100644 index 000000000..e37f22706 --- /dev/null +++ b/pl-PL/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Pytanie 3 z 3 +--- + +Okrąg jest rysowany przy użyciu następującego kodu: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Które z poniższych obrazów pokazują prawidłową pozycję tego okręgu w obszarze wyjściowym? + +--- choices --- + +- ( ) ![Zielone kółko wyśrodkowane w prawym dolnym rogu obszaru wyjściowego.](images/bottom-right.png) + + --- feedback --- + + Nie do końca, aby wyśrodkować okrąg w prawym dolnym rogu, współrzędne musiałyby być takie same jak rozmiar ekranu. W tym przykładzie elipsa byłaby ` circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Zielone kółko wyśrodkowane pośrodku obszaru wyjściowego.](images/centre.png) + + --- feedback --- + + Nie do końca, aby wyśrodkować okrąg na środku, współrzędne musiałyby być o połowę mniejsze od rozmiaru ekranu. W tym przykładzie ` circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Zielone kółko wyśrodkowane w lewym górnym rogu obszaru wyjściowego.](images/top-left.png) + + --- feedback --- + + Zgadza się! Ten okrąg jest wyśrodkowany w współrzędnych (0,0), lewym górnym rogu ekranu. + + --- /feedback --- + +- ( ) ![Zielone kółko wyśrodkowane w kierunku prawej górnej części obszaru wyjściowego.](images/random-side.png) + + --- feedback --- + + Nie, to koło będzie miało kod ` circle(350, 150, 300)`, który wyśrodkuje go w kierunku prawego górnego rogu ekranu. Współrzędna ` ` określa odległość elipsy na ekranie, a współrzędna `.` określa odległość ekranu od niego do dołu. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/pl-PL/resources/main.py b/pl-PL/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/pl-PL/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/pl-PL/resources/p5.py b/pl-PL/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/pl-PL/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/pl-PL/step_1.md b/pl-PL/step_1.md new file mode 100644 index 000000000..1d7d0114e --- /dev/null +++ b/pl-PL/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Use Python to draw a target and score points by hitting it with arrows. + +--- print-only --- + +![Cel łuczniczy z punktem uderzenia na zewnętrznym kole. Tekst "trafiłeś w zewnętrzne koło, 50 punktów!" jest wyświetlany poniżej](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Kliknij przycisk **Run** poniżej, aby rozpocząć grę. Kiedy kropka pojawi się na obiekcie docelowym ?, kliknij mysz (lub stuknij w tablet), aby wystrzelić strzałkę. + + +
+
+ +--- /no-print --- + +
+ Weź naszą ankietę , aby pomóc ulepszyć nasz edytor kodu! +
+ + + diff --git a/pl-PL/step_2.md b/pl-PL/step_2.md new file mode 100644 index 000000000..99541f68f --- /dev/null +++ b/pl-PL/step_2.md @@ -0,0 +1,37 @@ +## Narysuj trawę + +--- task --- + +Otwórz projekt [ Praktyka docelowa ](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![Obszar wyjściowy z prostokątem w kolorze nieba nad prostokątem w kolorze trawy, aby utworzyć tło. Lewy górny róg prostokąta jest oznaczony jako x=0, y=250 to jest początek początku prostokąta. Szerokość jest podświetlona jako 400, a wysokość jako 150. Wyświetlany jest kod rect(0, 250, 400, 150).](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to view the background. + +![Obszar wyjściowy z prostokątem w kolorze nieba nad prostokątem w kolorze trawy, aby utworzyć tło.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/pl-PL/step_3.md b/pl-PL/step_3.md new file mode 100644 index 000000000..b83508907 --- /dev/null +++ b/pl-PL/step_3.md @@ -0,0 +1,115 @@ +## Narysuj swój cel + +
+
+Twoja gra potrzebuje celu do strzelania strzałkami. +
+
+ +![Obszar wyjściowy z obiektem docelowym i stojakiem.](images/three-cirles.png){:width="300px"} + +
+
+ +### Narysuj stojak trójkątny + +--- task --- + +Set the fill colour to `brown`. + +Narysuj trójkąt używając współrzędnych x i y dla każdego z rogów. + +![Brązowy trójkąt na trawie i na niebie z punktami współrzędnych oznaczonymi jako 150, 350 i 200, 150 i 250, 350). Narożniki płótna są również oznaczone jako x=0, y=0 w lewym górnym rogu i x=400, y=400 w prawym dolnym rogu.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![Brązowy trójkąt na trawie i na tle nieba.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Narysuj docelowe okręgi + +--- task --- + +Największa część celu to niebieski okrąg ** **. + +Ustaw kolor wypełnienia na ` `. + +Narysuj okrąg ze współrzędnymi x i y dla jego środka i szerokości. + +![Brązowy trójkąt i niebieskie kółko na trawie i na niebie. Okrąg jest oznaczony współrzędnymi x=200, y=200 jako środek i szerokość okręgu 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +** Test:** Uruchom swój kod, aby zobaczyć pierwsze duże niebieskie kółko. + +Niebieskie kółko zostało narysowane za stojakiem, więc jest z przodu. + +![Brązowy trójkąt i niebieskie kółko na trawie i na niebie.](images/blue-circle.png){:width="400px"} + +--- /task --- + +Cel składa się z okręgów o różnych rozmiarach o tych samych współrzędnych środka (200, 200). + +--- task --- + +** ** kolorowe kółka dla wewnętrznej i środkowej części celu. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![Brązowy trójkąt z trzema kolorowymi kółkami na trawie i na tle nieba.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/pl-PL/step_4.md b/pl-PL/step_4.md new file mode 100644 index 000000000..99919f193 --- /dev/null +++ b/pl-PL/step_4.md @@ -0,0 +1,88 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![Target, z brązową strzałką koła pojawiającą się w różnych pozycjach.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# Pojawi się tutaj funkcja shoot_arrow +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![Animacja celu z brązową strzałką koła pojawiającą się w różnych pozycjach.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/pl-PL/step_5.md b/pl-PL/step_5.md new file mode 100644 index 000000000..69d6e03fe --- /dev/null +++ b/pl-PL/step_5.md @@ -0,0 +1,80 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# Tutaj pojawi się funkcja Mouse_pressed +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/pl-PL/step_6.md b/pl-PL/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/pl-PL/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/pl-PL/step_7.md b/pl-PL/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/pl-PL/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/pl-PL/step_8.md b/pl-PL/step_8.md new file mode 100644 index 000000000..910635d28 --- /dev/null +++ b/pl-PL/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/pl-PL/step_9.md b/pl-PL/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/pl-PL/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/pt-BR/code/target-practice-solution/main.py b/pt-BR/code/target-practice-solution/main.py new file mode 100644 index 000000000..4701c054a --- /dev/null +++ b/pt-BR/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +# Importa código da biblioteca! + +from p5 import * +from random import randint + + +# A função mouse_pressed vai aqui +def mouse_pressed(): + # print('🎯') + if cor_acerto == Color('blue').hex: # Como as funções, as instruções 'if' são indentadas + print('Você acertou o círculo externo, 50 pontos!') + elif cor_acerto == Color('red').hex: + print('Você acertou o círculo interno, 200 pontos!') + elif cor_acerto == Color('yellow').hex: + print('Você acertou o meio, 500 pontos!') + else: + print('Você errou! Sem pontos!') + + +# A função atirar_flecha vai aqui +def atirar_flecha(): + global hit_colour + flecha_x = randint(100, 300) # Armazena um número aleatório entre 100 e 300 + flecha_y = randint(100, 300) # Armazena um número aleatório entre 100 e 300 + cor_acerto = get(flecha_x, flecha_y).hex # Obtém a cor acertada + # print(hit_colour) + fill('sienna') # Defina a cor de preenchimento da flecha como marrom + circle(flecha_x, flecha_y, 15) # Desenha um pequeno círculo em coordenadas aleatórias + + +def setup(): + # Configure seu jogo aqui + size(400, 400) # largura e altura + no_stroke() + + +def draw(): + # Coisas para fazer em cada quadro + fill('cyan') + rect(0, 0, 400, 250) # Céu + fill('lightgreen') + rect(0, 250, 400, 150) # Grama + fill('sienna') + triangle(150, 350, 200, 150, 250, 350) # Suporte + fill('blue') + circle(200, 200, 170) # Círculo externo + fill('red') + circle(200, 200, 110) # Círculo interno + fill('yellow') + circle(200, 200, 30) # Círculo do meio + atirar_flecha() + + +# Mantenha isto para executar seu código +run(frame_rate=2) diff --git a/pt-BR/code/target-practice-solution/project_config.yml b/pt-BR/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..a2a3181ad --- /dev/null +++ b/pt-BR/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Tiro ao alvo - Exemplo' +identifier: 'target-practice-solution' +type: 'python' diff --git a/pt-BR/code/target-practice-starter/main.py b/pt-BR/code/target-practice-starter/main.py new file mode 100644 index 000000000..85ac867bb --- /dev/null +++ b/pt-BR/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +# Importar código da biblioteca +from p5 import * +from random import randint + +# A função mouse_pressed vai aqui + + +# A função atirar_flecha vai aqui + + +def setup(): + # Configure seu jogo aqui + size(400, 400) # largura e altura da tela + no_stroke() + + +def draw(): + # Coisas para fazer em cada quadro + fill("cyan") + rect(0, 0, 400, 250) + + +# Mantenha isto para executar seu código +run(frame_rate=2) diff --git a/pt-BR/code/target-practice-starter/project_config.yml b/pt-BR/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..befdca07c --- /dev/null +++ b/pt-BR/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Tiro ao alvo" +identifier: 'target-practice-starter' +type: 'python' diff --git a/pt-BR/images/alternative-colours.png b/pt-BR/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/pt-BR/images/alternative-colours.png differ diff --git a/pt-BR/images/animation_bg_erase.gif b/pt-BR/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/pt-BR/images/animation_bg_erase.gif differ diff --git a/pt-BR/images/animation_no_bg_erase.gif b/pt-BR/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/pt-BR/images/animation_no_bg_erase.gif differ diff --git a/pt-BR/images/arrow-centre.png b/pt-BR/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/pt-BR/images/arrow-centre.png differ diff --git a/pt-BR/images/arrow-middle.png b/pt-BR/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/pt-BR/images/arrow-middle.png differ diff --git a/pt-BR/images/arrow-target.png b/pt-BR/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/pt-BR/images/arrow-target.png differ diff --git a/pt-BR/images/background.png b/pt-BR/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/pt-BR/images/background.png differ diff --git a/pt-BR/images/banner.png b/pt-BR/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/pt-BR/images/banner.png differ diff --git a/pt-BR/images/blue-circle.png b/pt-BR/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/pt-BR/images/blue-circle.png differ diff --git a/pt-BR/images/blue-points.png b/pt-BR/images/blue-points.png new file mode 100644 index 000000000..c8f5b941c Binary files /dev/null and b/pt-BR/images/blue-points.png differ diff --git a/pt-BR/images/blue_circle_points.gif b/pt-BR/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/pt-BR/images/blue_circle_points.gif differ diff --git a/pt-BR/images/bottom-right.png b/pt-BR/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/pt-BR/images/bottom-right.png differ diff --git a/pt-BR/images/centre.png b/pt-BR/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/pt-BR/images/centre.png differ diff --git a/pt-BR/images/circle-coords.png b/pt-BR/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/pt-BR/images/circle-coords.png differ diff --git a/pt-BR/images/coords_animation.gif b/pt-BR/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/pt-BR/images/coords_animation.gif differ diff --git a/pt-BR/images/difficulty-setting.png b/pt-BR/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/pt-BR/images/difficulty-setting.png differ diff --git a/pt-BR/images/fire_arrow.gif b/pt-BR/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/pt-BR/images/fire_arrow.gif differ diff --git a/pt-BR/images/five_circles.png b/pt-BR/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/pt-BR/images/five_circles.png differ diff --git a/pt-BR/images/green-grass.png b/pt-BR/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/pt-BR/images/green-grass.png differ diff --git a/pt-BR/images/grey-circle.png b/pt-BR/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/pt-BR/images/grey-circle.png differ diff --git a/pt-BR/images/grey-points.png b/pt-BR/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/pt-BR/images/grey-points.png differ diff --git a/pt-BR/images/initial_target.png b/pt-BR/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/pt-BR/images/initial_target.png differ diff --git a/pt-BR/images/missed-points.png b/pt-BR/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/pt-BR/images/missed-points.png differ diff --git a/pt-BR/images/missed_no_points.gif b/pt-BR/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/pt-BR/images/missed_no_points.gif differ diff --git a/pt-BR/images/outline-circles.png b/pt-BR/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/pt-BR/images/outline-circles.png differ diff --git a/pt-BR/images/points-scored.gif b/pt-BR/images/points-scored.gif new file mode 100644 index 000000000..ab9509e5e Binary files /dev/null and b/pt-BR/images/points-scored.gif differ diff --git a/pt-BR/images/quiz-colour.png b/pt-BR/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/pt-BR/images/quiz-colour.png differ diff --git a/pt-BR/images/random-side.png b/pt-BR/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/pt-BR/images/random-side.png differ diff --git a/pt-BR/images/rectangle-diagram.png b/pt-BR/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/pt-BR/images/rectangle-diagram.png differ diff --git a/pt-BR/images/showcase_rocket.png b/pt-BR/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/pt-BR/images/showcase_rocket.png differ diff --git a/pt-BR/images/showcase_static.png b/pt-BR/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/pt-BR/images/showcase_static.png differ diff --git a/pt-BR/images/sky_coords.png b/pt-BR/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/pt-BR/images/sky_coords.png differ diff --git a/pt-BR/images/sky_stroke.png b/pt-BR/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/pt-BR/images/sky_stroke.png differ diff --git a/pt-BR/images/stand_coords.png b/pt-BR/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/pt-BR/images/stand_coords.png differ diff --git a/pt-BR/images/step_4_preview.gif b/pt-BR/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/pt-BR/images/step_4_preview.gif differ diff --git a/pt-BR/images/step_5_preview.gif b/pt-BR/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/pt-BR/images/step_5_preview.gif differ diff --git a/pt-BR/images/target-stand.png b/pt-BR/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/pt-BR/images/target-stand.png differ diff --git a/pt-BR/images/target_area.png b/pt-BR/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/pt-BR/images/target_area.png differ diff --git a/pt-BR/images/target_printed.gif b/pt-BR/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/pt-BR/images/target_printed.gif differ diff --git a/pt-BR/images/three-circles.png b/pt-BR/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/pt-BR/images/three-circles.png differ diff --git a/pt-BR/images/top-left.png b/pt-BR/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/pt-BR/images/top-left.png differ diff --git a/pt-BR/images/triangles-coords.png b/pt-BR/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/pt-BR/images/triangles-coords.png differ diff --git a/pt-BR/images/upgrade-ideas.png b/pt-BR/images/upgrade-ideas.png new file mode 100644 index 000000000..3778a85f1 Binary files /dev/null and b/pt-BR/images/upgrade-ideas.png differ diff --git a/pt-BR/images/yellow-points.png b/pt-BR/images/yellow-points.png new file mode 100644 index 000000000..6ef90ca8e Binary files /dev/null and b/pt-BR/images/yellow-points.png differ diff --git a/pt-BR/meta.yml b/pt-BR/meta.yml new file mode 100644 index 000000000..6fd3b75f6 --- /dev/null +++ b/pt-BR/meta.yml @@ -0,0 +1,41 @@ +--- +title: Tiro ao alvo +hero_image: images/banner.png +description: Use Python para desenhar um alvo e marcar pontos acertando-o com flechas +meta_title: Projetos de codificação Python para crianças e adolescentes | Tiro ao alvo +meta_description: Aprenda Python com os projetos de codificação da Raspberry Pi Foundation para crianças e adolescentes. Use Python para desenhar um alvo e marcar pontos acertando-o com flechas. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Você vai fazer + - + title: Crie um plano de fundo + - + title: Desenhe o seu alvo + completion: + - engaged + - + title: Atire sua flecha + - + title: Marque pontos + - + title: Teste rápido + completion: + - external + - + title: Melhore o seu projeto + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: E agora? + challenge: true + - + title: What can you do now? diff --git a/pt-BR/python-comments-demo.txt b/pt-BR/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/pt-BR/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/pt-BR/python-comments.txt b/pt-BR/python-comments.txt new file mode 100644 index 000000000..739fc7b94 --- /dev/null +++ b/pt-BR/python-comments.txt @@ -0,0 +1,27 @@ +Coisas para fazer em cada quadro + +Draw the inner circle + +Draw the middle circle + +A função atirar_flecha vai aqui + +A função mouse_pressed vai aqui + +Você acertou o círculo externo, 50 pontos! + +Você acertou o círculo interno, 200 pontos! + +Você acertou o meio, 500 pontos! + +You hit the middle, 500 points! + +Você errou! Sem pontos! + +Super rápida + +Bem rápida + +Muito rápida + +Velocidade não reconhecida! \ No newline at end of file diff --git a/pt-BR/python-translatable-demo.txt b/pt-BR/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/pt-BR/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/pt-BR/python-translatable.txt b/pt-BR/python-translatable.txt new file mode 100644 index 000000000..5175cec1e --- /dev/null +++ b/pt-BR/python-translatable.txt @@ -0,0 +1,9 @@ +atirar_flecha + +flecha_x + +flecha_y + +cor_acerto + +velocidade \ No newline at end of file diff --git a/pt-BR/quiz1/question_1.md b/pt-BR/quiz1/question_1.md new file mode 100644 index 000000000..d00a94bdf --- /dev/null +++ b/pt-BR/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Teste rápido + +Responda às três perguntas. Há dicas para guiá-lo para a resposta correta. + +Após responder cada pergunta, clique em **Ver minha resposta**. + +Divirta-se! + +--- question --- +--- +legend: Pergunta 1 de 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +Está correto. Uma borda preta será desenhada ao redor de suas formas se você não usar esta função. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Não exatamente. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- ( ) Preenche a forma com uma determinada cor. + + --- feedback --- + + Não exatamente. A função fill() faz isso e geralmente inclui uma cor fornecida. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Não exatamente. A função Circle() seria usada para desenhar um círculo. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/pt-BR/quiz1/question_2.md b/pt-BR/quiz1/question_2.md new file mode 100644 index 000000000..30093ec9a --- /dev/null +++ b/pt-BR/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Pergunta 2 de 3 +--- + +Em seu projeto, você usou as condições `if` , `elif` e `else` para verificar em qual cor a flecha acertou. + +No exemplo abaixo, uma variável chamada `velocidade` possui o número `6` armazenado nela. Quando esta instrução `if` for executada, o que será impresso na área de saída? + +--- code --- +--- +language: python +--- +velocidade = 6 + +if velocidade == 7: print('Super rápido') elif velocidade == 5: print('Bem rápido') elif velocidade == 6: print('Muito rápido') else: print('Velocidade não reconhecida!') + +--- /code --- + +--- choices --- + +- (x) `Muito rápida` + + --- feedback --- + + Está correto! A variável **velocidade** recebeu o valor `6`, o que torna a condição `velocidade == 6` **Verdadeira** e imprime `Muito rápida`. + + --- /feedback --- + +- ( ) `Velocidade não reconhecida!` + + --- feedback --- + + Não necessariamente. Veja o valor atribuído à variável **velocidade**. + + --- /feedback --- + +- ( ) Nada é impresso + + --- feedback --- + + Tente novamente. `else` é usado como uma opção final para quando todas as condições acima forem falsas. Examine as condições novamente, algumas das condições são verdadeiras? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/pt-BR/quiz1/question_3.md b/pt-BR/quiz1/question_3.md new file mode 100644 index 000000000..c2973dd3b --- /dev/null +++ b/pt-BR/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Pergunta 3 de 3 +--- + +Um círculo é desenhado usando o seguinte código: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Qual das imagens abaixo mostra a posição correta deste círculo na área de saída? + +--- choices --- + +- ( ) ![Um círculo verde centralizado no canto inferior direito da área de saída.](images/bottom-right.png) + + --- feedback --- + + Não necessariamente. Para centralizar o círculo no canto inferior direito, as coordenadas precisariam ser iguais ao tamanho da tela. Neste exemplo, a elipse seria `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Um círculo verde centralizado no meio da área de saída.](images/centre.png) + + --- feedback --- + + Não necessariamente. Para centralizar o círculo no meio, as coordenadas precisariam ser metade do tamanho da tela. Neste exemplo, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Um círculo verde centralizado no canto superior esquerdo da área de saída.](images/top-left.png) + + --- feedback --- + + Está correto! Este círculo está centralizado nas coordenadas (0,0), no canto superior esquerdo da tela. + + --- /feedback --- + +- ( ) ![Um círculo verde centralizado no canto superior direito da área de saída.](images/random-side.png) + + --- feedback --- + + Não, este círculo teria o código `circle(350, 150, 300)` para centralizá-lo no canto superior direito da tela. A coordenada `x` é a posição horizontal da elipse na tela, e a coordenada `y` é posição vertical da elipse na tela. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/pt-BR/resources/main.py b/pt-BR/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/pt-BR/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/pt-BR/resources/p5.py b/pt-BR/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/pt-BR/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/pt-BR/step_1.md b/pt-BR/step_1.md new file mode 100644 index 000000000..ec8c44176 --- /dev/null +++ b/pt-BR/step_1.md @@ -0,0 +1,29 @@ +## O que você vai fazer + +Use Python, com a biblioteca de gráficos `p5`, para desenhar um alvo e marcar pontos acertando-o com flechas. + +--- print-only --- + +![Um alvo de tiro com arco com um ponto de impacto no círculo externo. O texto 'Você atingiu o círculo externo, 50 pontos!' é exibido abaixo](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Clique no botão **Executar** abaixo para iniciar o jogo. Quando o ponto aparecer no alvo 🎯, clique com o mouse (ou toque no tablet) para disparar sua flecha. + + +
+
+ +--- /no-print --- + +
+ Responda à nossa pesquisa para ajudar a melhorar nosso Editor de código! +
+ + + diff --git a/pt-BR/step_2.md b/pt-BR/step_2.md new file mode 100644 index 000000000..0c21ca82c --- /dev/null +++ b/pt-BR/step_2.md @@ -0,0 +1,37 @@ +## Desenhe a grama + +--- task --- + +Abra o projeto [Tiro ao alvo inicial](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Adicione** código para desenhar um retângulo verde na parte inferior da tela. + +![A área de saída com um retângulo da cor do céu acima de um retângulo da cor da grama para criar o plano de fundo. O canto superior esquerdo do retângulo é marcado como x=0, y=250 esta é a origem do retângulo. A largura é destacada como 400 e a altura como 150. O código rect(0, 250, 400, 150) é mostrado.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 14 +line_highlights: 12 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Teste:** 🔄 Execute seu projeto novamente para visualizar o plano de fundo finalizado. + +![A área de saída com um retângulo da cor do céu acima de um retângulo da cor da grama para criar o plano de fundo.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/pt-BR/step_3.md b/pt-BR/step_3.md new file mode 100644 index 000000000..4f5a0fd2a --- /dev/null +++ b/pt-BR/step_3.md @@ -0,0 +1,117 @@ +## Desenhe o seu alvo + +
+
+Seu jogo precisa de um alvo para atirarmos as flechas. +
+
+ +![A área de saída com o alvo e suporte.](images/three-circles.png){:width="300px"} + +
+
+ +### Desenhe um suporte triangular + +--- task --- + +Defina a cor de preenchimento como `sienna` (marrom). + +Desenhe um triângulo usando as coordenadas x e y para cada um dos cantos. + +![Um triângulo marrom na grama e um céu com os pontos de coordenadas rotulados em 150, 350 e 200, 150 e 250, 350). Os cantos da tela também são rotulados como x=0, y=0 no canto superior esquerdo e x=400, y=400 no canto inferior direito.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 18 +line_highlights: 20, 21 +--- + + fill('lightgreen') # Define a cor de preenchimento da grama para verde claro + rect(0, 250, 400, 150) # Desenha um retângulo para a grama com estes valores para x, y, largura, altura + fill(' sienna') # Cor marrom + triangle(150, 350, 200, 150, 250, 350) # Desenha um triângulo para o suporte do alvo + +--- /code --- + +--- /task --- + +--- task --- + +**Teste:** 🔄 Execute seu código para ver o suporte para o seu alvo: + +![Um triângulo marrom na grama e um céu de fundo.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Desenhe os círculos do alvo + +--- task --- + +A maior parte do alvo é um **círculo** azul. + +Defina a cor de preenchimento como `azul`. + +Desenhe um círculo com coordenadas x e y para seu centro e largura. + +![Um triângulo marrom e um círculo azul na grama e um céu de fundo. O círculo é rotulado com as coordenadas x=200, y=200 como centro e a largura do círculo de 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 20 +line_highlights: 22, 23 +--- + + fill('sienna') # Cor marrom + triangle(150, 350, 200, 150, 250, 350) # Desenha um triângulo para o suporte do alvo + fill('blue') # Define a cor de preenchimento do círculo para azul + circle(200, 200, 170) # Desenha o círculo externo + +--- /code --- + +--- /task --- + +--- task --- + +**Teste:** Execute seu código para ver o primeiro grande círculo azul. + +O círculo azul foi desenhado depois do suporte, então fica na frente. + +![Um triângulo marrom e um círculo azul na grama e um céu de fundo.](images/blue-circle.png){:width="400px"} + +--- /task --- + +O alvo é feito de círculos de tamanhos diferentes com as mesmas coordenadas centrais (200, 200). + +--- task --- + +**Adicione** círculos coloridos para as partes interna e medianas do alvo. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 20 +line_highlights: 24, 25, 26, 27 +--- + + fill('sienna') # Cor marrom + triangle(150, 350, 200, 150, 250, 350) # Desenha um triângulo para o suporte do alvo + fill('blue') # Define a cor de preenchimento do círculo para azul + circle(200, 200, 170) # Desenha o círculo externo + fill('red') # Define a cor do preenchimento do círculo para vermelho + circle(200, 200, 110) # Desenha o círculo interno usando x, y, width + fill('yellow') # Define a cor de preenchimento do círculo para amarelo + circle(200, 200, 30) # Desenha o círculo do meio usando x, y, largura + +--- /code --- + +--- /task --- + +--- task --- + +**Teste:** 🔄 Execute seu projeto para ver o alvo com três círculos coloridos. + +![Um triângulo marrom com três círculos coloridos na grama e um céu de fundo.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/pt-BR/step_4.md b/pt-BR/step_4.md new file mode 100644 index 000000000..c691b2d37 --- /dev/null +++ b/pt-BR/step_4.md @@ -0,0 +1,95 @@ +## Atire a sua flecha + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![O alvo, com uma flecha circular marrom aparecendo em várias posições.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Adicione código para desenhar aleatoriamente um círculo marrom dentro de uma área de destino: + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 7 +line_highlights: 8-12 +--- +# A função atirar_flecha vai aqui +def atirar_flecha(): +flecha_x = randint(100, 300) # Armazena um número aleatório entre 100 e 300 +flecha_y = randint(100, 300) # Armazena um número aleatório entre 100 e 300 +fill('sienna') # Define a cor de preenchimento da flecha como marrom +circle(flecha_x, flecha_y, 15) # Desenha um pequeno círculo em coordenadas aleatórias + +--- /code --- + +--- /task --- + +--- task --- + +Vá para a função `draw` e invoque a sua nova função `atirar_flecha`. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 31 +line_highlights: 33 +--- + + fill('yellow') # Define a cor de preenchimento do círculo para amarelo + circle(200, 200, 30) # Desenha o círculo do meio usando x, y, width + atirar_flecha() + +--- /code --- + +--- /task --- + +--- task --- + +**Teste:** 🔄 Execute seu projeto. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 5 +line_highlights: 9, 12 +--- +def atirar_flecha(): global cor_acerto # Pode ser usado em outras funções +flecha_x = randint(100, 300) # Armazena um número aleatório entre 100 e 300 +flecha_y = randint(100, 300) # Armazena um número aleatório entre 100 e 300 cor_acerto = get(flecha_x, flecha_y).hex # Obtêm a cor do acerto +fill('sienna') # Define a cor de preenchimento da flecha como marrom +circle(flecha_x, flecha_y, 15) # Desenha um pequeno círculo em coordenadas aleatórias + +--- /code --- + +--- /task --- + + +--- task --- + + +**Teste:** 🔄 Execute seu projeto. You should see the arrow jump around the target. + +![Uma animação do alvo com uma seta circular marrom aparecendo em diversas posições.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/pt-BR/step_5.md b/pt-BR/step_5.md new file mode 100644 index 000000000..412080f43 --- /dev/null +++ b/pt-BR/step_5.md @@ -0,0 +1,79 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Exiba uma mensagem **if** a `cor_acerto` for igual à cor dos `círculos` externos (azul) 🎯. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): if cor_acerto == Color('blue').hex: +print('Você acertou o círculo externo, 50 pontos!') elif cor_acerto == Color('red').hex: print('Você acertou o círculo interno, 200 pontos!') elif cor_acerto == Color('yellow').hex: print('Você acertou o meio, 500 pontos!') + +--- /code --- + +**Depurar:** 🐞 Certifique-se de ter usado `.hex` para as cores dos **seus** círculos. + +--- /task --- + +--- task --- + +**Teste:** 🔄 Execute seu projeto. **Depurar:** 🐞 Verifique se você usou a grafia americana de 'Color' (sem 'u') e se 'Color' está em maiúscula. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 6 +line_highlights: 7, 8 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 5 +line_highlights: 9-12 +--- +# A função mouse_pressed vai aqui +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Teste:** 🔄 Execute seu projeto. Tente disparar a flecha nos círculos interno e do meio para ver suas mensagens. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/pt-BR/step_6.md b/pt-BR/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/pt-BR/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/pt-BR/step_7.md b/pt-BR/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/pt-BR/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/pt-BR/step_8.md b/pt-BR/step_8.md new file mode 100644 index 000000000..28ae6e382 --- /dev/null +++ b/pt-BR/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /no-print --- diff --git a/pt-BR/step_9.md b/pt-BR/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/pt-BR/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/ru-RU/code/target-practice-solution/main.py b/ru-RU/code/target-practice-solution/main.py new file mode 100644 index 000000000..9b71b07d4 --- /dev/null +++ b/ru-RU/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Import library code + +from p5 import * +from random import randint + + +# The mouse_pressed function goes here +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("You hit the outer circle, 50 points!") + elif hit_colour == Color("red").hex: + print("You hit the inner circle, 200 points!") + elif hit_colour == Color("yellow").hex: + print("You hit the middle, 500 points!") + else: + print("You missed! No points!") + + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Draw the inner circle + fill("yellow") + circle(200, 200, 30) # Draw the middle circle + shoot_arrow() + + +# Keep this to run your code +run(frame_rate=2) diff --git a/ru-RU/code/target-practice-solution/project_config.yml b/ru-RU/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..2c45eb56c --- /dev/null +++ b/ru-RU/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Target Practice Example' +identifier: 'target-practice-solution' +type: 'python' diff --git a/ru-RU/code/target-practice-starter/main.py b/ru-RU/code/target-practice-starter/main.py new file mode 100644 index 000000000..03f477ff0 --- /dev/null +++ b/ru-RU/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Import library code +from p5 import * +from random import randint + +# The mouse_pressed function goes here + + +# The shoot_arrow function goes here + + +def setup(): + # Set up your game here + size(400, 400) + no_stroke() + + +def draw(): + # Things to do in every frame + fill("cyan") + rect(0, 0, 400, 250) + + +# Keep this to run your code +run(frame_rate=2) diff --git a/ru-RU/code/target-practice-starter/project_config.yml b/ru-RU/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..1f6832901 --- /dev/null +++ b/ru-RU/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Target Practice" +identifier: 'target-practice-starter' +type: 'python' diff --git a/ru-RU/images/alternative-colours.png b/ru-RU/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/ru-RU/images/alternative-colours.png differ diff --git a/ru-RU/images/animation_bg_erase.gif b/ru-RU/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/ru-RU/images/animation_bg_erase.gif differ diff --git a/ru-RU/images/animation_no_bg_erase.gif b/ru-RU/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/ru-RU/images/animation_no_bg_erase.gif differ diff --git a/ru-RU/images/arrow-centre.png b/ru-RU/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/ru-RU/images/arrow-centre.png differ diff --git a/ru-RU/images/arrow-middle.png b/ru-RU/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/ru-RU/images/arrow-middle.png differ diff --git a/ru-RU/images/arrow-target.png b/ru-RU/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/ru-RU/images/arrow-target.png differ diff --git a/ru-RU/images/background.png b/ru-RU/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/ru-RU/images/background.png differ diff --git a/ru-RU/images/banner.png b/ru-RU/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/ru-RU/images/banner.png differ diff --git a/ru-RU/images/blue-circle.png b/ru-RU/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/ru-RU/images/blue-circle.png differ diff --git a/ru-RU/images/blue-points.png b/ru-RU/images/blue-points.png new file mode 100644 index 000000000..921b62ff2 Binary files /dev/null and b/ru-RU/images/blue-points.png differ diff --git a/ru-RU/images/blue_circle_points.gif b/ru-RU/images/blue_circle_points.gif new file mode 100644 index 000000000..e6308eb07 Binary files /dev/null and b/ru-RU/images/blue_circle_points.gif differ diff --git a/ru-RU/images/bottom-right.png b/ru-RU/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/ru-RU/images/bottom-right.png differ diff --git a/ru-RU/images/centre.png b/ru-RU/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/ru-RU/images/centre.png differ diff --git a/ru-RU/images/circle-coords.png b/ru-RU/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/ru-RU/images/circle-coords.png differ diff --git a/ru-RU/images/coords_animation.gif b/ru-RU/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/ru-RU/images/coords_animation.gif differ diff --git a/ru-RU/images/difficulty-setting.png b/ru-RU/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/ru-RU/images/difficulty-setting.png differ diff --git a/ru-RU/images/fire_arrow.gif b/ru-RU/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/ru-RU/images/fire_arrow.gif differ diff --git a/ru-RU/images/five_circles.png b/ru-RU/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/ru-RU/images/five_circles.png differ diff --git a/ru-RU/images/green-grass.png b/ru-RU/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/ru-RU/images/green-grass.png differ diff --git a/ru-RU/images/grey-circle.png b/ru-RU/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/ru-RU/images/grey-circle.png differ diff --git a/ru-RU/images/grey-points.png b/ru-RU/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/ru-RU/images/grey-points.png differ diff --git a/ru-RU/images/initial_target.png b/ru-RU/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/ru-RU/images/initial_target.png differ diff --git a/ru-RU/images/missed-points.png b/ru-RU/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/ru-RU/images/missed-points.png differ diff --git a/ru-RU/images/missed_no_points.gif b/ru-RU/images/missed_no_points.gif new file mode 100644 index 000000000..212ca30e4 Binary files /dev/null and b/ru-RU/images/missed_no_points.gif differ diff --git a/ru-RU/images/outline-circles.png b/ru-RU/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/ru-RU/images/outline-circles.png differ diff --git a/ru-RU/images/points-scored.gif b/ru-RU/images/points-scored.gif new file mode 100644 index 000000000..3fbe161a8 Binary files /dev/null and b/ru-RU/images/points-scored.gif differ diff --git a/ru-RU/images/quiz-colour.png b/ru-RU/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/ru-RU/images/quiz-colour.png differ diff --git a/ru-RU/images/random-side.png b/ru-RU/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/ru-RU/images/random-side.png differ diff --git a/ru-RU/images/rectangle-diagram.png b/ru-RU/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/ru-RU/images/rectangle-diagram.png differ diff --git a/ru-RU/images/showcase_rocket.png b/ru-RU/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/ru-RU/images/showcase_rocket.png differ diff --git a/ru-RU/images/showcase_static.png b/ru-RU/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/ru-RU/images/showcase_static.png differ diff --git a/ru-RU/images/sky_coords.png b/ru-RU/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/ru-RU/images/sky_coords.png differ diff --git a/ru-RU/images/sky_stroke.png b/ru-RU/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/ru-RU/images/sky_stroke.png differ diff --git a/ru-RU/images/stand_coords.png b/ru-RU/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/ru-RU/images/stand_coords.png differ diff --git a/ru-RU/images/step_4_preview.gif b/ru-RU/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/ru-RU/images/step_4_preview.gif differ diff --git a/ru-RU/images/step_5_preview.gif b/ru-RU/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/ru-RU/images/step_5_preview.gif differ diff --git a/ru-RU/images/target-stand.png b/ru-RU/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/ru-RU/images/target-stand.png differ diff --git a/ru-RU/images/target_area.png b/ru-RU/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/ru-RU/images/target_area.png differ diff --git a/ru-RU/images/target_printed.gif b/ru-RU/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/ru-RU/images/target_printed.gif differ diff --git a/ru-RU/images/three-circles.png b/ru-RU/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/ru-RU/images/three-circles.png differ diff --git a/ru-RU/images/top-left.png b/ru-RU/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/ru-RU/images/top-left.png differ diff --git a/ru-RU/images/triangles-coords.png b/ru-RU/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/ru-RU/images/triangles-coords.png differ diff --git a/ru-RU/images/upgrade-ideas.png b/ru-RU/images/upgrade-ideas.png new file mode 100644 index 000000000..083f82320 Binary files /dev/null and b/ru-RU/images/upgrade-ideas.png differ diff --git a/ru-RU/images/yellow-points.png b/ru-RU/images/yellow-points.png new file mode 100644 index 000000000..0c461812c Binary files /dev/null and b/ru-RU/images/yellow-points.png differ diff --git a/ru-RU/meta.yml b/ru-RU/meta.yml new file mode 100644 index 000000000..e56ce34a6 --- /dev/null +++ b/ru-RU/meta.yml @@ -0,0 +1,41 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +meta_title: Python coding projects for kids and teens | Target practice +meta_description: Learn Python with the Raspberry Pi Foundation's coding projects for kids and teens. Use Python to draw a target and score points by hitting it with arrows. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: What you will make + - + title: Draw the grass + - + title: Draw your target + completion: + - engaged + - + title: Add an arrow + - + title: What colour did you hit? + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Challenge + challenge: true + - + title: What can you do now? diff --git a/ru-RU/python-comments-demo.txt b/ru-RU/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/ru-RU/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/ru-RU/python-comments.txt b/ru-RU/python-comments.txt new file mode 100644 index 000000000..35750f346 --- /dev/null +++ b/ru-RU/python-comments.txt @@ -0,0 +1,27 @@ +Things to do in every frame + +Draw the inner circle + +Draw the middle circle + +The shoot_arrow function goes here + +The mouse_pressed function goes here + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! \ No newline at end of file diff --git a/ru-RU/python-translatable-demo.txt b/ru-RU/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/ru-RU/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/ru-RU/python-translatable.txt b/ru-RU/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/ru-RU/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/ru-RU/quiz1/question_1.md b/ru-RU/quiz1/question_1.md new file mode 100644 index 000000000..3be0de9d4 --- /dev/null +++ b/ru-RU/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Вопрос 1 из 3 +--- +In your project you added `randint(100, 300)` to your `shoot_arrow()` function. What does `randint(100, 300)` do? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) It chooses a random whole number between 100 and 300. + + --- feedback --- + +That's correct. This chooses a random x coordinate for your arrow. + + --- /feedback --- + +- ( ) It makes the arrow move randomly around the screen. + + --- feedback --- + +Not quite. This code part of how the arrow moves randomly but you need other code too to achieve that goal. + + --- /feedback --- + +- () It gets the colour that was hit by the arrow. + + --- feedback --- + + Not quite. The get() function would be used to get the colour. + + --- /feedback --- + +- ( ) It draws a circle of a random size. + + --- feedback --- + + Not quite. The circle() function would be used to draw a circle. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ru-RU/quiz1/question_2.md b/ru-RU/quiz1/question_2.md new file mode 100644 index 000000000..6f879699f --- /dev/null +++ b/ru-RU/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Вопрос 2 из 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ru-RU/quiz1/question_3.md b/ru-RU/quiz1/question_3.md new file mode 100644 index 000000000..b59583f00 --- /dev/null +++ b/ru-RU/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Вопрос 3 из 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/ru-RU/resources/main.py b/ru-RU/resources/main.py new file mode 100644 index 000000000..8d0da5672 --- /dev/null +++ b/ru-RU/resources/main.py @@ -0,0 +1,61 @@ +#!/bin/python3 + +# Import library code +from p5 import * +from math import * +from random import randint + +# The mouse_pressed function goes here +def mouse_pressed(): + if hit_color == outer: + print('You hit the outer circle, 50 points!') #Like functions, 'if' statements are indented + elif hit_color == inner: + print('You hit the inner circle, 200 points!') + elif hit_color == bullseye: + print('You hit the bullseye, 500 points!') + else: + print('You missed! No points!') + +# The shoot_arrow function goes here +def shoot_arrow(): + global hit_color + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_color = get(arrow_x, arrow_y) + ellipse(arrow_x, arrow_y, 15, 15) + +def setup(): +# Setup your game here + size(400, 400) # width and height + frame_rate(2) + + +def draw(): +# Things to do in every frame + global outer, inner, bullseye + sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 + grass = color(149, 212, 122) + wood = color(145, 96, 51) + outer = color(0, 120, 180) + inner = color(210, 60, 60) + bullseye = color(220, 200, 0) + + no_stroke() + fill(sky) + rect(0, 0, 400, 250) + fill(grass) + rect(0, 250, 400, 150) + + fill(wood) + triangle(150, 350, 200, 150, 250, 350) + fill(outer) + ellipse(200, 200, 170, 170) + fill(inner) + ellipse(200, 200, 110, 110) #Inner circle + fill(bullseye) + ellipse(200, 200, 30, 30) #Bullseye + + fill(wood) + shoot_arrow() +# Keep this to run your code +run() diff --git a/ru-RU/resources/p5.py b/ru-RU/resources/p5.py new file mode 100644 index 000000000..fc023ee64 --- /dev/null +++ b/ru-RU/resources/p5.py @@ -0,0 +1,135 @@ +# Definitions for compatibility with the p5py processing library +from processing import * +import __main__ + +# Shape +from processing import rectMode as rect_mode +from processing import ellipseMode as ellipse_mode +from processing import strokeWeight as stroke_weight +from processing import strokeCap as stroke_cap +from processing import strokeJoin as stroke_join +from processing import noStroke as no_stroke +from processing import noFill as no_fill + +# Fonts +from processing import createFont as create_font +from processing import loadFont as load_font +from processing import textFont as text_font + +# Text +from processing import textAlign as text_align +from processing import textLeading as text_leading +from processing import textMode as text_mode +from processing import textSize as text_size +from processing import textWidth as text_width + +# Colour +from processing import blendColor as blend_color +from processing import lerpColor as lerp_color +from processing import color as Color + +# Images +from processing import createImage as create_image +from processing import imageMode as image_mode +from processing import loadImage as load_image +from processing import noTint as no_tint +from processing import requestImage as request_image + +# Environment +from processing import frameRate as frame_rate +from processing import noCursor as no_cursor +from processing import noLoop as no_loop + +# Transform +from processing import applyMatrix as apply_matrix +from processing import popMatrix as pop_matrix +from processing import printMatrix as print_matrix +from processing import pushMatrix as push_matrix +from processing import resetMatrix as reset_matrix +from processing import rotateX as rotate_x +from processing import rotateY as rotate_y +from processing import pushStyle as push_style +from processing import popStyle as pop_style + +from processing import run as main_run + +# Keyboard + +def mousePressed(): + if hasattr(__main__, "mouse_pressed"): + mouse_pressed = getattr(__main__, "mouse_pressed") + mouse_pressed() + +def mouseReleased(): + if hasattr(__main__, "mouse_released"): + mouse_released = getattr(__main__, "mouse_released") + mouse_released() + +__main__.mouse_x = 0 +__main__.mouse_y = 0 +__main__.mouse_px = 0 +__main__.mouse_py = 0 +__main__.frame_count = 0 +__main__.frame_rate = 60 + +def mouseMoved(): + __main__.mouse_x = mouse.x + __main__.mouse_y = mouse.y + __main__.mouse_px = mouse.px + __main__.mouse_py = mouse.py + if hasattr(__main__, "mouse_moved"): + mouse_moved = getattr(__main__, "mouse_moved") + mouse_moved() + +def mouseDragged(): + if hasattr(__main__, "mouse_dragged"): + mouse_dragged = getattr(__main__, "mouse_dragged") + mouse_dragged() + +def new_draw(): + __main__.frame_count = frameCount + frameRate = __main__.frame_rate + old_draw() + +def run(): + global old_draw + old_draw = __main__.draw + __main__.draw = new_draw + main_run() + +def grid(): + pushMatrix() + stroke(200) + fill(0) + line(0, height/2, width, height/2) + line(width/2, 0, width/2, height) + x_coords = [0, width/2, width] + y_coords = [0, height/2, height] + + for x in x_coords: + for y in y_coords: + show_coord(x, y) + + popMatrix() + +def show_coord(x, y): + if x == width: + x_align = RIGHT + elif x == 0: + x_align = LEFT + else: + x_align = CENTER + + if y == height: + y_align = BASELINE + elif y == 0: + y_align = TOP + else: + y_align = CENTER + + pushStyle() + fill(100) + text_align(x_align, y_align) + text('(' + str(int(x)) + ', ' + str(int(y)) + ')', x, y) + popStyle() + diff --git a/ru-RU/step_1.md b/ru-RU/step_1.md new file mode 100644 index 000000000..e3a8012cf --- /dev/null +++ b/ru-RU/step_1.md @@ -0,0 +1,29 @@ +## What you will make + +Use Python to draw a target and score points by hitting it with arrows. + +--- print-only --- + +![An archery target with a hit point on the outer circle. The text 'You hit the outer circle, 50 points!' is displayed underneath](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + + +
+
+ +--- /no-print --- + +
+ Take our survey to help make our Code Editor better! +
+ + + diff --git a/ru-RU/step_2.md b/ru-RU/step_2.md new file mode 100644 index 000000000..919a62214 --- /dev/null +++ b/ru-RU/step_2.md @@ -0,0 +1,37 @@ +## Draw the grass + +--- task --- + +Open the [Target practice starter](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"} project. + +--- /task --- + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen to represent the grass. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to view the background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/ru-RU/step_3.md b/ru-RU/step_3.md new file mode 100644 index 000000000..c0895baaf --- /dev/null +++ b/ru-RU/step_3.md @@ -0,0 +1,115 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `brown`. + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 in the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `blue`. + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front. + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/ru-RU/step_4.md b/ru-RU/step_4.md new file mode 100644 index 000000000..0e4f7b007 --- /dev/null +++ b/ru-RU/step_4.md @@ -0,0 +1,88 @@ +## Add an arrow + +
+
+Add an even smaller circle to represent an arrow. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Where will you shoot? + +--- task --- + +Add a function to draw a brown circle at coordinates `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Call your new `shoot_arrow()`{:.language-python} function at the end of your `draw()`{:.language-python} function. + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the arrow in the centre. + +![a brown arrow circle in the centre of the target](images/arrow-centre.png) + + +--- /task --- + +The arrow needs to move randomly. + + +--- task --- + +Change the `arrow_x`{:.language-python} and `arrow_y`{:.language-python} variables to choose a random number between 100 and 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Test:** Click the **Run** button. You should see the arrow jump around the target. + +![An animation of target with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/ru-RU/step_5.md b/ru-RU/step_5.md new file mode 100644 index 000000000..2933b68ca --- /dev/null +++ b/ru-RU/step_5.md @@ -0,0 +1,80 @@ +## What colour did you hit? + +Next, you will add some code to get the colour at the location of the arrow. + +### Get the colour hit by the arrow + +--- task --- + +Add a new **global variable** called `hit_colour`. + +Add code to `get` the colour at the centre of the arrow ,and store it in the `hit_colour` variable. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the brown colour of the arrow! + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see colours being printed in the **Text output**, in hexadecimal format. + +--- /task --- + +### Run code when the mouse is pressed + +--- task --- + +Comment out the line that prints the colour. This means it will not run. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Add code to print the target emoji 🎯 **when the mouse is clicked**. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. You should see the 🎯 character printed when you click the mouse on the target. + +![target emoji printed when mouse clicked](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/ru-RU/step_6.md b/ru-RU/step_6.md new file mode 100644 index 000000000..9449522ab --- /dev/null +++ b/ru-RU/step_6.md @@ -0,0 +1,112 @@ +## Score points + +
+
+Add a score based on where the arrow hits. +
+
+ +![An animation of the target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Comment out the line to print the 🎯 character so that it no longer runs. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Display a message **if** the `hit_colour`{:.language-python} is equal to the `outer` circle colour (blue). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Tip:** If you changed the colour of your outer circle then you will need to replace `blue` with the colour name that you have chosen. + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Wait for the arrow to land on the blue circle, then click your left mouse button. ![points scored when blue circle clicked](images/blue_circle_points.gif) + +--- /task --- + +`elif`{:.language-python} can be used to add more conditions to your `if`{:.language-python} statement. + +--- task --- + +Add some more code to score points if the arrow lands on the **inner** or **middle** circles. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button.You should score points whenever you hit the target. + +![points being scored on any area of target](images/yellow-points.png) + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? + +To do this last check, you use `else`{:.language-python}. + +--- task --- + +Add code to `print` a message when none of the `if` and `elif` statements are true. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Click the **Run** button. Fire the arrow in the grass or sky to see the miss message. + +![no points printed when outside target](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/ru-RU/step_7.md b/ru-RU/step_7.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/ru-RU/step_7.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/ru-RU/step_8.md b/ru-RU/step_8.md new file mode 100644 index 000000000..910635d28 --- /dev/null +++ b/ru-RU/step_8.md @@ -0,0 +1,36 @@ +## Challenge + +--- challenge --- + + +You could: + + +--- task --- + +Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position + +--- /task --- + +--- task --- + +Put emojis in your print messages ([here's a list of emojis](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) + +--- /task --- + +--- task --- + +Make the game easier or harder by changing the `frame_rate=2` value + + +--- /task --- + +--- task --- + +Add a variable to keep track of the total score, adding the correct number of points to it each time. + +--- /task --- + + + +--- /challenge --- diff --git a/ru-RU/step_9.md b/ru-RU/step_9.md new file mode 100644 index 000000000..86edf4a89 --- /dev/null +++ b/ru-RU/step_9.md @@ -0,0 +1,21 @@ +## What can you do now? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Click the **Run** button to view an example of this project. + + + +\--- /no-print --- + +Or, why not try out another [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python) project. + diff --git a/sw-KE/images/alternative-colours.png b/sw-KE/images/alternative-colours.png new file mode 100644 index 000000000..a688ac942 Binary files /dev/null and b/sw-KE/images/alternative-colours.png differ diff --git a/sw-KE/images/animation_bg_erase.gif b/sw-KE/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/sw-KE/images/animation_bg_erase.gif differ diff --git a/sw-KE/images/animation_no_bg_erase.gif b/sw-KE/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/sw-KE/images/animation_no_bg_erase.gif differ diff --git a/sw-KE/images/arrow-middle.png b/sw-KE/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/sw-KE/images/arrow-middle.png differ diff --git a/sw-KE/images/arrow-target.png b/sw-KE/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/sw-KE/images/arrow-target.png differ diff --git a/sw-KE/images/background.png b/sw-KE/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/sw-KE/images/background.png differ diff --git a/sw-KE/images/banner.png b/sw-KE/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/sw-KE/images/banner.png differ diff --git a/sw-KE/images/blue-circle.png b/sw-KE/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/sw-KE/images/blue-circle.png differ diff --git a/sw-KE/images/blue-points.png b/sw-KE/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/sw-KE/images/blue-points.png differ diff --git a/sw-KE/images/bottom-right.png b/sw-KE/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/sw-KE/images/bottom-right.png differ diff --git a/sw-KE/images/centre.png b/sw-KE/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/sw-KE/images/centre.png differ diff --git a/sw-KE/images/circle-coords.png b/sw-KE/images/circle-coords.png new file mode 100644 index 000000000..6c0d2c78b Binary files /dev/null and b/sw-KE/images/circle-coords.png differ diff --git a/sw-KE/images/coords_animation.gif b/sw-KE/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/sw-KE/images/coords_animation.gif differ diff --git a/sw-KE/images/difficulty-setting.png b/sw-KE/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/sw-KE/images/difficulty-setting.png differ diff --git a/sw-KE/images/fire_arrow.gif b/sw-KE/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/sw-KE/images/fire_arrow.gif differ diff --git a/sw-KE/images/five_circles.png b/sw-KE/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/sw-KE/images/five_circles.png differ diff --git a/sw-KE/images/green-grass.png b/sw-KE/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/sw-KE/images/green-grass.png differ diff --git a/sw-KE/images/grey-circle.png b/sw-KE/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/sw-KE/images/grey-circle.png differ diff --git a/sw-KE/images/grey-points.png b/sw-KE/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/sw-KE/images/grey-points.png differ diff --git a/sw-KE/images/initial_target.png b/sw-KE/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/sw-KE/images/initial_target.png differ diff --git a/sw-KE/images/missed-points.png b/sw-KE/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/sw-KE/images/missed-points.png differ diff --git a/sw-KE/images/outline-circles.png b/sw-KE/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/sw-KE/images/outline-circles.png differ diff --git a/sw-KE/images/points-scored.gif b/sw-KE/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/sw-KE/images/points-scored.gif differ diff --git a/sw-KE/images/quiz-colour.png b/sw-KE/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/sw-KE/images/quiz-colour.png differ diff --git a/sw-KE/images/random-side.png b/sw-KE/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/sw-KE/images/random-side.png differ diff --git a/sw-KE/images/rectangle-diagram.png b/sw-KE/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/sw-KE/images/rectangle-diagram.png differ diff --git a/sw-KE/images/showcase_rocket.png b/sw-KE/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/sw-KE/images/showcase_rocket.png differ diff --git a/sw-KE/images/showcase_static.png b/sw-KE/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/sw-KE/images/showcase_static.png differ diff --git a/sw-KE/images/sky_coords.png b/sw-KE/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/sw-KE/images/sky_coords.png differ diff --git a/sw-KE/images/sky_stroke.png b/sw-KE/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/sw-KE/images/sky_stroke.png differ diff --git a/sw-KE/images/stand_coords.png b/sw-KE/images/stand_coords.png new file mode 100644 index 000000000..28e151045 Binary files /dev/null and b/sw-KE/images/stand_coords.png differ diff --git a/sw-KE/images/step_4_preview.gif b/sw-KE/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/sw-KE/images/step_4_preview.gif differ diff --git a/sw-KE/images/step_5_preview.gif b/sw-KE/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/sw-KE/images/step_5_preview.gif differ diff --git a/sw-KE/images/target-stand.png b/sw-KE/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/sw-KE/images/target-stand.png differ diff --git a/sw-KE/images/target_area.png b/sw-KE/images/target_area.png new file mode 100644 index 000000000..72d80ba1d Binary files /dev/null and b/sw-KE/images/target_area.png differ diff --git a/sw-KE/images/three-circles.png b/sw-KE/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/sw-KE/images/three-circles.png differ diff --git a/sw-KE/images/top-left.png b/sw-KE/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/sw-KE/images/top-left.png differ diff --git a/sw-KE/images/triangles-coords.png b/sw-KE/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/sw-KE/images/triangles-coords.png differ diff --git a/sw-KE/images/upgrade-ideas.png b/sw-KE/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/sw-KE/images/upgrade-ideas.png differ diff --git a/sw-KE/images/yellow-points.png b/sw-KE/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/sw-KE/images/yellow-points.png differ diff --git a/sw-KE/meta.yml b/sw-KE/meta.yml new file mode 100644 index 000000000..d4420e902 --- /dev/null +++ b/sw-KE/meta.yml @@ -0,0 +1,36 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: You will make + - + title: Create a background + - + title: Draw your target + completion: + - engaged + - + title: Fire your arrow + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Upgrade your project + - + title: What next? diff --git a/sw-KE/python-comments-demo.txt b/sw-KE/python-comments-demo.txt new file mode 100644 index 000000000..cb2eb5621 --- /dev/null +++ b/sw-KE/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill color to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill color to grass diff --git a/sw-KE/python-comments.txt b/sw-KE/python-comments.txt new file mode 100644 index 000000000..160666a85 --- /dev/null +++ b/sw-KE/python-comments.txt @@ -0,0 +1,87 @@ +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Start x, start y, width, height + +x, y, width, height + +Set the stand fill colour to wood + +Set the arrow to fill colour to wood + +Set the stand fill colour to grass + +Set the circle fill colour to outer + +Set the circle fill colour to inner + +Set the circle fill colour to middle + +x, y, width of the circle + +Inner circle - x, y, width of the circle + +Middle circle - x, y, width of the circle + +Outer circle.200, 200 is the middle of the screen + +Blue + +Red + +Yellow + +Stand + +Outer circle + +Inner circle + +Bullseye + +The shoot_arrow function goes here + +Import library code + +Update to random coordinates + +Save the colour before drawing the arrow + +The mouse_pressed function goes here + +Can be used in other functions + +Like functions, 'if' statements are indented + +Setup your game here + +width and height + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Keep this to run your code + +Store a random number between 100 and 300 + +Get the hit colour + +Draw a small circle at random coordinates + +width and height of screen diff --git a/sw-KE/python-translatable-demo.txt b/sw-KE/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/sw-KE/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/sw-KE/python-translatable.txt b/sw-KE/python-translatable.txt new file mode 100644 index 000000000..75c0058cc --- /dev/null +++ b/sw-KE/python-translatable.txt @@ -0,0 +1,43 @@ +sky + +grass + +wood + +outer + +inner + +bullseye + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the bullseye, 500 points! + +You missed! No points! + +How fast do you want the arrow? slow, medium, fast + +You hit red, 200 points! + +speed + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! diff --git a/sw-KE/quiz1/question_1.md b/sw-KE/quiz1/question_1.md new file mode 100644 index 000000000..7413e69a7 --- /dev/null +++ b/sw-KE/quiz1/question_1.md @@ -0,0 +1,53 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +Here is a blue square, what are the RGB values that will create it? + +![A single block of blue colour.](images/quiz-colour.png) + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +Not quite, when all the colour values are set to `0`, the color is **black**. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite, colours follow the RGB model. This colour has maximum R value and no G or B, so will be **red**. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + That's correct! Colours follow the RGB model. This colour has no R or G, but maximum B, so will be **blue**. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite, when all the colour values are set to the `255` maximum, the color is **white**. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/sw-KE/quiz1/question_2.md b/sw-KE/quiz1/question_2.md new file mode 100644 index 000000000..cb8b743b2 --- /dev/null +++ b/sw-KE/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/sw-KE/quiz1/question_3.md b/sw-KE/quiz1/question_3.md new file mode 100644 index 000000000..de44b3b7f --- /dev/null +++ b/sw-KE/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/sw-KE/step_1.md b/sw-KE/step_1.md new file mode 100644 index 000000000..21a69d6b9 --- /dev/null +++ b/sw-KE/step_1.md @@ -0,0 +1,40 @@ +## You will make + +Use Python, with the `p5` graphics library, to draw a target and score points by hitting it with arrows. + +You will: + + Personalise your game with **RGB colours** + + Use **conditional statements** (`if`, `elif`, `else`) to make decisions + + Position shapes with **x, y coordinates** + +--- no-print --- + +### Play ▶️ + +--- task --- + +
+
+Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + +Have a few goes. Your score appears in the output area below the target. How does your score change when the arrow lands on the different colours? + +
+
+ +--- /task --- + +--- /no-print --- + +--- print-only --- + +![Completed project.](images/yellow-points.png) + +--- /print-only --- + +

+The oldest evidence of archery comes from the Sibudu Cave in KwaZulu-Natal, South Africa. Remains of stone and bone arrowheads have been found, which date to between 60,000 and 70,000 years ago. +

+ +![](http://code.org/api/hour/begin_coderdojo_target.png) diff --git a/sw-KE/step_2.md b/sw-KE/step_2.md new file mode 100644 index 000000000..b03ac80cf --- /dev/null +++ b/sw-KE/step_2.md @@ -0,0 +1,97 @@ +## Create a background + +
+
+Your game needs a colourful background. +
+
+ +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="300px"} + +
+
+ +### Open the starter project + +--- task --- + +Open the [Target practice starter](https://trinket.io/python/9973649e5c){:target="_blank"} project. + +If you have a Trinket account, you can click on the **Remix** button to save a copy to your **My Trinkets** library. + +--- /task --- + +### Edit the sky + +--- task --- + +The starter project has some code already written for you. + +Click **'Run'** to see a blue filled rectangle drawn from x=`0`, y=`0` (the top of the screen). This `400` x `250` pixels rectangle is the sky. + +![A blue rectangle with a black border around it, above a grey rectangle. The top left corner of the canvas is marked as x=0, y=0 this is the origin of the rectangle. The width is highlighted as 400 and the height as 250. The code rect(0, 0, 400, 250) is shown.](images/sky_stroke.png){:width="400px"} + +**Tip:** 💡 Coordinates start from (x=0, y=0) in the top left corner. This might be different to other coordinate systems you have used. + +--- /task --- + +--- task --- + +The sky has been drawn with a black border (stroke). + +To turn the stroke off for all shapes add `no_stroke()` to the `setup` function: + +--- code --- +--- +language: python filename: main.py — setup() line_numbers: true line_number_start: 11 +line_highlights: 15 +--- +def setup(): +# Setup your game here + size(400, 400) # width and height of screen frame_rate(2) no_stroke() + +--- /code --- + +--- /task --- + +--- task --- + +**Run** your code again and notice 👀 that the border (stroke) has now disappeared. + +--- /task --- + +### Draw the grass + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 17 +line_highlights: 27, 28 +--- +def draw(): +# Things to do in every frame + global wood sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 grass = color(149, 212, 122) wood = color(145, 96, 51) outer = color(0, 120, 180) + + fill(sky) +rect(0, 0, 400, 250) +fill(grass) # Set the fill color to grass rect(0, 250, 400, 150) # x, y, width, height + +--- /code --- + +**Tip:** 💡 We have added comments to our code, like `# Set the fill color to grass`, to tell you what it does. You don't need to add these comments to your code, but they can be helpful to remind you what lines of code do. + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project again to view the finished background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + diff --git a/sw-KE/step_3.md b/sw-KE/step_3.md new file mode 100644 index 000000000..39986aa1f --- /dev/null +++ b/sw-KE/step_3.md @@ -0,0 +1,152 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `wood` (brown). + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 i the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 27 +line_highlights: 29, 30 +--- + fill(grass) +rect(0, 250, 400, 150) fill(wood) # Set the stand fill colour to wood +triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `outer` (blue). + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 29 +line_highlights: 31, 32 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) # Set the circle fill colour to outer +circle(200, 200, 170) # x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front: + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +--- task --- + +👀 Find your colour variables in the `draw` function. + +Create two variables called `inner` and `middle` to store colours for the other circles. + +The `color` function expects three numbers: one each for red, green, and blue. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 17 +line_highlights: 24, 25 +--- +def draw(): +# Things to do in every frame global wood sky = color(92, 204, 206) +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) # Blue +inner = color(210, 60, 60) # Red +middle = color(220, 200, 0) # Yellow + +--- /code --- + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 35, 36, 37, 38 +--- + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) +circle(200, 200, 170) fill(inner) # Set the circle fill colour to inner +circle(200, 200, 110) # Inner circle - x, y, width of the circle +fill(middle) # Set the circle fill colour to middle +circle(200, 200, 30) # Middle circle - x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +**Debug:** 🐞 Check that you have used the American spelling of 'color' (without a 'u'). + +--- /task --- + +--- task --- + +**Choose:** 💭 Change any of the colours. + +[[[generic-theory-simple-colours]]] + +![A brown triangle with three coloured circles on grass and against a sky. The colours have changed to pinks and purples.](images/alternative-colours.png){:width="400px"} + + +--- /task --- + + + diff --git a/sw-KE/step_4.md b/sw-KE/step_4.md new file mode 100644 index 000000000..995a078e0 --- /dev/null +++ b/sw-KE/step_4.md @@ -0,0 +1,159 @@ +## Fire your arrow + +
+
+When you click or tap, an arrow will fire at the position of a moving target circle. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Draw a target circle every frame + +

Computers create the effect of movement by showing lots of images one after another. Each image is called a frame . +

+ +--- task --- + +Define your `shoot_arrow()` function under the comment **# The shoot_arrow function goes here**. + +Add code to randomly draw a brown circle within a target area: + +![A rectangle showing the target area coordinates in a semi transparent rectangle. The target area is between x=100 and y=100 to x=300 and y=300 so covers the whole target and wider.](images/target_area.png) + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 10, 11, 12, 13, 14 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) # Store a random number between 100 and 300 +arrow_y = randint(100, 300) # Store a random number between 100 and 300 +fill(wood) # Set the arrow to fill colour to wood +circle(arrow_x, arrow_y, 15) # Draw a small circle at random coordinates + +--- /code --- + +--- /task --- + +--- task --- + +Go to the `draw` function and call your new `shoot_arrow` function. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 42 +line_highlights: 44 +--- + fill(middle) +circle(200, 200, 30) +shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run you code and see the arrow appear in a random position each frame. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +The background and target will be drawn over the old arrow. This means you only see one arrow at a time. + +--- /task --- + +### Get the colour hit by the arrow + +The `get()` function returns the colour of a pixel. + +

+A pixel, short for picture element, is a single coloured dot within an image. Images are made up of lots of coloured pixels. +

+ +--- task --- + +Add code to `get` the colour of the pixel at the centre of the arrow and store it in the `hit_color` variable. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Get the hit colour fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** 💡 The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the wood colour of the arrow! + +--- /task --- + +### Print the colour when the mouse is pressed + +The `p5` library 'listens' for certain events, one of these is the press of the mouse button. When it detects that the button has been pressed, it will run whatever code it has been given in the `mouse_pressed` function. + +--- task --- + +Define your `mouse_pressed()` function under the comment **# The mouse_pressed function goes here**. + +Add code to print the amounts of red, green, and blue in the pixel the arrow lands on. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 8, 9 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +print( red(hit_color), green(hit_color), blue(hit_color) ) + +--- /code --- + +--- /task --- + +--- task --- + +Make `hit_color` a **global variable** so that it can be used throughout your code: + +--- code --- +--- +language: python filename: main.py - shoot_arrow() line_numbers: true line_number_start: 11 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +global hit_color # Can be used in other functions +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Save the colour before drawing the arrow fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. + +The project prints the `hit_color` each time the arrow is redrawn. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +**Debug:** 🐞 If you are seeing a message about `hit_color` being 'not defined', then go back to `shoot_arrow()` and check that you have the `global hit_color` line. + +**Debug:** 🐞 Check the `print` line really carefully for commas and brackets. + +--- /task --- + + diff --git a/sw-KE/step_5.md b/sw-KE/step_5.md new file mode 100644 index 000000000..e0660f134 --- /dev/null +++ b/sw-KE/step_5.md @@ -0,0 +1,169 @@ +## Score points + +
+
+Your game will add scores based on where the arrow hits. +
+
+ +![The target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Go to the `draw()` function and add `, outer, inner, middle` to the list of global variables. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 28 +--- + +def draw(): +# Things to do in every frame + global wood, outer, inner, middle +sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +middle = color(220, 200, 0) + +--- /code --- + +--- /task --- + +

+We use conditions all the time to make decisions. We could say 'if the pencil is blunt, then sharpen it'. Similarly, `if` conditions let us write code that do something different depending on whether a condition is true or false. +

+ +### Display the scores + +--- task --- + +Delete ❌ the `print( red(hit_color), green(hit_color), blue(hit_color) )` line of code. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9 +--- +# The mouse_pressed function goes here +def mouse_pressed(): + + +--- /code --- + +--- /task --- + +--- task --- + +`print` a message `if` the `hit_color` is equal to `outer` 🎯. + +Notice 👀 that the code uses two equals signs `==` to mean **equal to**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9, 10 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') # Like functions, 'if' statements are indented + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the blue outer circle to see your message. + +**Tip:** 💡 `frame_rate()`, in `setup`, controls how fast your game draws. If it's going too fast, set it to a lower number. + +![The output area with arrow touching the outer circle. The points print statement appears in the output area.](images/blue-points.png) + +**Debug:** 🐞 Make sure your code matches exactly and you indented the code inside your `if` statement. + +--- /task --- + +`elif` (else - if) can be used to add more conditions to your `if` statement. These will be read from top to bottom. As soon as a **True** condition is found, it will be actioned. The remaining conditions will be ignored. + +--- task --- + +Score points if the arrow lands on the `inner` or `middle` circles 🎯: + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11, 12, 13, 14 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the inner and middle circles to see their messages. + +![The output area with arrow touching the inner circle. The points print statement appears in the output area.](images/yellow-points.png) + +**Debug:** 🐞 Check your indentation matches the example. + +**Debug:** 🐞 If you see a message about `inner` or `middle` being 'not defined', then go back to `draw()` and check that they are on the line that declares variables global. + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? ❌ + +To do this last check, you use `else`. + +--- task --- + +Add code to `print` a message `else` none of the `if` and `elif` statements have been met. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 8 +line_highlights: 15, 16 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') +else: +print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow in the grass or sky to see the miss message. + +**Choose:** 💭 Change the number of points scored for the different colours if you like. + +![The output area with an arrow missing the target. The points print statement appears in the output area.](images/missed-points.png) + +--- /task --- + diff --git a/sw-KE/step_6.md b/sw-KE/step_6.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/sw-KE/step_6.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/sw-KE/step_7.md b/sw-KE/step_7.md new file mode 100644 index 000000000..e479b9649 --- /dev/null +++ b/sw-KE/step_7.md @@ -0,0 +1,35 @@ +## Upgrade your project + +
+
+Personalise and add more to your project. Perhaps you could change the difficulty level or add more circles to your target. +
+
+ +![The output area showing a target with five circles.](images/five_circles.png){:width="300px"} + +
+
+ +--- task --- + +You could: + ++ Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position 🟠🟣 ++ Put emoji in your print messages ([here's a list of emoji](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) 🎯 ++ Make the game easier or harder by changing the `frame_rate(2)` value 💨 ++ Use `input()` to ask the user which difficulty level they want to play at 🗣️ + +--- /task --- + +![Upgraded project ideas: one with five circles, one with a difficulty input question, one with emoji in the points message.](images/upgrade-ideas.png) + +--- collapse --- +--- +title: Completed project +--- + +You can view the [completed project here](https://trinket.io/python/f686c82d8a){:target="_blank"}. + +--- /collapse --- + diff --git a/sw-KE/step_8.md b/sw-KE/step_8.md new file mode 100644 index 000000000..867ede7b9 --- /dev/null +++ b/sw-KE/step_8.md @@ -0,0 +1,31 @@ +## What next? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png) + +--- /print-only --- + +--- no-print --- + +--- task --- + +**Try it:** Your program will adjust the animation based on how much fuel you give it and will succeed or fail in reaching orbit. How much fuel do you want to use to reach orbit but not waste too much extra fuel? + +**Tip:** Around 25,000kg should be enough, but experiment with the numbers to see what happens. + + + +![Rocket launch project](images/showcase_rocket.png) + +--- /task --- + +--- /no-print --- + +If you want to have more fun exploring Python, then you could try out any of [these projects](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + + + diff --git a/uk-UA/code/target-practice-solution/main.py b/uk-UA/code/target-practice-solution/main.py new file mode 100644 index 000000000..923eaeb0e --- /dev/null +++ b/uk-UA/code/target-practice-solution/main.py @@ -0,0 +1,55 @@ +## Імпортуй код бібліотеки + +from p5 import * +from random import randint + + +# Тут буде функція mouse_pressed +def mouse_pressed(): + # print('🎯') + if hit_colour == Color("blue").hex: + print("Стріла в зовнішньому колі — 50 балів!") + elif hit_colour == Color("red").hex: + print("Стріла у внутрішньому колі — 200 балів!") + elif hit_colour == Color("yellow").hex: + print("Стріла у центрі — 500 балів!") + else: + print("Стріла не влучила! Нуль балів!") + + +# Тут буде функція shoot_arrow +def shoot_arrow(): + global hit_colour + arrow_x = randint(100, 300) + arrow_y = randint(100, 300) + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + fill("brown") + circle(arrow_x, arrow_y, 15) + + +def setup(): + # Налаштуй свою гру тут + size(400, 400) + no_stroke() + + +def draw(): + # Що відбувається на кожному кадрі + fill("cyan") + rect(0, 0, 400, 250) + fill("lightgreen") + rect(0, 250, 400, 150) + fill("brown") + triangle(150, 350, 200, 150, 250, 350) + fill("blue") + circle(200, 200, 170) + fill("red") + circle(200, 200, 110) # Намалюй внутрішнє коло + fill("yellow") + circle(200, 200, 30) # Намалюй середнє коло + shoot_arrow() + + +# Цей рядок запускає код +run(frame_rate=2) diff --git a/uk-UA/code/target-practice-solution/project_config.yml b/uk-UA/code/target-practice-solution/project_config.yml new file mode 100644 index 000000000..013fa87cd --- /dev/null +++ b/uk-UA/code/target-practice-solution/project_config.yml @@ -0,0 +1,3 @@ +name: 'Влучний постріл — приклад' +identifier: 'target-practice-solution' +type: 'python' diff --git a/uk-UA/code/target-practice-starter/main.py b/uk-UA/code/target-practice-starter/main.py new file mode 100644 index 000000000..77614c2df --- /dev/null +++ b/uk-UA/code/target-practice-starter/main.py @@ -0,0 +1,24 @@ +## Імпортуй код бібліотеки +from p5 import * +from random import randint + +# Тут буде функція mouse_pressed + + +# Тут буде функція shoot_arrow + + +def setup(): + # Налаштуй свою гру тут + size(400, 400) + no_stroke() + + +def draw(): + # Що відбувається на кожному кадрі + fill("cyan") + rect(0, 0, 400, 250) + + +# Цей рядок запускає код +run(frame_rate=2) diff --git a/uk-UA/code/target-practice-starter/project_config.yml b/uk-UA/code/target-practice-starter/project_config.yml new file mode 100644 index 000000000..4b0746586 --- /dev/null +++ b/uk-UA/code/target-practice-starter/project_config.yml @@ -0,0 +1,3 @@ +name: "Влучний постріл" +identifier: 'target-practice-starter' +type: 'python' diff --git a/uk-UA/images/alternative-colours.png b/uk-UA/images/alternative-colours.png new file mode 100644 index 000000000..e630dd54b Binary files /dev/null and b/uk-UA/images/alternative-colours.png differ diff --git a/uk-UA/images/animation_bg_erase.gif b/uk-UA/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/uk-UA/images/animation_bg_erase.gif differ diff --git a/uk-UA/images/animation_no_bg_erase.gif b/uk-UA/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/uk-UA/images/animation_no_bg_erase.gif differ diff --git a/uk-UA/images/arrow-centre.png b/uk-UA/images/arrow-centre.png new file mode 100644 index 000000000..14dba17ee Binary files /dev/null and b/uk-UA/images/arrow-centre.png differ diff --git a/uk-UA/images/arrow-middle.png b/uk-UA/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/uk-UA/images/arrow-middle.png differ diff --git a/uk-UA/images/arrow-target.png b/uk-UA/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/uk-UA/images/arrow-target.png differ diff --git a/uk-UA/images/background.png b/uk-UA/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/uk-UA/images/background.png differ diff --git a/uk-UA/images/banner.png b/uk-UA/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/uk-UA/images/banner.png differ diff --git a/uk-UA/images/blue-circle.png b/uk-UA/images/blue-circle.png new file mode 100644 index 000000000..054b612e8 Binary files /dev/null and b/uk-UA/images/blue-circle.png differ diff --git a/uk-UA/images/blue-points.png b/uk-UA/images/blue-points.png new file mode 100644 index 000000000..070075759 Binary files /dev/null and b/uk-UA/images/blue-points.png differ diff --git a/uk-UA/images/blue_circle_points.gif b/uk-UA/images/blue_circle_points.gif new file mode 100644 index 000000000..8458c2b8f Binary files /dev/null and b/uk-UA/images/blue_circle_points.gif differ diff --git a/uk-UA/images/bottom-right.png b/uk-UA/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/uk-UA/images/bottom-right.png differ diff --git a/uk-UA/images/centre.png b/uk-UA/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/uk-UA/images/centre.png differ diff --git a/uk-UA/images/circle-coords.png b/uk-UA/images/circle-coords.png new file mode 100644 index 000000000..a888286e1 Binary files /dev/null and b/uk-UA/images/circle-coords.png differ diff --git a/uk-UA/images/coords_animation.gif b/uk-UA/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/uk-UA/images/coords_animation.gif differ diff --git a/uk-UA/images/difficulty-setting.png b/uk-UA/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/uk-UA/images/difficulty-setting.png differ diff --git a/uk-UA/images/fire_arrow.gif b/uk-UA/images/fire_arrow.gif new file mode 100644 index 000000000..924ba34af Binary files /dev/null and b/uk-UA/images/fire_arrow.gif differ diff --git a/uk-UA/images/five_circles.png b/uk-UA/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/uk-UA/images/five_circles.png differ diff --git a/uk-UA/images/green-grass.png b/uk-UA/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/uk-UA/images/green-grass.png differ diff --git a/uk-UA/images/grey-circle.png b/uk-UA/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/uk-UA/images/grey-circle.png differ diff --git a/uk-UA/images/grey-points.png b/uk-UA/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/uk-UA/images/grey-points.png differ diff --git a/uk-UA/images/initial_target.png b/uk-UA/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/uk-UA/images/initial_target.png differ diff --git a/uk-UA/images/missed-points.png b/uk-UA/images/missed-points.png new file mode 100644 index 000000000..74162ddd2 Binary files /dev/null and b/uk-UA/images/missed-points.png differ diff --git a/uk-UA/images/missed_no_points.gif b/uk-UA/images/missed_no_points.gif new file mode 100644 index 000000000..7f3e3a66d Binary files /dev/null and b/uk-UA/images/missed_no_points.gif differ diff --git a/uk-UA/images/outline-circles.png b/uk-UA/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/uk-UA/images/outline-circles.png differ diff --git a/uk-UA/images/points-scored.gif b/uk-UA/images/points-scored.gif new file mode 100644 index 000000000..7f3e3a66d Binary files /dev/null and b/uk-UA/images/points-scored.gif differ diff --git a/uk-UA/images/quiz-colour.png b/uk-UA/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/uk-UA/images/quiz-colour.png differ diff --git a/uk-UA/images/random-side.png b/uk-UA/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/uk-UA/images/random-side.png differ diff --git a/uk-UA/images/rectangle-diagram.png b/uk-UA/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/uk-UA/images/rectangle-diagram.png differ diff --git a/uk-UA/images/showcase_rocket.png b/uk-UA/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/uk-UA/images/showcase_rocket.png differ diff --git a/uk-UA/images/showcase_static.png b/uk-UA/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/uk-UA/images/showcase_static.png differ diff --git a/uk-UA/images/sky_coords.png b/uk-UA/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/uk-UA/images/sky_coords.png differ diff --git a/uk-UA/images/sky_stroke.png b/uk-UA/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/uk-UA/images/sky_stroke.png differ diff --git a/uk-UA/images/stand_coords.png b/uk-UA/images/stand_coords.png new file mode 100644 index 000000000..2002bae5f Binary files /dev/null and b/uk-UA/images/stand_coords.png differ diff --git a/uk-UA/images/step_4_preview.gif b/uk-UA/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/uk-UA/images/step_4_preview.gif differ diff --git a/uk-UA/images/step_5_preview.gif b/uk-UA/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/uk-UA/images/step_5_preview.gif differ diff --git a/uk-UA/images/target-stand.png b/uk-UA/images/target-stand.png new file mode 100644 index 000000000..c65d89363 Binary files /dev/null and b/uk-UA/images/target-stand.png differ diff --git a/uk-UA/images/target_area.png b/uk-UA/images/target_area.png new file mode 100644 index 000000000..1e5c72120 Binary files /dev/null and b/uk-UA/images/target_area.png differ diff --git a/uk-UA/images/target_printed.gif b/uk-UA/images/target_printed.gif new file mode 100644 index 000000000..b29a244fe Binary files /dev/null and b/uk-UA/images/target_printed.gif differ diff --git a/uk-UA/images/three-circles.png b/uk-UA/images/three-circles.png new file mode 100644 index 000000000..13a8dd8ed Binary files /dev/null and b/uk-UA/images/three-circles.png differ diff --git a/uk-UA/images/top-left.png b/uk-UA/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/uk-UA/images/top-left.png differ diff --git a/uk-UA/images/triangles-coords.png b/uk-UA/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/uk-UA/images/triangles-coords.png differ diff --git a/uk-UA/images/upgrade-ideas.png b/uk-UA/images/upgrade-ideas.png new file mode 100644 index 000000000..34b87678d Binary files /dev/null and b/uk-UA/images/upgrade-ideas.png differ diff --git a/uk-UA/images/yellow-points.png b/uk-UA/images/yellow-points.png new file mode 100644 index 000000000..90c285f39 Binary files /dev/null and b/uk-UA/images/yellow-points.png differ diff --git a/uk-UA/meta.yml b/uk-UA/meta.yml new file mode 100644 index 000000000..869398d91 --- /dev/null +++ b/uk-UA/meta.yml @@ -0,0 +1,41 @@ +--- +title: Влучний постріл +hero_image: images/banner.png +description: За допомогою Python намалюй мішень та набирай бали, влучаючи в неї стрілами +meta_title: Проєкти з кодування для дітей і підлітків | Влучний постріл +meta_description: Вивчай Python за допомогою проєктів програмування Raspberry Pi Foundation для дітей і підлітків. За допомогою Python намалюй ціль і набирай бали, влучаючи в неї стрілами. +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: Що ти зробиш + - + title: Намалюй траву + - + title: Намалюй мішень + completion: + - engaged + - + title: Додай стрілу + - + title: У який колір влучила стріла? + - + title: Набирай бали + completion: + - internal + - + title: Швидкий тест + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Додаткове завдання + challenge: true + - + title: Що ти тепер вмієш? diff --git a/uk-UA/python-comments-demo.txt b/uk-UA/python-comments-demo.txt new file mode 100644 index 000000000..86261a0a7 --- /dev/null +++ b/uk-UA/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill colour to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill colour to grass diff --git a/uk-UA/python-comments.txt b/uk-UA/python-comments.txt new file mode 100644 index 000000000..a149b3a51 --- /dev/null +++ b/uk-UA/python-comments.txt @@ -0,0 +1,27 @@ +Що відбувається на кожному кадрі + +Намалюй внутрішнє коло + +Намалюй центральне коло + +Тут буде функція shoot_arrow + +Тут буде функція mouse_pressed + +Стріла в зовнішньому колі — 50 балів! + +Стріла у внутрішньому колі — 200 балів! + +Стріла у центрі — 500 балів! + +Стріла у центрі — 500 балів! + +Стріла не влучила! Нуль балів! + +Надзвичайно швидко + +Досить швидко + +Дуже швидко + +Не вдається розпізнати швидкість! \ No newline at end of file diff --git a/uk-UA/python-translatable-demo.txt b/uk-UA/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/uk-UA/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/uk-UA/python-translatable.txt b/uk-UA/python-translatable.txt new file mode 100644 index 000000000..1e4f01f6b --- /dev/null +++ b/uk-UA/python-translatable.txt @@ -0,0 +1,9 @@ +shoot_arrow + +arrow_x + +arrow_y + +hit_colour + +speed \ No newline at end of file diff --git a/uk-UA/quiz1/question_1.md b/uk-UA/quiz1/question_1.md new file mode 100644 index 000000000..af366ccb3 --- /dev/null +++ b/uk-UA/quiz1/question_1.md @@ -0,0 +1,60 @@ +## Швидкий тест + +Дай відповідь на три запитання. Підказки допоможуть знайти правильну відповідь. + +Відповівши на питання, натисни на **Перевірити мою відповідь**. + +Успіхів! + +--- question --- +--- +legend: Питання 1 з 3 +--- +У цьому проєкті ми додали `randint(100, 300)` до функції `shoot_arrow()`. Що робить `randint(100, 300)`? + +--- code --- +--- +language: python +--- + +def shoot_arrow(): global hit_colour arrow_x = randint(100, 300) arrow_y = randint(100, 300) + +--- /code --- + +--- choices --- + +- (x) Вибирає випадкове ціле число від 100 до 300. + + --- feedback --- + +Правильно. randint(100, 300) вибирає випадкову координату x для твоєї стріли. + + --- /feedback --- + +- ( ) Змушує стрілу довільно рухатися по екрану. + + --- feedback --- + +Не зовсім так. Ця частина коду допомагає стрілі рухатися випадковим чином, але для досягнення цієї мети тобі потрібен інший код. + + --- /feedback --- + +- () Визначає колір, на який потрапила стріла. + + --- feedback --- + + Не зовсім так. Для отримання кольору використовувалася б функція get(). + + --- /feedback --- + +- ( ) Малює коло довільного розміру. + + --- feedback --- + + Не зовсім так. Для малювання кола використовувалася б функція circle(). + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/uk-UA/quiz1/question_2.md b/uk-UA/quiz1/question_2.md new file mode 100644 index 000000000..7dedfafe1 --- /dev/null +++ b/uk-UA/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Питання 2 з 3 +--- + +У твоєму проєкті використовувалися умови `if`, `elif` та `else`, щоб перевірити, на який колір влучила стріла. + +У наступному прикладі змінна з назвою `speed` зберігає число `6`. Що буде надруковано в області виводу, коли ми запустимо умову `if`? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Надзвичайно швидко') elif speed == 5: print('Досить швидко') elif speed == 6: print('Дуже швидко') else: print('Не вдається розпізнати швидкість!') + +--- /code --- + +--- choices --- + +- (x) `Дуже швидко` + + --- feedback --- + + Правильно! Змінній **speed** було присвоєно значення `6`. Це означає, що умова `speed == 6` **справджується** (True), і код виведе на екран `Дуже швидко`. + + --- /feedback --- + +- ( ) `Не вдається розпізнати швидкість!` + + --- feedback --- + + Не зовсім так. Подивися на значення, присвоєне змінній **speed**. + + --- /feedback --- + +- ( ) Нічого не буде надруковано + + --- feedback --- + + Спробуй ще раз. `else` використовується тоді, коли всі попередні умови є хибними. Подивись ще раз на умови, чи справджуються вони? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/uk-UA/quiz1/question_3.md b/uk-UA/quiz1/question_3.md new file mode 100644 index 000000000..02bac3521 --- /dev/null +++ b/uk-UA/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Питання 3 з 3 +--- + +За допомогою наступного коду малюється коло: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +На якому з наведених нижче зображень показано правильне положення кола в області виводу результатів? + +--- choices --- + +- ( ) ![Зелене коло з центром у правому нижньому куті області виводу.](images/bottom-right.png) + + --- feedback --- + + Не зовсім так. Для центрування кола в правому нижньому куті необхідно, щоб його координати збігалися з розміром екрана. У нашому прикладі еліпс матиме такий вигляд: `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![Зелене коло з центром посередині в області виводу.](images/centre.png) + + --- feedback --- + + Не зовсім так. Щоб відцентрувати коло посередині, координати повинні бути вдвічі меншими за розмір екрана. У нашому прикладі це було б `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![Зелене коло з центром у лівому верхньому куті області виводу.](images/top-left.png) + + --- feedback --- + + Правильно! Центр цього кола знаходиться в точці з координатами (0,0) — верхньому лівому куті екрана. + + --- /feedback --- + +- ( ) ![Зелене коло з центром у верхньому правому куті області виводу.](images/random-side.png) + + --- feedback --- + + Ні, щоб відцентрувати коло у верхньому правому куті екрана, його код мав би бути `circle(350, 150, 300)`. Координата `x` встановлює позицію еліпса на екрані по горизонталі, а координата `y` встановлює позицію по вертикалі. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/uk-UA/step_1.md b/uk-UA/step_1.md new file mode 100644 index 000000000..d806bb3b8 --- /dev/null +++ b/uk-UA/step_1.md @@ -0,0 +1,29 @@ +## Що ти зробиш + +За допомогою Python ти намалюєш мішень та зароблятимеш бали, влучаючи в неї стрілами. + +--- print-only --- + +![Мішень для стрільби з лука зі слідом влучання стріли на зовнішньому колі. Внизу видно текст «Стріла в зовнішньому колі — 50 балів!»](images/blue-points.png){:width="640px"} + +--- /print-only --- + +--- no-print --- +
+
+ +Натисни кнопку **Run** (Запуск) внизу, щоб запустити гру. Коли на мішені 🎯 з'явиться крапка, клацни мишкою (або торкнись екрану планшета), щоб випустити стрілу. + + +
+
+ +--- /no-print --- + +
+ Візьми участь в опитуванні, щоб покращити наш редактор коду Code Editor! +
+ + + diff --git a/uk-UA/step_2.md b/uk-UA/step_2.md new file mode 100644 index 000000000..405500af9 --- /dev/null +++ b/uk-UA/step_2.md @@ -0,0 +1,37 @@ +## Намалюй траву + +--- task --- + +Відкрий [початковий проєкт «Влучний постріл»](https://editor.raspberrypi.org/en/projects/target-practice-starter){:target="_blank"}. + +--- /task --- + +--- task --- + +**Додай** код, щоб намалювати зелений прямокутник у нижній частині екрана. Це буде трава. + +![Область виводу з прямокутником небесного кольору вгорі та прямокутником зеленого кольору внизу, які створюють тло. Верхній лівий кут прямокутника позначено як x=0, y=250. Це початок прямокутника. Ширина позначена як 400, а висота — 150. Видно код rect(0, 250, 400, 150).](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 17 +line_highlights: 21-22 +--- +def draw(): # Things to do in every frame fill('cyan') +rect(0, 0, 400, 250) +fill('lightgreen') +rect(0, 250, 400, 150) + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** запусти свій проєкт, щоб побачити тло. + +![Область виводу з прямокутником небесного кольору вгорі та прямокутником зеленого кольору внизу, які створюють тло.](images/background.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/uk-UA/step_3.md b/uk-UA/step_3.md new file mode 100644 index 000000000..b14b85e74 --- /dev/null +++ b/uk-UA/step_3.md @@ -0,0 +1,115 @@ +## Намалюй мішень + +
+
+У твоїй грі потрібно намалювати мішень, в яку можна випускати стріли. +
+
+ +![Зона виводу з мішенню та підставкою.](images/three-circles.png){:width="300px"} + +
+
+ +### Намалюй підставку у вигляді трикутника + +--- task --- + +Встанови колір заливки `brown` (коричневий). + +Намалюй трикутник (англійською triangle), використовуючи координати x та y для кожного з кутів. + +![Коричневий трикутник на траві на фоні неба. Він має такі підписані координати: 150, 350; 200, 150; 250, 350). Кути фона також підписані: x=0, y=0 у верхньому лівому куті та x=400, y=400 у нижньому правому куті.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 21 +line_highlights: 23-24 +--- + + fill('lightgreen') + rect(0, 250, 400, 150) + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** запусти код, щоб побачити підставку для мішені: + +![Коричневий трикутник на траві на фоні неба.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Намалюй кола мішені + +--- task --- + +Найбільша частина мішені — це синє **коло** (англійською circle). + +Встанови колір заливки `blue` (синій). + +Намалюй коло з координатами x та y (де буде його центр) та шириною. + +![Коричневий трикутник та синє коло на траві, на фоні неба. Координати центру кола підписані: x=200, y=200. Ширина кола підписана 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python line_numbers: true line_number_start: 23 +line_highlights: 25-26 +--- + + fill('brown') + triangle(150, 350, 200, 150, 250, 350) + fill('blue') + circle(200, 200, 170) + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** запусти код, щоб побачити перше велике синє коло. + +Ми намалювали синє коло після підставки, тому воно знаходиться попереду. + +![Коричневий трикутник та синє коло на траві на фоні неба.](images/blue-circle.png){:width="400px"} + +--- /task --- + +Мішень складається з кіл різного розміру з однаковими координатами центру (200, 200). + +--- task --- + +**Додай** кольорові кола для внутрішньої та центральної частин мішені. + +--- code --- +--- +language: python line_numbers: true line_number_start: 25 +line_highlights: 27-30 +--- + + fill('blue') + circle(200, 200, 170) + fill('red') + circle(200, 200, 110) # Draw the inner circle + fill('yellow') + circle(200, 200, 30) # Draw the middle circle + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** запусти свій проєкт, щоб побачити мішень з трьома кольоровими колами. + +![Коричневий трикутник з трьома кольоровими колами на траві на фоні неба.](images/three-circles.png){:width="400px"} + +--- /task --- + +--- save --- diff --git a/uk-UA/step_4.md b/uk-UA/step_4.md new file mode 100644 index 000000000..0ad2f975e --- /dev/null +++ b/uk-UA/step_4.md @@ -0,0 +1,88 @@ +## Додай стрілу + +
+
+Додайте найменше коло — це буде стріла. +
+
+ +![Мішень з коричневою круговою стрілою, що з'являється в різних положеннях.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Куди ти поцілиш? + +--- task --- + +Додай функцію, яка малюватиме коричневе коло з координатами `200`, `200`. + +--- code --- +--- +language: python line_numbers: true line_number_start: 8 +line_highlights: 9-13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = 200 arrow_y = 200 fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Виклич цю нову функцію `shoot_arrow()`{:.language-python} (з англійської «пустити стрілу») наприкінці своєї функції `draw()`{:.language-python} (з англійської «малювати»). + +--- code --- +--- +language: python line_numbers: true line_number_start: 33 +line_highlights: 35 +--- + + fill('yellow') + circle(200, 200, 30) + shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** натисни на кнопку **Run**. Ти маєш побачити стрілу в центрі. + +![Коричневе коло стріли в центрі мішені](images/arrow-centre.png) + + +--- /task --- + +Стріла повинна рухатися випадковим чином. + + +--- task --- + +Зміни код так, щоб змінні `arrow_x`{:.language-python} і `arrow_y`{:.language-python} вибирали випадкове число від 100 до 300. + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10-11 +--- +def shoot_arrow(): arrow_x = randint(100, 300) arrow_y = randint(100, 300) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + + +--- task --- + + +**Протестуй:** натисни на кнопку **Run**. Ти маєш побачити, як стріла рухається навколо цілі. + +![Анімація, на якій коричневе коло стріли зʼявляється у різних положеннях.](images/fire_arrow.gif) + +--- /task --- + +--- save --- diff --git a/uk-UA/step_5.md b/uk-UA/step_5.md new file mode 100644 index 000000000..62ea246ad --- /dev/null +++ b/uk-UA/step_5.md @@ -0,0 +1,80 @@ +## У який колір влучила стріла? + +Тепер ти додаси код, який буде визначати колір місця, куди влучила стріла. + +### Визнач колір, на який потрапила стріла + +--- task --- + +Додай нову **глобальну змінну** під назвою `hit_colour` (з англійської «колір, у який влучила стріла»). + +Додай код який буде `діставати` (англійською get) колір пікселя з центру стріли та зберігати його у змінній `hit_color`. + + +--- code --- +--- +language: python line_numbers: true line_number_start: 9 +line_highlights: 10, 13, 14 +--- +def shoot_arrow(): global hit_colour +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) hit_colour = get(arrow_x, arrow_y).hex print(hit_colour) fill('brown') circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Порада:** код для визначення кольору (`get`) повинен бути **перед** кодом, який малює коло (`circle`). Інакше ти будеш постійно зберігати коричневий колір стріли! + +--- /task --- + +--- task --- + +**Протестуй:** натисни на кнопку **Run**. Ти маєш бачити кольори, що друкуються у **полі для вихідного тексту** у шістнадцятковому форматі. + +--- /task --- + +### Запускай код, коли натиснута кнопка миші + +--- task --- + +Додай значок коментаря # перед рядком, який виводить колір. Це означає, що цей рядок не буде виконуватися. + +--- code --- +--- +language: python line_numbers: true line_number_start: 13 +line_highlights: 14 +--- + + hit_colour = get(arrow_x, arrow_y).hex + # print(hit_colour) + circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +Додай код, щоб **коли натискалася кнопка миші**, у полі для вихідного тексту виводилось емоджі мішені 🎯. + +--- code --- +--- +language: python line_numbers: true line_number_start: 5 +line_highlights: 6-7 +--- +# The mouse_pressed function goes here +def mouse_pressed(): +print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** натисни на кнопку **Run**. Ти маєш бачити символ мішені 🎯 щоразу, як клацаєш мишкою на мішені. + +![Емоджі мішені виводиться, коли натиснута кнопка миші](images/target_printed.gif) + +--- /task --- + +--- save --- \ No newline at end of file diff --git a/uk-UA/step_6.md b/uk-UA/step_6.md new file mode 100644 index 000000000..b1acc75a3 --- /dev/null +++ b/uk-UA/step_6.md @@ -0,0 +1,112 @@ +## Набирай бали + +
+
+Додай рахунок залежно від того, куди влучить стріла. +
+
+ +![Анімація, на якій стріла зʼявляється у різних положеннях і бали зʼявляються у вигляді тексту під грою.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Додай символ коментаря # перед рядком, який виводить 🎯, щоб він більше не виконувався. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 7 +--- +def mouse_pressed(): # print('🎯') + +--- /code --- + +--- /task --- + +--- task --- + +Виведи повідомлення, **якщо** колір `hit_colour`{:.language-python} дорівнює кольору `зовнішнього` кола (синьому). + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 8-9 +--- +def mouse_pressed(): +# print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') + +--- /code --- + +**Порада:** якщо твоє зовнішнє коло іншого кольору, тобі потрібно буде замінити `blue` на назву вибраного тобою кольору англійською мовою. + +--- /task --- + +--- task --- + +**Протестуй:** натисни на кнопку **Run**. Зачекай, поки стріла опиниться на синьому колі, а потім натисни ліву кнопку миші. ![Бали, зароблені за влучання у синє коло](images/blue_circle_points.gif) + +--- /task --- + +Щоб додати більше умов до виразу `if`{:.language-python}, можна використовувати `elif`{:.language-python}. + +--- task --- + +Додай рядки коду, які рахуватимуть бали у випадку потрапляння у **внутрішнє** або **середнє** коло. + +--- code --- +--- +language: python line_numbers: true line_number_start: 6 +line_highlights: 10-14 +--- + +def mouse_pressed(): # print('🎯') if hit_colour == Color('blue').hex: print('You hit the outer circle, 50 points!') elif hit_colour == Color('red').hex: print('You hit the inner circle, 200 points!') elif hit_colour == Color('yellow').hex: print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** натисни кнопку **Run**. Ти маєш бачити рахунок щоразу, як стріла влучає у мішень. + +![Бали, зароблені за влучання у будь-яке місце на мішені](images/yellow-points.png) + +--- /task --- + +### Мимо мішені + +Тобі треба вирішити: що буде, якщо стріла не влучить у мішень? + +Щоб виконати цю перевірку, використай `else`{:.language-python}. + +--- task --- + +Додай код, який виводитиме повідомлення (`print`), коли жодна з умов `if` або `elif` не виконалась. + +--- code --- +--- +language: python line_numbers: true line_number_start: 12 +line_highlights: 14-15 +--- + + elif hit_colour == Color('yellow').hex: + print('You hit the middle, 500 points!') + else: + print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Протестуй:** натисни на кнопку **Run**. Спробуй влучити в траву або небо, щоб побачити повідомлення про промах. + +![Бали не зараховуються, якщо стріла не влучила у мішень](images/missed_no_points.gif) + +--- /task --- + +--- save --- diff --git a/uk-UA/step_7.md b/uk-UA/step_7.md new file mode 100644 index 000000000..89468759d --- /dev/null +++ b/uk-UA/step_7.md @@ -0,0 +1 @@ +## Швидкий тест \ No newline at end of file diff --git a/uk-UA/step_8.md b/uk-UA/step_8.md new file mode 100644 index 000000000..a2089363e --- /dev/null +++ b/uk-UA/step_8.md @@ -0,0 +1,36 @@ +## Додаткове завдання + +--- challenge --- + + +Ти можеш: + + +--- task --- + +Додати `четверте` і `пʼяте` коло інших кольорів, за які зараховується різна кількість балів залежно від їхнього розташування. + +--- /task --- + +--- task --- + +Додати емоджі до повідомлень print (можеш скопіювати їх із цього [списку емоджі](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"}) + +--- /task --- + +--- task --- + +Зробити гру легшою або складнішою, змінивши значення `frame_rate(2)` + + +--- /task --- + +--- task --- + +Додати змінну, яка відстежуватиме загальну кількість балів. Щоразу як стріла влучає у мішень, до значення змінної має додаватися правильна кількість балів. + +--- /task --- + + + +--- /challenge --- diff --git a/uk-UA/step_9.md b/uk-UA/step_9.md new file mode 100644 index 000000000..aa7f182ee --- /dev/null +++ b/uk-UA/step_9.md @@ -0,0 +1,21 @@ +## Що робити далі? + +Якщо ти йдеш напрямом [Вступ до Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro), можеш переходити до наступного проєкту — [Ракета летить у космос](https://projects.raspberrypi.org/en/projects/rocket-launch). У цьому проєкті ти створиш інтерактивну анімацію ракети, яка виводить супутник на орбіту. + +\--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png){:width="600px"} + +\--- /print-only --- + +\--- no-print --- + +Натисни кнопку **Run**, щоб побачити приклад цього проєкту. + + + +\--- /no-print --- + +Або чому б не спробувати інший проєкт у [Python](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + diff --git a/xh-ZA/images/alternative-colours.png b/xh-ZA/images/alternative-colours.png new file mode 100644 index 000000000..a688ac942 Binary files /dev/null and b/xh-ZA/images/alternative-colours.png differ diff --git a/xh-ZA/images/animation_bg_erase.gif b/xh-ZA/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/xh-ZA/images/animation_bg_erase.gif differ diff --git a/xh-ZA/images/animation_no_bg_erase.gif b/xh-ZA/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/xh-ZA/images/animation_no_bg_erase.gif differ diff --git a/xh-ZA/images/arrow-middle.png b/xh-ZA/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/xh-ZA/images/arrow-middle.png differ diff --git a/xh-ZA/images/arrow-target.png b/xh-ZA/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/xh-ZA/images/arrow-target.png differ diff --git a/xh-ZA/images/background.png b/xh-ZA/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/xh-ZA/images/background.png differ diff --git a/xh-ZA/images/banner.png b/xh-ZA/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/xh-ZA/images/banner.png differ diff --git a/xh-ZA/images/blue-circle.png b/xh-ZA/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/xh-ZA/images/blue-circle.png differ diff --git a/xh-ZA/images/blue-points.png b/xh-ZA/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/xh-ZA/images/blue-points.png differ diff --git a/xh-ZA/images/bottom-right.png b/xh-ZA/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/xh-ZA/images/bottom-right.png differ diff --git a/xh-ZA/images/centre.png b/xh-ZA/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/xh-ZA/images/centre.png differ diff --git a/xh-ZA/images/circle-coords.png b/xh-ZA/images/circle-coords.png new file mode 100644 index 000000000..6c0d2c78b Binary files /dev/null and b/xh-ZA/images/circle-coords.png differ diff --git a/xh-ZA/images/coords_animation.gif b/xh-ZA/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/xh-ZA/images/coords_animation.gif differ diff --git a/xh-ZA/images/difficulty-setting.png b/xh-ZA/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/xh-ZA/images/difficulty-setting.png differ diff --git a/xh-ZA/images/fire_arrow.gif b/xh-ZA/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/xh-ZA/images/fire_arrow.gif differ diff --git a/xh-ZA/images/five_circles.png b/xh-ZA/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/xh-ZA/images/five_circles.png differ diff --git a/xh-ZA/images/green-grass.png b/xh-ZA/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/xh-ZA/images/green-grass.png differ diff --git a/xh-ZA/images/grey-circle.png b/xh-ZA/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/xh-ZA/images/grey-circle.png differ diff --git a/xh-ZA/images/grey-points.png b/xh-ZA/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/xh-ZA/images/grey-points.png differ diff --git a/xh-ZA/images/initial_target.png b/xh-ZA/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/xh-ZA/images/initial_target.png differ diff --git a/xh-ZA/images/missed-points.png b/xh-ZA/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/xh-ZA/images/missed-points.png differ diff --git a/xh-ZA/images/outline-circles.png b/xh-ZA/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/xh-ZA/images/outline-circles.png differ diff --git a/xh-ZA/images/points-scored.gif b/xh-ZA/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/xh-ZA/images/points-scored.gif differ diff --git a/xh-ZA/images/quiz-colour.png b/xh-ZA/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/xh-ZA/images/quiz-colour.png differ diff --git a/xh-ZA/images/random-side.png b/xh-ZA/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/xh-ZA/images/random-side.png differ diff --git a/xh-ZA/images/rectangle-diagram.png b/xh-ZA/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/xh-ZA/images/rectangle-diagram.png differ diff --git a/xh-ZA/images/showcase_rocket.png b/xh-ZA/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/xh-ZA/images/showcase_rocket.png differ diff --git a/xh-ZA/images/showcase_static.png b/xh-ZA/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/xh-ZA/images/showcase_static.png differ diff --git a/xh-ZA/images/sky_coords.png b/xh-ZA/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/xh-ZA/images/sky_coords.png differ diff --git a/xh-ZA/images/sky_stroke.png b/xh-ZA/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/xh-ZA/images/sky_stroke.png differ diff --git a/xh-ZA/images/stand_coords.png b/xh-ZA/images/stand_coords.png new file mode 100644 index 000000000..28e151045 Binary files /dev/null and b/xh-ZA/images/stand_coords.png differ diff --git a/xh-ZA/images/step_4_preview.gif b/xh-ZA/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/xh-ZA/images/step_4_preview.gif differ diff --git a/xh-ZA/images/step_5_preview.gif b/xh-ZA/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/xh-ZA/images/step_5_preview.gif differ diff --git a/xh-ZA/images/target-stand.png b/xh-ZA/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/xh-ZA/images/target-stand.png differ diff --git a/xh-ZA/images/target_area.png b/xh-ZA/images/target_area.png new file mode 100644 index 000000000..72d80ba1d Binary files /dev/null and b/xh-ZA/images/target_area.png differ diff --git a/xh-ZA/images/three-circles.png b/xh-ZA/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/xh-ZA/images/three-circles.png differ diff --git a/xh-ZA/images/top-left.png b/xh-ZA/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/xh-ZA/images/top-left.png differ diff --git a/xh-ZA/images/triangles-coords.png b/xh-ZA/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/xh-ZA/images/triangles-coords.png differ diff --git a/xh-ZA/images/upgrade-ideas.png b/xh-ZA/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/xh-ZA/images/upgrade-ideas.png differ diff --git a/xh-ZA/images/yellow-points.png b/xh-ZA/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/xh-ZA/images/yellow-points.png differ diff --git a/xh-ZA/meta.yml b/xh-ZA/meta.yml new file mode 100644 index 000000000..d4420e902 --- /dev/null +++ b/xh-ZA/meta.yml @@ -0,0 +1,36 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: You will make + - + title: Create a background + - + title: Draw your target + completion: + - engaged + - + title: Fire your arrow + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Upgrade your project + - + title: What next? diff --git a/xh-ZA/python-comments-demo.txt b/xh-ZA/python-comments-demo.txt new file mode 100644 index 000000000..cb2eb5621 --- /dev/null +++ b/xh-ZA/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill color to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill color to grass diff --git a/xh-ZA/python-comments.txt b/xh-ZA/python-comments.txt new file mode 100644 index 000000000..160666a85 --- /dev/null +++ b/xh-ZA/python-comments.txt @@ -0,0 +1,87 @@ +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Start x, start y, width, height + +x, y, width, height + +Set the stand fill colour to wood + +Set the arrow to fill colour to wood + +Set the stand fill colour to grass + +Set the circle fill colour to outer + +Set the circle fill colour to inner + +Set the circle fill colour to middle + +x, y, width of the circle + +Inner circle - x, y, width of the circle + +Middle circle - x, y, width of the circle + +Outer circle.200, 200 is the middle of the screen + +Blue + +Red + +Yellow + +Stand + +Outer circle + +Inner circle + +Bullseye + +The shoot_arrow function goes here + +Import library code + +Update to random coordinates + +Save the colour before drawing the arrow + +The mouse_pressed function goes here + +Can be used in other functions + +Like functions, 'if' statements are indented + +Setup your game here + +width and height + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Keep this to run your code + +Store a random number between 100 and 300 + +Get the hit colour + +Draw a small circle at random coordinates + +width and height of screen diff --git a/xh-ZA/python-translatable-demo.txt b/xh-ZA/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/xh-ZA/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/xh-ZA/python-translatable.txt b/xh-ZA/python-translatable.txt new file mode 100644 index 000000000..75c0058cc --- /dev/null +++ b/xh-ZA/python-translatable.txt @@ -0,0 +1,43 @@ +sky + +grass + +wood + +outer + +inner + +bullseye + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the bullseye, 500 points! + +You missed! No points! + +How fast do you want the arrow? slow, medium, fast + +You hit red, 200 points! + +speed + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! diff --git a/xh-ZA/quiz1/question_1.md b/xh-ZA/quiz1/question_1.md new file mode 100644 index 000000000..7413e69a7 --- /dev/null +++ b/xh-ZA/quiz1/question_1.md @@ -0,0 +1,53 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +Here is a blue square, what are the RGB values that will create it? + +![A single block of blue colour.](images/quiz-colour.png) + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +Not quite, when all the colour values are set to `0`, the color is **black**. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite, colours follow the RGB model. This colour has maximum R value and no G or B, so will be **red**. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + That's correct! Colours follow the RGB model. This colour has no R or G, but maximum B, so will be **blue**. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite, when all the colour values are set to the `255` maximum, the color is **white**. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/xh-ZA/quiz1/question_2.md b/xh-ZA/quiz1/question_2.md new file mode 100644 index 000000000..cb8b743b2 --- /dev/null +++ b/xh-ZA/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/xh-ZA/quiz1/question_3.md b/xh-ZA/quiz1/question_3.md new file mode 100644 index 000000000..de44b3b7f --- /dev/null +++ b/xh-ZA/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/xh-ZA/step_1.md b/xh-ZA/step_1.md new file mode 100644 index 000000000..21a69d6b9 --- /dev/null +++ b/xh-ZA/step_1.md @@ -0,0 +1,40 @@ +## You will make + +Use Python, with the `p5` graphics library, to draw a target and score points by hitting it with arrows. + +You will: + + Personalise your game with **RGB colours** + + Use **conditional statements** (`if`, `elif`, `else`) to make decisions + + Position shapes with **x, y coordinates** + +--- no-print --- + +### Play ▶️ + +--- task --- + +
+
+Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + +Have a few goes. Your score appears in the output area below the target. How does your score change when the arrow lands on the different colours? + +
+
+ +--- /task --- + +--- /no-print --- + +--- print-only --- + +![Completed project.](images/yellow-points.png) + +--- /print-only --- + +

+The oldest evidence of archery comes from the Sibudu Cave in KwaZulu-Natal, South Africa. Remains of stone and bone arrowheads have been found, which date to between 60,000 and 70,000 years ago. +

+ +![](http://code.org/api/hour/begin_coderdojo_target.png) diff --git a/xh-ZA/step_2.md b/xh-ZA/step_2.md new file mode 100644 index 000000000..b03ac80cf --- /dev/null +++ b/xh-ZA/step_2.md @@ -0,0 +1,97 @@ +## Create a background + +
+
+Your game needs a colourful background. +
+
+ +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="300px"} + +
+
+ +### Open the starter project + +--- task --- + +Open the [Target practice starter](https://trinket.io/python/9973649e5c){:target="_blank"} project. + +If you have a Trinket account, you can click on the **Remix** button to save a copy to your **My Trinkets** library. + +--- /task --- + +### Edit the sky + +--- task --- + +The starter project has some code already written for you. + +Click **'Run'** to see a blue filled rectangle drawn from x=`0`, y=`0` (the top of the screen). This `400` x `250` pixels rectangle is the sky. + +![A blue rectangle with a black border around it, above a grey rectangle. The top left corner of the canvas is marked as x=0, y=0 this is the origin of the rectangle. The width is highlighted as 400 and the height as 250. The code rect(0, 0, 400, 250) is shown.](images/sky_stroke.png){:width="400px"} + +**Tip:** 💡 Coordinates start from (x=0, y=0) in the top left corner. This might be different to other coordinate systems you have used. + +--- /task --- + +--- task --- + +The sky has been drawn with a black border (stroke). + +To turn the stroke off for all shapes add `no_stroke()` to the `setup` function: + +--- code --- +--- +language: python filename: main.py — setup() line_numbers: true line_number_start: 11 +line_highlights: 15 +--- +def setup(): +# Setup your game here + size(400, 400) # width and height of screen frame_rate(2) no_stroke() + +--- /code --- + +--- /task --- + +--- task --- + +**Run** your code again and notice 👀 that the border (stroke) has now disappeared. + +--- /task --- + +### Draw the grass + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 17 +line_highlights: 27, 28 +--- +def draw(): +# Things to do in every frame + global wood sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 grass = color(149, 212, 122) wood = color(145, 96, 51) outer = color(0, 120, 180) + + fill(sky) +rect(0, 0, 400, 250) +fill(grass) # Set the fill color to grass rect(0, 250, 400, 150) # x, y, width, height + +--- /code --- + +**Tip:** 💡 We have added comments to our code, like `# Set the fill color to grass`, to tell you what it does. You don't need to add these comments to your code, but they can be helpful to remind you what lines of code do. + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project again to view the finished background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + diff --git a/xh-ZA/step_3.md b/xh-ZA/step_3.md new file mode 100644 index 000000000..39986aa1f --- /dev/null +++ b/xh-ZA/step_3.md @@ -0,0 +1,152 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `wood` (brown). + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 i the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 27 +line_highlights: 29, 30 +--- + fill(grass) +rect(0, 250, 400, 150) fill(wood) # Set the stand fill colour to wood +triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `outer` (blue). + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 29 +line_highlights: 31, 32 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) # Set the circle fill colour to outer +circle(200, 200, 170) # x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front: + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +--- task --- + +👀 Find your colour variables in the `draw` function. + +Create two variables called `inner` and `middle` to store colours for the other circles. + +The `color` function expects three numbers: one each for red, green, and blue. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 17 +line_highlights: 24, 25 +--- +def draw(): +# Things to do in every frame global wood sky = color(92, 204, 206) +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) # Blue +inner = color(210, 60, 60) # Red +middle = color(220, 200, 0) # Yellow + +--- /code --- + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 35, 36, 37, 38 +--- + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) +circle(200, 200, 170) fill(inner) # Set the circle fill colour to inner +circle(200, 200, 110) # Inner circle - x, y, width of the circle +fill(middle) # Set the circle fill colour to middle +circle(200, 200, 30) # Middle circle - x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +**Debug:** 🐞 Check that you have used the American spelling of 'color' (without a 'u'). + +--- /task --- + +--- task --- + +**Choose:** 💭 Change any of the colours. + +[[[generic-theory-simple-colours]]] + +![A brown triangle with three coloured circles on grass and against a sky. The colours have changed to pinks and purples.](images/alternative-colours.png){:width="400px"} + + +--- /task --- + + + diff --git a/xh-ZA/step_4.md b/xh-ZA/step_4.md new file mode 100644 index 000000000..995a078e0 --- /dev/null +++ b/xh-ZA/step_4.md @@ -0,0 +1,159 @@ +## Fire your arrow + +
+
+When you click or tap, an arrow will fire at the position of a moving target circle. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Draw a target circle every frame + +

Computers create the effect of movement by showing lots of images one after another. Each image is called a frame . +

+ +--- task --- + +Define your `shoot_arrow()` function under the comment **# The shoot_arrow function goes here**. + +Add code to randomly draw a brown circle within a target area: + +![A rectangle showing the target area coordinates in a semi transparent rectangle. The target area is between x=100 and y=100 to x=300 and y=300 so covers the whole target and wider.](images/target_area.png) + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 10, 11, 12, 13, 14 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) # Store a random number between 100 and 300 +arrow_y = randint(100, 300) # Store a random number between 100 and 300 +fill(wood) # Set the arrow to fill colour to wood +circle(arrow_x, arrow_y, 15) # Draw a small circle at random coordinates + +--- /code --- + +--- /task --- + +--- task --- + +Go to the `draw` function and call your new `shoot_arrow` function. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 42 +line_highlights: 44 +--- + fill(middle) +circle(200, 200, 30) +shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run you code and see the arrow appear in a random position each frame. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +The background and target will be drawn over the old arrow. This means you only see one arrow at a time. + +--- /task --- + +### Get the colour hit by the arrow + +The `get()` function returns the colour of a pixel. + +

+A pixel, short for picture element, is a single coloured dot within an image. Images are made up of lots of coloured pixels. +

+ +--- task --- + +Add code to `get` the colour of the pixel at the centre of the arrow and store it in the `hit_color` variable. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Get the hit colour fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** 💡 The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the wood colour of the arrow! + +--- /task --- + +### Print the colour when the mouse is pressed + +The `p5` library 'listens' for certain events, one of these is the press of the mouse button. When it detects that the button has been pressed, it will run whatever code it has been given in the `mouse_pressed` function. + +--- task --- + +Define your `mouse_pressed()` function under the comment **# The mouse_pressed function goes here**. + +Add code to print the amounts of red, green, and blue in the pixel the arrow lands on. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 8, 9 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +print( red(hit_color), green(hit_color), blue(hit_color) ) + +--- /code --- + +--- /task --- + +--- task --- + +Make `hit_color` a **global variable** so that it can be used throughout your code: + +--- code --- +--- +language: python filename: main.py - shoot_arrow() line_numbers: true line_number_start: 11 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +global hit_color # Can be used in other functions +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Save the colour before drawing the arrow fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. + +The project prints the `hit_color` each time the arrow is redrawn. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +**Debug:** 🐞 If you are seeing a message about `hit_color` being 'not defined', then go back to `shoot_arrow()` and check that you have the `global hit_color` line. + +**Debug:** 🐞 Check the `print` line really carefully for commas and brackets. + +--- /task --- + + diff --git a/xh-ZA/step_5.md b/xh-ZA/step_5.md new file mode 100644 index 000000000..e0660f134 --- /dev/null +++ b/xh-ZA/step_5.md @@ -0,0 +1,169 @@ +## Score points + +
+
+Your game will add scores based on where the arrow hits. +
+
+ +![The target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Go to the `draw()` function and add `, outer, inner, middle` to the list of global variables. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 28 +--- + +def draw(): +# Things to do in every frame + global wood, outer, inner, middle +sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +middle = color(220, 200, 0) + +--- /code --- + +--- /task --- + +

+We use conditions all the time to make decisions. We could say 'if the pencil is blunt, then sharpen it'. Similarly, `if` conditions let us write code that do something different depending on whether a condition is true or false. +

+ +### Display the scores + +--- task --- + +Delete ❌ the `print( red(hit_color), green(hit_color), blue(hit_color) )` line of code. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9 +--- +# The mouse_pressed function goes here +def mouse_pressed(): + + +--- /code --- + +--- /task --- + +--- task --- + +`print` a message `if` the `hit_color` is equal to `outer` 🎯. + +Notice 👀 that the code uses two equals signs `==` to mean **equal to**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9, 10 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') # Like functions, 'if' statements are indented + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the blue outer circle to see your message. + +**Tip:** 💡 `frame_rate()`, in `setup`, controls how fast your game draws. If it's going too fast, set it to a lower number. + +![The output area with arrow touching the outer circle. The points print statement appears in the output area.](images/blue-points.png) + +**Debug:** 🐞 Make sure your code matches exactly and you indented the code inside your `if` statement. + +--- /task --- + +`elif` (else - if) can be used to add more conditions to your `if` statement. These will be read from top to bottom. As soon as a **True** condition is found, it will be actioned. The remaining conditions will be ignored. + +--- task --- + +Score points if the arrow lands on the `inner` or `middle` circles 🎯: + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11, 12, 13, 14 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the inner and middle circles to see their messages. + +![The output area with arrow touching the inner circle. The points print statement appears in the output area.](images/yellow-points.png) + +**Debug:** 🐞 Check your indentation matches the example. + +**Debug:** 🐞 If you see a message about `inner` or `middle` being 'not defined', then go back to `draw()` and check that they are on the line that declares variables global. + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? ❌ + +To do this last check, you use `else`. + +--- task --- + +Add code to `print` a message `else` none of the `if` and `elif` statements have been met. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 8 +line_highlights: 15, 16 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') +else: +print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow in the grass or sky to see the miss message. + +**Choose:** 💭 Change the number of points scored for the different colours if you like. + +![The output area with an arrow missing the target. The points print statement appears in the output area.](images/missed-points.png) + +--- /task --- + diff --git a/xh-ZA/step_6.md b/xh-ZA/step_6.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/xh-ZA/step_6.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/xh-ZA/step_7.md b/xh-ZA/step_7.md new file mode 100644 index 000000000..e479b9649 --- /dev/null +++ b/xh-ZA/step_7.md @@ -0,0 +1,35 @@ +## Upgrade your project + +
+
+Personalise and add more to your project. Perhaps you could change the difficulty level or add more circles to your target. +
+
+ +![The output area showing a target with five circles.](images/five_circles.png){:width="300px"} + +
+
+ +--- task --- + +You could: + ++ Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position 🟠🟣 ++ Put emoji in your print messages ([here's a list of emoji](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) 🎯 ++ Make the game easier or harder by changing the `frame_rate(2)` value 💨 ++ Use `input()` to ask the user which difficulty level they want to play at 🗣️ + +--- /task --- + +![Upgraded project ideas: one with five circles, one with a difficulty input question, one with emoji in the points message.](images/upgrade-ideas.png) + +--- collapse --- +--- +title: Completed project +--- + +You can view the [completed project here](https://trinket.io/python/f686c82d8a){:target="_blank"}. + +--- /collapse --- + diff --git a/xh-ZA/step_8.md b/xh-ZA/step_8.md new file mode 100644 index 000000000..867ede7b9 --- /dev/null +++ b/xh-ZA/step_8.md @@ -0,0 +1,31 @@ +## What next? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png) + +--- /print-only --- + +--- no-print --- + +--- task --- + +**Try it:** Your program will adjust the animation based on how much fuel you give it and will succeed or fail in reaching orbit. How much fuel do you want to use to reach orbit but not waste too much extra fuel? + +**Tip:** Around 25,000kg should be enough, but experiment with the numbers to see what happens. + + + +![Rocket launch project](images/showcase_rocket.png) + +--- /task --- + +--- /no-print --- + +If you want to have more fun exploring Python, then you could try out any of [these projects](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + + + diff --git a/zu-ZA/images/alternative-colours.png b/zu-ZA/images/alternative-colours.png new file mode 100644 index 000000000..a688ac942 Binary files /dev/null and b/zu-ZA/images/alternative-colours.png differ diff --git a/zu-ZA/images/animation_bg_erase.gif b/zu-ZA/images/animation_bg_erase.gif new file mode 100644 index 000000000..d241286f5 Binary files /dev/null and b/zu-ZA/images/animation_bg_erase.gif differ diff --git a/zu-ZA/images/animation_no_bg_erase.gif b/zu-ZA/images/animation_no_bg_erase.gif new file mode 100644 index 000000000..c96d54052 Binary files /dev/null and b/zu-ZA/images/animation_no_bg_erase.gif differ diff --git a/zu-ZA/images/arrow-middle.png b/zu-ZA/images/arrow-middle.png new file mode 100644 index 000000000..945ca5b23 Binary files /dev/null and b/zu-ZA/images/arrow-middle.png differ diff --git a/zu-ZA/images/arrow-target.png b/zu-ZA/images/arrow-target.png new file mode 100644 index 000000000..64e413737 Binary files /dev/null and b/zu-ZA/images/arrow-target.png differ diff --git a/zu-ZA/images/background.png b/zu-ZA/images/background.png new file mode 100644 index 000000000..7d2a272de Binary files /dev/null and b/zu-ZA/images/background.png differ diff --git a/zu-ZA/images/banner.png b/zu-ZA/images/banner.png new file mode 100644 index 000000000..ddd9a5786 Binary files /dev/null and b/zu-ZA/images/banner.png differ diff --git a/zu-ZA/images/blue-circle.png b/zu-ZA/images/blue-circle.png new file mode 100644 index 000000000..65c8564cc Binary files /dev/null and b/zu-ZA/images/blue-circle.png differ diff --git a/zu-ZA/images/blue-points.png b/zu-ZA/images/blue-points.png new file mode 100644 index 000000000..7c1a8049a Binary files /dev/null and b/zu-ZA/images/blue-points.png differ diff --git a/zu-ZA/images/bottom-right.png b/zu-ZA/images/bottom-right.png new file mode 100644 index 000000000..2c4fb9e43 Binary files /dev/null and b/zu-ZA/images/bottom-right.png differ diff --git a/zu-ZA/images/centre.png b/zu-ZA/images/centre.png new file mode 100644 index 000000000..1ce8e6fc4 Binary files /dev/null and b/zu-ZA/images/centre.png differ diff --git a/zu-ZA/images/circle-coords.png b/zu-ZA/images/circle-coords.png new file mode 100644 index 000000000..6c0d2c78b Binary files /dev/null and b/zu-ZA/images/circle-coords.png differ diff --git a/zu-ZA/images/coords_animation.gif b/zu-ZA/images/coords_animation.gif new file mode 100644 index 000000000..e684f63a6 Binary files /dev/null and b/zu-ZA/images/coords_animation.gif differ diff --git a/zu-ZA/images/difficulty-setting.png b/zu-ZA/images/difficulty-setting.png new file mode 100644 index 000000000..eb2d42527 Binary files /dev/null and b/zu-ZA/images/difficulty-setting.png differ diff --git a/zu-ZA/images/fire_arrow.gif b/zu-ZA/images/fire_arrow.gif new file mode 100644 index 000000000..c084db578 Binary files /dev/null and b/zu-ZA/images/fire_arrow.gif differ diff --git a/zu-ZA/images/five_circles.png b/zu-ZA/images/five_circles.png new file mode 100644 index 000000000..524db6c9c Binary files /dev/null and b/zu-ZA/images/five_circles.png differ diff --git a/zu-ZA/images/green-grass.png b/zu-ZA/images/green-grass.png new file mode 100644 index 000000000..8c7f5794e Binary files /dev/null and b/zu-ZA/images/green-grass.png differ diff --git a/zu-ZA/images/grey-circle.png b/zu-ZA/images/grey-circle.png new file mode 100644 index 000000000..3e8d5d182 Binary files /dev/null and b/zu-ZA/images/grey-circle.png differ diff --git a/zu-ZA/images/grey-points.png b/zu-ZA/images/grey-points.png new file mode 100644 index 000000000..b516035b9 Binary files /dev/null and b/zu-ZA/images/grey-points.png differ diff --git a/zu-ZA/images/initial_target.png b/zu-ZA/images/initial_target.png new file mode 100644 index 000000000..caaca5115 Binary files /dev/null and b/zu-ZA/images/initial_target.png differ diff --git a/zu-ZA/images/missed-points.png b/zu-ZA/images/missed-points.png new file mode 100644 index 000000000..0cd14626c Binary files /dev/null and b/zu-ZA/images/missed-points.png differ diff --git a/zu-ZA/images/outline-circles.png b/zu-ZA/images/outline-circles.png new file mode 100644 index 000000000..fb31925b0 Binary files /dev/null and b/zu-ZA/images/outline-circles.png differ diff --git a/zu-ZA/images/points-scored.gif b/zu-ZA/images/points-scored.gif new file mode 100644 index 000000000..e6ddac2a3 Binary files /dev/null and b/zu-ZA/images/points-scored.gif differ diff --git a/zu-ZA/images/quiz-colour.png b/zu-ZA/images/quiz-colour.png new file mode 100644 index 000000000..e6012953c Binary files /dev/null and b/zu-ZA/images/quiz-colour.png differ diff --git a/zu-ZA/images/random-side.png b/zu-ZA/images/random-side.png new file mode 100644 index 000000000..212ea6368 Binary files /dev/null and b/zu-ZA/images/random-side.png differ diff --git a/zu-ZA/images/rectangle-diagram.png b/zu-ZA/images/rectangle-diagram.png new file mode 100644 index 000000000..8b1a8d348 Binary files /dev/null and b/zu-ZA/images/rectangle-diagram.png differ diff --git a/zu-ZA/images/showcase_rocket.png b/zu-ZA/images/showcase_rocket.png new file mode 100644 index 000000000..6586fe933 Binary files /dev/null and b/zu-ZA/images/showcase_rocket.png differ diff --git a/zu-ZA/images/showcase_static.png b/zu-ZA/images/showcase_static.png new file mode 100644 index 000000000..312d7fac1 Binary files /dev/null and b/zu-ZA/images/showcase_static.png differ diff --git a/zu-ZA/images/sky_coords.png b/zu-ZA/images/sky_coords.png new file mode 100644 index 000000000..5f918d7ef Binary files /dev/null and b/zu-ZA/images/sky_coords.png differ diff --git a/zu-ZA/images/sky_stroke.png b/zu-ZA/images/sky_stroke.png new file mode 100644 index 000000000..347018cb5 Binary files /dev/null and b/zu-ZA/images/sky_stroke.png differ diff --git a/zu-ZA/images/stand_coords.png b/zu-ZA/images/stand_coords.png new file mode 100644 index 000000000..28e151045 Binary files /dev/null and b/zu-ZA/images/stand_coords.png differ diff --git a/zu-ZA/images/step_4_preview.gif b/zu-ZA/images/step_4_preview.gif new file mode 100644 index 000000000..06af11669 Binary files /dev/null and b/zu-ZA/images/step_4_preview.gif differ diff --git a/zu-ZA/images/step_5_preview.gif b/zu-ZA/images/step_5_preview.gif new file mode 100644 index 000000000..49c6e41a3 Binary files /dev/null and b/zu-ZA/images/step_5_preview.gif differ diff --git a/zu-ZA/images/target-stand.png b/zu-ZA/images/target-stand.png new file mode 100644 index 000000000..c64259beb Binary files /dev/null and b/zu-ZA/images/target-stand.png differ diff --git a/zu-ZA/images/target_area.png b/zu-ZA/images/target_area.png new file mode 100644 index 000000000..72d80ba1d Binary files /dev/null and b/zu-ZA/images/target_area.png differ diff --git a/zu-ZA/images/three-circles.png b/zu-ZA/images/three-circles.png new file mode 100644 index 000000000..90a5e243a Binary files /dev/null and b/zu-ZA/images/three-circles.png differ diff --git a/zu-ZA/images/top-left.png b/zu-ZA/images/top-left.png new file mode 100644 index 000000000..3cb3e458f Binary files /dev/null and b/zu-ZA/images/top-left.png differ diff --git a/zu-ZA/images/triangles-coords.png b/zu-ZA/images/triangles-coords.png new file mode 100644 index 000000000..1eec68b23 Binary files /dev/null and b/zu-ZA/images/triangles-coords.png differ diff --git a/zu-ZA/images/upgrade-ideas.png b/zu-ZA/images/upgrade-ideas.png new file mode 100644 index 000000000..bfda023ae Binary files /dev/null and b/zu-ZA/images/upgrade-ideas.png differ diff --git a/zu-ZA/images/yellow-points.png b/zu-ZA/images/yellow-points.png new file mode 100644 index 000000000..5e702c248 Binary files /dev/null and b/zu-ZA/images/yellow-points.png differ diff --git a/zu-ZA/meta.yml b/zu-ZA/meta.yml new file mode 100644 index 000000000..d4420e902 --- /dev/null +++ b/zu-ZA/meta.yml @@ -0,0 +1,36 @@ +--- +title: Target practice +hero_image: images/banner.png +description: Use Python to draw a target and score points by hitting it with arrows +version: 4 +listed: true +copyedit: true +last_tested: "2021-10-06" +steps: + - + title: You will make + - + title: Create a background + - + title: Draw your target + completion: + - engaged + - + title: Fire your arrow + - + title: Score points + completion: + - internal + - + title: Quick quiz + knowledge_quiz: + path: quiz1 + version: 1 + questions: 3 + passing_score: 3 + completion: + - external + - + title: Upgrade your project + - + title: What next? diff --git a/zu-ZA/python-comments-demo.txt b/zu-ZA/python-comments-demo.txt new file mode 100644 index 000000000..cb2eb5621 --- /dev/null +++ b/zu-ZA/python-comments-demo.txt @@ -0,0 +1,73 @@ +Setup your game here + +width and height of screen + +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Set the fill color to grass + +x, y, width, height + +Set the stand fill colour to wood + +Set the circle fill colour to outer + +x, y, width of the circle + +Blue + +Red + +Yellow + +Set the circle fill colour to inner + +Inner circle - x, y, width of the circle + +Set the circle fill colour to middle + +Middle circle - x, y, width of the circle + +The shoot_arrow function goes here + +Store a random number between 100 and 300 + +Set the arrow to fill colour to wood + +Draw a small circle at random coordinates + +Get the hit colour + +The mouse_pressed function goes here + +Can be used in other functions + +Save the colour before drawing the arrow + +Like functions, 'if' statements are indented + +Import library code + +Keep this to run your code + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Set the fill color to grass diff --git a/zu-ZA/python-comments.txt b/zu-ZA/python-comments.txt new file mode 100644 index 000000000..160666a85 --- /dev/null +++ b/zu-ZA/python-comments.txt @@ -0,0 +1,87 @@ +Things to do in every frame + +Red = 92, Green = 204, Blue = 206 + +Start x, start y, width, height + +x, y, width, height + +Set the stand fill colour to wood + +Set the arrow to fill colour to wood + +Set the stand fill colour to grass + +Set the circle fill colour to outer + +Set the circle fill colour to inner + +Set the circle fill colour to middle + +x, y, width of the circle + +Inner circle - x, y, width of the circle + +Middle circle - x, y, width of the circle + +Outer circle.200, 200 is the middle of the screen + +Blue + +Red + +Yellow + +Stand + +Outer circle + +Inner circle + +Bullseye + +The shoot_arrow function goes here + +Import library code + +Update to random coordinates + +Save the colour before drawing the arrow + +The mouse_pressed function goes here + +Can be used in other functions + +Like functions, 'if' statements are indented + +Setup your game here + +width and height + +Definitions for compatibility with the p5py processing library + +Shape + +Fonts + +Text + +Colour + +Images + +Environment + +Transform + +Keyboard + +Keep this to run your code + +Store a random number between 100 and 300 + +Get the hit colour + +Draw a small circle at random coordinates + +width and height of screen diff --git a/zu-ZA/python-translatable-demo.txt b/zu-ZA/python-translatable-demo.txt new file mode 100644 index 000000000..71707d059 --- /dev/null +++ b/zu-ZA/python-translatable-demo.txt @@ -0,0 +1,37 @@ +wood + +sky + +grass + +outer + +inner + +middle + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You missed! No points! + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! + +speed diff --git a/zu-ZA/python-translatable.txt b/zu-ZA/python-translatable.txt new file mode 100644 index 000000000..75c0058cc --- /dev/null +++ b/zu-ZA/python-translatable.txt @@ -0,0 +1,43 @@ +sky + +grass + +wood + +outer + +inner + +bullseye + +shoot_arrow + +arrow_x + +arrow_y + +hit_color + +You hit the outer circle, 50 points! + +You hit the inner circle, 200 points! + +You hit the middle, 500 points! + +You hit the bullseye, 500 points! + +You missed! No points! + +How fast do you want the arrow? slow, medium, fast + +You hit red, 200 points! + +speed + +Super fast + +Pretty quick + +Very fast + +Speed not recognised! diff --git a/zu-ZA/quiz1/question_1.md b/zu-ZA/quiz1/question_1.md new file mode 100644 index 000000000..7413e69a7 --- /dev/null +++ b/zu-ZA/quiz1/question_1.md @@ -0,0 +1,53 @@ +## Quick quiz + +Answer the three questions. There are hints to guide you to the correct answer. + +When you have answered each question, click on **Check my answer**. + +Have fun! + +--- question --- +--- +legend: Question 1 of 3 +--- +Here is a blue square, what are the RGB values that will create it? + +![A single block of blue colour.](images/quiz-colour.png) + +--- choices --- + +- ( ) (0, 0, 0) + + --- feedback --- + +Not quite, when all the colour values are set to `0`, the color is **black**. + + --- /feedback --- + +- ( ) (255, 0, 0) + + --- feedback --- + +Not quite, colours follow the RGB model. This colour has maximum R value and no G or B, so will be **red**. + + --- /feedback --- + +- (x) (0, 0, 255) + + --- feedback --- + + That's correct! Colours follow the RGB model. This colour has no R or G, but maximum B, so will be **blue**. + + --- /feedback --- + +- ( ) (255, 255, 255) + + --- feedback --- + + Not quite, when all the colour values are set to the `255` maximum, the color is **white**. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/zu-ZA/quiz1/question_2.md b/zu-ZA/quiz1/question_2.md new file mode 100644 index 000000000..cb8b743b2 --- /dev/null +++ b/zu-ZA/quiz1/question_2.md @@ -0,0 +1,49 @@ + +--- question --- +--- +legend: Question 2 of 3 +--- + +In your project, you used `if` , `elif`, and `else` conditions to check which colour the arrow landed on. + +In the example below, a variable called `speed` has the number `6` stored in it. When this `if` statement is run, what would be printed in the output area? + +--- code --- +--- +language: python +--- +speed = 6 + +if speed == 7: print('Super fast') elif speed == 5: print('Pretty quick') elif speed == 6: print('Very fast') else: print('Speed not recognised!') + +--- /code --- + +--- choices --- + +- (x) `Very fast` + + --- feedback --- + + That's correct! The **speed** variable has been assigned the value `6`, which makes the `speed == 6` condition **True** and prints `Very fast`. + + --- /feedback --- + +- ( ) `Speed not recognised!` + + --- feedback --- + + Not quite, look at the value assigned to the **speed** variable. + + --- /feedback --- + +- ( ) Nothing gets printed + + --- feedback --- + + Try again, `else` is used as a final option for when all the above conditions are false. Look through the conditions again, are any of the conditions true? + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/zu-ZA/quiz1/question_3.md b/zu-ZA/quiz1/question_3.md new file mode 100644 index 000000000..de44b3b7f --- /dev/null +++ b/zu-ZA/quiz1/question_3.md @@ -0,0 +1,64 @@ + +--- question --- +--- +legend: Question 3 of 3 +--- + +A circle is drawn using the following code: + +--- code --- +--- +language: python +--- + +def setup(): +size(400, 400) +fill(0, 255, 0) +no_stroke() + +def draw(): +circle(0, 0, 300) + +run() + +--- /code --- + +Which of the images below show the correct position of this circle in the output area? + +--- choices --- + +- ( ) ![A green circle centred in the bottom-right corner of the output area.](images/bottom-right.png) + + --- feedback --- + + Not quite, to centre the circle in the bottom-right corner, the coordinates would need to be the same as the screen size. In this example, the ellipse would be `circle(400, 400, 300)`. + + --- /feedback --- + +- ( ) ![A green circle centred in the middle of the output area.](images/centre.png) + + --- feedback --- + + Not quite, to centre the circle in the middle, the coordinates would need to be half of the screen size. In this example, `circle(200, 200, 300)`. + + --- /feedback --- + +- (x) ![A green circle centred in the top-left corner of the output area.](images/top-left.png) + + --- feedback --- + + That's correct! This circle is centred at coordinates (0,0), the top-left corner of the screen. + + --- /feedback --- + +- ( ) ![A green circle centred towards the top-right side of the output area.](images/random-side.png) + + --- feedback --- + + No, this circle would have code of `circle(350, 150, 300)` to centre it towards the top-right of the screen. The `x` coordinate is how far across the screen the ellipse is, and the `y` coordinate is how far down the screen it is. + + --- /feedback --- + +--- /choices --- + +--- /question --- diff --git a/zu-ZA/step_1.md b/zu-ZA/step_1.md new file mode 100644 index 000000000..21a69d6b9 --- /dev/null +++ b/zu-ZA/step_1.md @@ -0,0 +1,40 @@ +## You will make + +Use Python, with the `p5` graphics library, to draw a target and score points by hitting it with arrows. + +You will: + + Personalise your game with **RGB colours** + + Use **conditional statements** (`if`, `elif`, `else`) to make decisions + + Position shapes with **x, y coordinates** + +--- no-print --- + +### Play ▶️ + +--- task --- + +
+
+Click the **Run** button below to start the game. When the dot appears on the target 🎯, click the mouse (or tap on your tablet) to fire your arrow. + +Have a few goes. Your score appears in the output area below the target. How does your score change when the arrow lands on the different colours? + +
+
+ +--- /task --- + +--- /no-print --- + +--- print-only --- + +![Completed project.](images/yellow-points.png) + +--- /print-only --- + +

+The oldest evidence of archery comes from the Sibudu Cave in KwaZulu-Natal, South Africa. Remains of stone and bone arrowheads have been found, which date to between 60,000 and 70,000 years ago. +

+ +![](http://code.org/api/hour/begin_coderdojo_target.png) diff --git a/zu-ZA/step_2.md b/zu-ZA/step_2.md new file mode 100644 index 000000000..b03ac80cf --- /dev/null +++ b/zu-ZA/step_2.md @@ -0,0 +1,97 @@ +## Create a background + +
+
+Your game needs a colourful background. +
+
+ +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="300px"} + +
+
+ +### Open the starter project + +--- task --- + +Open the [Target practice starter](https://trinket.io/python/9973649e5c){:target="_blank"} project. + +If you have a Trinket account, you can click on the **Remix** button to save a copy to your **My Trinkets** library. + +--- /task --- + +### Edit the sky + +--- task --- + +The starter project has some code already written for you. + +Click **'Run'** to see a blue filled rectangle drawn from x=`0`, y=`0` (the top of the screen). This `400` x `250` pixels rectangle is the sky. + +![A blue rectangle with a black border around it, above a grey rectangle. The top left corner of the canvas is marked as x=0, y=0 this is the origin of the rectangle. The width is highlighted as 400 and the height as 250. The code rect(0, 0, 400, 250) is shown.](images/sky_stroke.png){:width="400px"} + +**Tip:** 💡 Coordinates start from (x=0, y=0) in the top left corner. This might be different to other coordinate systems you have used. + +--- /task --- + +--- task --- + +The sky has been drawn with a black border (stroke). + +To turn the stroke off for all shapes add `no_stroke()` to the `setup` function: + +--- code --- +--- +language: python filename: main.py — setup() line_numbers: true line_number_start: 11 +line_highlights: 15 +--- +def setup(): +# Setup your game here + size(400, 400) # width and height of screen frame_rate(2) no_stroke() + +--- /code --- + +--- /task --- + +--- task --- + +**Run** your code again and notice 👀 that the border (stroke) has now disappeared. + +--- /task --- + +### Draw the grass + +--- task --- + +**Add** code to draw a green rectangle at the bottom of the screen. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background. The top left corner of the rectangle is marked as x=0, y=250 this is the origin of the rectangle. The width is highlighted as 400 and the height as 150. The code rect(0, 250, 400, 150) is shown.](images/green-grass.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 17 +line_highlights: 27, 28 +--- +def draw(): +# Things to do in every frame + global wood sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 grass = color(149, 212, 122) wood = color(145, 96, 51) outer = color(0, 120, 180) + + fill(sky) +rect(0, 0, 400, 250) +fill(grass) # Set the fill color to grass rect(0, 250, 400, 150) # x, y, width, height + +--- /code --- + +**Tip:** 💡 We have added comments to our code, like `# Set the fill color to grass`, to tell you what it does. You don't need to add these comments to your code, but they can be helpful to remind you what lines of code do. + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project again to view the finished background. + +![The output area with a sky-coloured rectangle above a grass-coloured rectangle to create the background.](images/background.png){:width="400px"} + +--- /task --- + diff --git a/zu-ZA/step_3.md b/zu-ZA/step_3.md new file mode 100644 index 000000000..39986aa1f --- /dev/null +++ b/zu-ZA/step_3.md @@ -0,0 +1,152 @@ +## Draw your target + +
+
+Your game needs a target to shoot arrows at. +
+
+ +![The output area with the target and stand.](images/three-circles.png){:width="300px"} + +
+
+ +### Draw a triangular stand + +--- task --- + +Set the fill colour to `wood` (brown). + +Draw a triangle using the x and y coordinates for each of the corners. + +![A brown triangle on grass and against a sky with the coordinate points labelled at 150, 350 and 200, 150 and 250, 350). The corners of the canvas are also labelled as x=0, y=0 in the top left and x=400, y=400 i the bottom right.](images/stand_coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 27 +line_highlights: 29, 30 +--- + fill(grass) +rect(0, 250, 400, 150) fill(wood) # Set the stand fill colour to wood +triangle(150, 350, 200, 150, 250, 350) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your code to see the stand for your target: + +![A brown triangle on grass and against a sky.](images/target-stand.png){:width="400px"} + +--- /task --- + +### Draw the target circles + +--- task --- + +The largest part of the target is a blue **circle**. + +Set the fill colour to `outer` (blue). + +Draw a circle with x and y coordinates for its centre and a width. + +![A brown triangle and blue circle on grass and against a sky. The circle is labelled with the coordinates x=200, y=200 as the centre and circle width of 170.](images/circle-coords.png){:width="400px"} + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 29 +line_highlights: 31, 32 +--- + + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) # Set the circle fill colour to outer +circle(200, 200, 170) # x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** Run your code to see the first large blue circle. + +The blue circle was drawn after the stand so it is in front: + +![A brown triangle and blue circle on grass and against a sky.](images/blue-circle.png){:width="400px"} + +--- /task --- + +--- task --- + +👀 Find your colour variables in the `draw` function. + +Create two variables called `inner` and `middle` to store colours for the other circles. + +The `color` function expects three numbers: one each for red, green, and blue. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 17 +line_highlights: 24, 25 +--- +def draw(): +# Things to do in every frame global wood sky = color(92, 204, 206) +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) # Blue +inner = color(210, 60, 60) # Red +middle = color(220, 200, 0) # Yellow + +--- /code --- + +--- /task --- + +The target is made of different-sized circles with the same centre coordinates (200, 200). + +--- task --- + +**Add** coloured circles for the inner and middle parts of the target. + +--- code --- +--- +language: python filename: main.py - draw() line_numbers: true line_number_start: 31 +line_highlights: 35, 36, 37, 38 +--- + fill(wood) +triangle(150, 350, 200, 150, 250, 350) +fill(outer) +circle(200, 200, 170) fill(inner) # Set the circle fill colour to inner +circle(200, 200, 110) # Inner circle - x, y, width of the circle +fill(middle) # Set the circle fill colour to middle +circle(200, 200, 30) # Middle circle - x, y, width of the circle + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project to see the target with three coloured circles. + +![A brown triangle with three coloured circles on grass and against a sky.](images/three-circles.png){:width="400px"} + +**Debug:** 🐞 Check that you have used the American spelling of 'color' (without a 'u'). + +--- /task --- + +--- task --- + +**Choose:** 💭 Change any of the colours. + +[[[generic-theory-simple-colours]]] + +![A brown triangle with three coloured circles on grass and against a sky. The colours have changed to pinks and purples.](images/alternative-colours.png){:width="400px"} + + +--- /task --- + + + diff --git a/zu-ZA/step_4.md b/zu-ZA/step_4.md new file mode 100644 index 000000000..995a078e0 --- /dev/null +++ b/zu-ZA/step_4.md @@ -0,0 +1,159 @@ +## Fire your arrow + +
+
+When you click or tap, an arrow will fire at the position of a moving target circle. +
+
+ +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif){:width="300px"} + +
+
+ +### Draw a target circle every frame + +

Computers create the effect of movement by showing lots of images one after another. Each image is called a frame . +

+ +--- task --- + +Define your `shoot_arrow()` function under the comment **# The shoot_arrow function goes here**. + +Add code to randomly draw a brown circle within a target area: + +![A rectangle showing the target area coordinates in a semi transparent rectangle. The target area is between x=100 and y=100 to x=300 and y=300 so covers the whole target and wider.](images/target_area.png) + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 10, 11, 12, 13, 14 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) # Store a random number between 100 and 300 +arrow_y = randint(100, 300) # Store a random number between 100 and 300 +fill(wood) # Set the arrow to fill colour to wood +circle(arrow_x, arrow_y, 15) # Draw a small circle at random coordinates + +--- /code --- + +--- /task --- + +--- task --- + +Go to the `draw` function and call your new `shoot_arrow` function. + +--- code --- +--- +language: python filename: main.py — draw() line_numbers: true line_number_start: 42 +line_highlights: 44 +--- + fill(middle) +circle(200, 200, 30) +shoot_arrow() + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run you code and see the arrow appear in a random position each frame. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +The background and target will be drawn over the old arrow. This means you only see one arrow at a time. + +--- /task --- + +### Get the colour hit by the arrow + +The `get()` function returns the colour of a pixel. + +

+A pixel, short for picture element, is a single coloured dot within an image. Images are made up of lots of coloured pixels. +

+ +--- task --- + +Add code to `get` the colour of the pixel at the centre of the arrow and store it in the `hit_color` variable. + +--- code --- +--- +language: python filename: main.py — shoot_arrow() line_numbers: true line_number_start: 9 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Get the hit colour fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +**Tip:** 💡 The code to `get` the colour needs to be **before** the code to draw the `circle` otherwise you will always save the wood colour of the arrow! + +--- /task --- + +### Print the colour when the mouse is pressed + +The `p5` library 'listens' for certain events, one of these is the press of the mouse button. When it detects that the button has been pressed, it will run whatever code it has been given in the `mouse_pressed` function. + +--- task --- + +Define your `mouse_pressed()` function under the comment **# The mouse_pressed function goes here**. + +Add code to print the amounts of red, green, and blue in the pixel the arrow lands on. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 8, 9 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +print( red(hit_color), green(hit_color), blue(hit_color) ) + +--- /code --- + +--- /task --- + +--- task --- + +Make `hit_color` a **global variable** so that it can be used throughout your code: + +--- code --- +--- +language: python filename: main.py - shoot_arrow() line_numbers: true line_number_start: 11 +line_highlights: 13 +--- +# The shoot_arrow function goes here +def shoot_arrow(): +global hit_color # Can be used in other functions +arrow_x = randint(100, 300) +arrow_y = randint(100, 300) +hit_color = get(arrow_x, arrow_y) # Save the colour before drawing the arrow fill(wood) +circle(arrow_x, arrow_y, 15) + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. + +The project prints the `hit_color` each time the arrow is redrawn. + +![The target, with a brown circle arrow appearing in a variety of positions.](images/fire_arrow.gif) + +**Debug:** 🐞 If you are seeing a message about `hit_color` being 'not defined', then go back to `shoot_arrow()` and check that you have the `global hit_color` line. + +**Debug:** 🐞 Check the `print` line really carefully for commas and brackets. + +--- /task --- + + diff --git a/zu-ZA/step_5.md b/zu-ZA/step_5.md new file mode 100644 index 000000000..e0660f134 --- /dev/null +++ b/zu-ZA/step_5.md @@ -0,0 +1,169 @@ +## Score points + +
+
+Your game will add scores based on where the arrow hits. +
+
+ +![The target, with the arrow appearing in a variety of positions, and scores appearing as text below the game.](images/points-scored.gif){:width="300px"} + +
+
+ +--- task --- + +Go to the `draw()` function and add `, outer, inner, middle` to the list of global variables. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 26 +line_highlights: 28 +--- + +def draw(): +# Things to do in every frame + global wood, outer, inner, middle +sky = color(92, 204, 206) # Red = 92, Green = 204, Blue = 206 +grass = color(149, 212, 122) +wood = color(145, 96, 51) +outer = color(0, 120, 180) +inner = color(210, 60, 60) +middle = color(220, 200, 0) + +--- /code --- + +--- /task --- + +

+We use conditions all the time to make decisions. We could say 'if the pencil is blunt, then sharpen it'. Similarly, `if` conditions let us write code that do something different depending on whether a condition is true or false. +

+ +### Display the scores + +--- task --- + +Delete ❌ the `print( red(hit_color), green(hit_color), blue(hit_color) )` line of code. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9 +--- +# The mouse_pressed function goes here +def mouse_pressed(): + + +--- /code --- + +--- /task --- + +--- task --- + +`print` a message `if` the `hit_color` is equal to `outer` 🎯. + +Notice 👀 that the code uses two equals signs `==` to mean **equal to**. + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 7 +line_highlights: 9, 10 +--- + +# The mouse_pressed function goes here +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') # Like functions, 'if' statements are indented + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the blue outer circle to see your message. + +**Tip:** 💡 `frame_rate()`, in `setup`, controls how fast your game draws. If it's going too fast, set it to a lower number. + +![The output area with arrow touching the outer circle. The points print statement appears in the output area.](images/blue-points.png) + +**Debug:** 🐞 Make sure your code matches exactly and you indented the code inside your `if` statement. + +--- /task --- + +`elif` (else - if) can be used to add more conditions to your `if` statement. These will be read from top to bottom. As soon as a **True** condition is found, it will be actioned. The remaining conditions will be ignored. + +--- task --- + +Score points if the arrow lands on the `inner` or `middle` circles 🎯: + +--- code --- +--- +language: python filename: main.py - mouse_pressed() line_numbers: true line_number_start: 8 +line_highlights: 11, 12, 13, 14 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow on the inner and middle circles to see their messages. + +![The output area with arrow touching the inner circle. The points print statement appears in the output area.](images/yellow-points.png) + +**Debug:** 🐞 Check your indentation matches the example. + +**Debug:** 🐞 If you see a message about `inner` or `middle` being 'not defined', then go back to `draw()` and check that they are on the line that declares variables global. + +--- /task --- + +### Missing the target + +There is one more decision you need to make: what happens if the arrow does not land on any of the target circles? ❌ + +To do this last check, you use `else`. + +--- task --- + +Add code to `print` a message `else` none of the `if` and `elif` statements have been met. + +--- code --- +--- +language: python filename: main.py line_numbers: true line_number_start: 8 +line_highlights: 15, 16 +--- + +def mouse_pressed(): +if hit_color == outer: +print('You hit the outer circle, 50 points!') +elif hit_color == inner: +print('You hit the inner circle, 200 points!') +elif hit_color == middle: +print('You hit the middle, 500 points!') +else: +print('You missed! No points!') + +--- /code --- + +--- /task --- + +--- task --- + +**Test:** 🔄 Run your project. Try to stop the arrow in the grass or sky to see the miss message. + +**Choose:** 💭 Change the number of points scored for the different colours if you like. + +![The output area with an arrow missing the target. The points print statement appears in the output area.](images/missed-points.png) + +--- /task --- + diff --git a/zu-ZA/step_6.md b/zu-ZA/step_6.md new file mode 100644 index 000000000..ef044b75d --- /dev/null +++ b/zu-ZA/step_6.md @@ -0,0 +1 @@ +## Quick quiz \ No newline at end of file diff --git a/zu-ZA/step_7.md b/zu-ZA/step_7.md new file mode 100644 index 000000000..e479b9649 --- /dev/null +++ b/zu-ZA/step_7.md @@ -0,0 +1,35 @@ +## Upgrade your project + +
+
+Personalise and add more to your project. Perhaps you could change the difficulty level or add more circles to your target. +
+
+ +![The output area showing a target with five circles.](images/five_circles.png){:width="300px"} + +
+
+ +--- task --- + +You could: + ++ Add a `fourth` and `fifth` circle, in new colours, which score different amounts of points based on their position 🟠🟣 ++ Put emoji in your print messages ([here's a list of emoji](https://unicode.org/emoji/charts/full-emoji-list.html){:target="_blank"} you can copy from) 🎯 ++ Make the game easier or harder by changing the `frame_rate(2)` value 💨 ++ Use `input()` to ask the user which difficulty level they want to play at 🗣️ + +--- /task --- + +![Upgraded project ideas: one with five circles, one with a difficulty input question, one with emoji in the points message.](images/upgrade-ideas.png) + +--- collapse --- +--- +title: Completed project +--- + +You can view the [completed project here](https://trinket.io/python/f686c82d8a){:target="_blank"}. + +--- /collapse --- + diff --git a/zu-ZA/step_8.md b/zu-ZA/step_8.md new file mode 100644 index 000000000..867ede7b9 --- /dev/null +++ b/zu-ZA/step_8.md @@ -0,0 +1,31 @@ +## What next? + +If you are following the [Introduction to Python](https://projects.raspberrypi.org/en/raspberrypi/python-intro) pathway, you can move on to the [Rocket launch](https://projects.raspberrypi.org/en/projects/rocket-launch) project. In this project, you will make an interactive animation of a rocket launching a satellite into orbit. + +--- print-only --- + +![Rocket launch project.](images/showcase_rocket.png) + +--- /print-only --- + +--- no-print --- + +--- task --- + +**Try it:** Your program will adjust the animation based on how much fuel you give it and will succeed or fail in reaching orbit. How much fuel do you want to use to reach orbit but not waste too much extra fuel? + +**Tip:** Around 25,000kg should be enough, but experiment with the numbers to see what happens. + + + +![Rocket launch project](images/showcase_rocket.png) + +--- /task --- + +--- /no-print --- + +If you want to have more fun exploring Python, then you could try out any of [these projects](https://projects.raspberrypi.org/en/projects?software%5B%5D=python). + + +