Skip to content

Commit d9df35b

Browse files
iHiDdem4ron
andauthored
L16 exercises (exercism#7888)
* Add take control * Add hot zones * Add controlled snake * Improve tasks * Fix stubs * Add tic-tac-toe * Add tic-tac-toe * Use vmin for font --------- Co-authored-by: dem4ron <[email protected]>
1 parent 81fc3c2 commit d9df35b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+860
-24
lines changed

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*.rb
22
*.haml
33
stub.html
4-
stub.js
4+
stub.js
5+
stub.css

app/commands/bootcamp/solution/generate_stub.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ def call
77
exercise.stub(language).gsub(Regexp.new("{{EXERCISE:([-a-z0-9]+)/([-a-z0-9]+)}}")) do
88
project_slug = ::Regexp.last_match(1)
99
exercise_slug = ::Regexp.last_match(2)
10-
user.bootcamp_solutions.joins(exercise: :project).
10+
sol = user.bootcamp_solutions.joins(exercise: :project).
1111
where('bootcamp_exercises.slug = ? AND bootcamp_projects.slug = ?', exercise_slug, project_slug).
12-
first&.code || ""
12+
first
13+
14+
if sol
15+
if language == "jikiscript"
16+
sol.code
17+
else
18+
JSON.parse(sol.code)[language]
19+
end
20+
else
21+
""
22+
end
1323
end
1424
end
1525
end

app/helpers/react_components/bootcamp/frontend_exercise_page.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ def data
3333
css: exercise&.default("css")
3434
},
3535
stub: {
36-
css: exercise.stub("css"),
37-
html: exercise.stub("html"),
38-
js: exercise.stub("js")
36+
css: ::Bootcamp::Solution::GenerateStub.(exercise, current_user, "css"),
37+
html: ::Bootcamp::Solution::GenerateStub.(exercise, current_user, "html"),
38+
js: ::Bootcamp::Solution::GenerateStub.(exercise, current_user, "js")
3939
},
4040
aspect_ratio: editor_config[:aspect_ratio] || 1,
4141
code: solution&.code,

bootcamp_content/levels/16.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Level 16
2+
3+
Welcome to Level 16. This is a really exciting level as you finally start to get to interact with the games that you're making.
4+
5+
Your exercises this week build on what you made last week, but also add a new project as well!
6+
7+
Good luck!

bootcamp_content/levels/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,9 @@
5858
{
5959
"title": "CSS Absolute Positioning & JS Game mechanics",
6060
"description": "We learn about absolute positioning in CSS and some JS game mecahnics."
61+
},
62+
{
63+
"title": "JavaScript Interactions",
64+
"description": "Learn how to manage mouse and keyboard events in JavaScript."
6165
}
6266
]

bootcamp_content/projects/breakout/config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"paddle",
99
"break-out-those-classes",
1010
"breakout-css",
11-
"bouncy-ball"
11+
"bouncy-ball",
12+
"take-control",
13+
"hot-zones"
1214
]
1315
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"title": "Hot Zones",
3+
"description": "Add some rules to the paddle interactions.",
4+
"level": 16,
5+
"idx": 5,
6+
"language": "frontend"
7+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
body {
2+
background: #fdfaf6;
3+
font-family: sans-serif;
4+
padding: 0;
5+
margin: 0;
6+
overflow: auto;
7+
8+
height: 100%;
9+
margin: 0;
10+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
body {
2+
background: white;
3+
}
4+
#game {
5+
width: 80vmin;
6+
height: 80vmin;
7+
margin: 10vmin auto;
8+
background: rgb(10, 18, 21);
9+
position: relative;
10+
}
11+
#ball {
12+
border-radius: 100%;
13+
width: 4%;
14+
height: 4%;
15+
position: absolute;
16+
left: 50%;
17+
top: 94%;
18+
transform: translateX(-50%) translateY(-50%);
19+
background: white;
20+
}
21+
22+
#paddle {
23+
width: 20%;
24+
background: white;
25+
height: 3%;
26+
border-radius: 10px;
27+
position: absolute;
28+
left: 50%;
29+
top: 96%;
30+
transform: translateX(-50%);
31+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<main id="game">
2+
<div id="ball"></div>
3+
<div id="paddle"></div>
4+
</main>

0 commit comments

Comments
 (0)