diff --git a/lib/tasks/project_components/dont-collide-starter/astronaut1.png b/lib/tasks/project_components/dont-collide-starter/astronaut1.png new file mode 100644 index 00000000..07f7a8b4 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/astronaut1.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/astronaut2.png b/lib/tasks/project_components/dont-collide-starter/astronaut2.png new file mode 100644 index 00000000..b47505f4 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/astronaut2.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/earth.png b/lib/tasks/project_components/dont-collide-starter/earth.png new file mode 100644 index 00000000..e37920c0 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/earth.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/flowers.png b/lib/tasks/project_components/dont-collide-starter/flowers.png new file mode 100644 index 00000000..9bf7884b Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/flowers.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/iss.png b/lib/tasks/project_components/dont-collide-starter/iss.png new file mode 100644 index 00000000..c7f9d907 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/iss.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/moon.png b/lib/tasks/project_components/dont-collide-starter/moon.png new file mode 100644 index 00000000..62930b46 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/moon.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/planet1.png b/lib/tasks/project_components/dont-collide-starter/planet1.png new file mode 100644 index 00000000..a670636b Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/planet1.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/planet2.png b/lib/tasks/project_components/dont-collide-starter/planet2.png new file mode 100644 index 00000000..76bf52e6 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/planet2.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/project_config.yml b/lib/tasks/project_components/dont-collide-starter/project_config.yml index b1b63403..fb934ec3 100644 --- a/lib/tasks/project_components/dont-collide-starter/project_config.yml +++ b/lib/tasks/project_components/dont-collide-starter/project_config.yml @@ -6,3 +6,18 @@ COMPONENTS: location: "main.py" index: 0 default: true +IMAGES: + - "astronaut1.png" + - "astronaut2.png" + - "earth.png" + - "flowers.png" + - "iss.png" + - "moon.png" + - "planet1.png" + - "planet2.png" + - "rocket1.png" + - "rocket2.png" + - "shark.png" + - "tree.png" + - "treefeller.png" + - "turtle.png" diff --git a/lib/tasks/project_components/dont-collide-starter/rocket1.png b/lib/tasks/project_components/dont-collide-starter/rocket1.png new file mode 100644 index 00000000..970fbecd Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/rocket1.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/rocket2.png b/lib/tasks/project_components/dont-collide-starter/rocket2.png new file mode 100644 index 00000000..6aee645a Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/rocket2.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/shark.png b/lib/tasks/project_components/dont-collide-starter/shark.png new file mode 100644 index 00000000..6d44f97a Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/shark.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/tree.png b/lib/tasks/project_components/dont-collide-starter/tree.png new file mode 100644 index 00000000..6726eff9 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/tree.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/treefeller.png b/lib/tasks/project_components/dont-collide-starter/treefeller.png new file mode 100644 index 00000000..0bc5361b Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/treefeller.png differ diff --git a/lib/tasks/project_components/dont-collide-starter/turtle.png b/lib/tasks/project_components/dont-collide-starter/turtle.png new file mode 100644 index 00000000..66f6e622 Binary files /dev/null and b/lib/tasks/project_components/dont-collide-starter/turtle.png differ diff --git a/lib/tasks/project_components/dont_collide_clean_car_example/car.png b/lib/tasks/project_components/dont_collide_clean_car_example/car.png new file mode 100644 index 00000000..893d8eb5 Binary files /dev/null and b/lib/tasks/project_components/dont_collide_clean_car_example/car.png differ diff --git a/lib/tasks/project_components/dont_collide_clean_car_example/project_config.yml b/lib/tasks/project_components/dont_collide_clean_car_example/project_config.yml index 298aafcc..15e8e0e3 100644 --- a/lib/tasks/project_components/dont_collide_clean_car_example/project_config.yml +++ b/lib/tasks/project_components/dont_collide_clean_car_example/project_config.yml @@ -6,3 +6,5 @@ COMPONENTS: location: "main.py" index: 0 default: true +IMAGES: + - "car.png" diff --git a/lib/tasks/project_components/dont_collide_dodge_asteroids_example/moon.png b/lib/tasks/project_components/dont_collide_dodge_asteroids_example/moon.png new file mode 100644 index 00000000..62930b46 Binary files /dev/null and b/lib/tasks/project_components/dont_collide_dodge_asteroids_example/moon.png differ diff --git a/lib/tasks/project_components/dont_collide_dodge_asteroids_example/project_config.yml b/lib/tasks/project_components/dont_collide_dodge_asteroids_example/project_config.yml index dcf0ca6d..ebffbd72 100644 --- a/lib/tasks/project_components/dont_collide_dodge_asteroids_example/project_config.yml +++ b/lib/tasks/project_components/dont_collide_dodge_asteroids_example/project_config.yml @@ -6,3 +6,6 @@ COMPONENTS: location: "main.py" index: 0 default: true +IMAGES: + - "moon.png" + - "rocket.png" diff --git a/lib/tasks/project_components/dont_collide_dodge_asteroids_example/rocket.png b/lib/tasks/project_components/dont_collide_dodge_asteroids_example/rocket.png new file mode 100644 index 00000000..970fbecd Binary files /dev/null and b/lib/tasks/project_components/dont_collide_dodge_asteroids_example/rocket.png differ diff --git a/lib/tasks/project_components/dont_collide_dont_pop_example/main.py b/lib/tasks/project_components/dont_collide_dont_pop_example/main.py index 442320bd..42199b98 100644 --- a/lib/tasks/project_components/dont_collide_dont_pop_example/main.py +++ b/lib/tasks/project_components/dont_collide_dont_pop_example/main.py @@ -53,9 +53,9 @@ def draw_player(): def setup(): # Setup your animation here + size(400, 400) text_size(40) text_align(CENTER, TOP) # position around the centre, top - size(400, 400) def draw(): diff --git a/lib/tasks/project_components/dont_collide_skiing_cat_example/fallenover.png b/lib/tasks/project_components/dont_collide_skiing_cat_example/fallenover.png new file mode 100644 index 00000000..c5df1ab9 Binary files /dev/null and b/lib/tasks/project_components/dont_collide_skiing_cat_example/fallenover.png differ diff --git a/lib/tasks/project_components/dont_collide_skiing_cat_example/project_config.yml b/lib/tasks/project_components/dont_collide_skiing_cat_example/project_config.yml index 59324b6f..9f05e9bc 100644 --- a/lib/tasks/project_components/dont_collide_skiing_cat_example/project_config.yml +++ b/lib/tasks/project_components/dont_collide_skiing_cat_example/project_config.yml @@ -6,3 +6,6 @@ COMPONENTS: location: "main.py" index: 0 default: true +IMAGES: + - "fallenover.png" + - "skiing.png" diff --git a/lib/tasks/project_components/dont_collide_skiing_cat_example/skiing.png b/lib/tasks/project_components/dont_collide_skiing_cat_example/skiing.png new file mode 100644 index 00000000..215d3074 Binary files /dev/null and b/lib/tasks/project_components/dont_collide_skiing_cat_example/skiing.png differ diff --git a/lib/tasks/project_components/rocket_launch_example/moon.png b/lib/tasks/project_components/rocket_launch_example/moon.png new file mode 100644 index 00000000..62930b46 Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_example/moon.png differ diff --git a/lib/tasks/project_components/rocket_launch_example/orange_planet.png b/lib/tasks/project_components/rocket_launch_example/orange_planet.png new file mode 100644 index 00000000..a670636b Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_example/orange_planet.png differ diff --git a/lib/tasks/project_components/rocket_launch_example/planet.png b/lib/tasks/project_components/rocket_launch_example/planet.png new file mode 100644 index 00000000..e37920c0 Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_example/planet.png differ diff --git a/lib/tasks/project_components/rocket_launch_example/project_config.yml b/lib/tasks/project_components/rocket_launch_example/project_config.yml index 3fa9056d..fe2b6a47 100644 --- a/lib/tasks/project_components/rocket_launch_example/project_config.yml +++ b/lib/tasks/project_components/rocket_launch_example/project_config.yml @@ -6,3 +6,9 @@ COMPONENTS: location: "main.py" index: 0 default: true +IMAGES: + - "moon.png" + - "orange_planet.png" + - "planet.png" + - "purple_planet.png" + - "rocket.png" diff --git a/lib/tasks/project_components/rocket_launch_example/purple_planet.png b/lib/tasks/project_components/rocket_launch_example/purple_planet.png new file mode 100644 index 00000000..76bf52e6 Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_example/purple_planet.png differ diff --git a/lib/tasks/project_components/rocket_launch_example/rocket.png b/lib/tasks/project_components/rocket_launch_example/rocket.png new file mode 100644 index 00000000..970fbecd Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_example/rocket.png differ diff --git a/lib/tasks/project_components/rocket_launch_starter/moon.png b/lib/tasks/project_components/rocket_launch_starter/moon.png new file mode 100644 index 00000000..62930b46 Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_starter/moon.png differ diff --git a/lib/tasks/project_components/rocket_launch_starter/orange_planet.png b/lib/tasks/project_components/rocket_launch_starter/orange_planet.png new file mode 100644 index 00000000..a670636b Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_starter/orange_planet.png differ diff --git a/lib/tasks/project_components/rocket_launch_starter/planet.png b/lib/tasks/project_components/rocket_launch_starter/planet.png new file mode 100644 index 00000000..e37920c0 Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_starter/planet.png differ diff --git a/lib/tasks/project_components/rocket_launch_starter/project_config.yml b/lib/tasks/project_components/rocket_launch_starter/project_config.yml index 5f0b9d7c..99ad8aba 100644 --- a/lib/tasks/project_components/rocket_launch_starter/project_config.yml +++ b/lib/tasks/project_components/rocket_launch_starter/project_config.yml @@ -6,3 +6,9 @@ COMPONENTS: location: "main.py" index: 0 default: true +IMAGES: + - "moon.png" + - "orange_planet.png" + - "planet.png" + - "purple_planet.png" + - "rocket.png" diff --git a/lib/tasks/project_components/rocket_launch_starter/purple_planet.png b/lib/tasks/project_components/rocket_launch_starter/purple_planet.png new file mode 100644 index 00000000..76bf52e6 Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_starter/purple_planet.png differ diff --git a/lib/tasks/project_components/rocket_launch_starter/rocket.png b/lib/tasks/project_components/rocket_launch_starter/rocket.png new file mode 100644 index 00000000..970fbecd Binary files /dev/null and b/lib/tasks/project_components/rocket_launch_starter/rocket.png differ diff --git a/lib/tasks/projects.rake b/lib/tasks/projects.rake index 3a5e7d33..1c8d61fb 100644 --- a/lib/tasks/projects.rake +++ b/lib/tasks/projects.rake @@ -7,8 +7,7 @@ namespace :projects do task create_starter: :environment do Dir.each_child("#{File.dirname(__FILE__)}/project_components") do |dir| proj_config = YAML.safe_load(File.read("#{File.dirname(__FILE__)}/project_components/#{dir}/project_config.yml")) - Project.find_by(identifier: proj_config['IDENTIFIER'])&.destroy - new_project = Project.new(identifier: proj_config['IDENTIFIER'], name: proj_config['NAME']) + project = find_project(proj_config) components = proj_config['COMPONENTS'] components.each do |component| name = component['name'] @@ -18,9 +17,29 @@ namespace :projects do default = component['default'] project_component = Component.new(name: name, extension: extension, content: code, index: index, default: default) - new_project.components << project_component + project.components << project_component end - new_project.save + + project_images = proj_config['IMAGES'] || [] + project_images.each do |image_name| + project.images.attach(io: File.open(File.dirname(__FILE__) + "/project_components/#{dir}/#{image_name}"), + filename: image_name) + end + + project.save end end end + +def find_project(proj_config) + if Project.find_by(identifier: proj_config['IDENTIFIER']).nil? + project = Project.new(identifier: proj_config['IDENTIFIER'], name: proj_config['NAME']) + else + project = Project.find_by(identifier: proj_config['IDENTIFIER']) + project.name = proj_config['NAME'] + project.components.each(&:destroy) + project.images.purge + end + + project +end