Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tutorial-conway-life-t5
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COSC360 in 2018
tutorial-conway-life-t5
Commits
bd7298b6
Commit
bd7298b6
authored
6 years ago
by
Will Billingsley
Browse files
Options
Downloads
Plain Diff
Merge branch 'solution'
parents
61211b52
29fae6cf
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
index.html
+9
-6
9 additions, 6 deletions
index.html
render.js
+13
-5
13 additions, 5 deletions
render.js
style.css
+16
-0
16 additions, 0 deletions
style.css
style.css.map
+1
-0
1 addition, 0 deletions
style.css.map
style.scss
+21
-0
21 additions, 0 deletions
style.scss
with
60 additions
and
11 deletions
index.html
+
9
−
6
View file @
bd7298b6
<!DOCTYPE html>
<html>
<title>
Conway's Game of Life
</title>
<link
rel=
"stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.2/css/bootstrap.min.css"
integrity=
"sha384-Smlep5jCw/wG7hdkwQ/Z5nLIefveQRIY9nfy6xoR1uRYBtpZgI6339F5dgvm/e9B"
crossorigin=
"anonymous"
>
<div
class=
"container"
>
<h1>
Conway's Game of Life
</h1>
<div
id=
"game"
style=
"font-family: monospace; cursor: pointer;"
>
</div>
<svg
xmlns=
"http://www.w3.org/2000/svg"
id=
"game"
width=
"640"
height=
"400"
></svg>
<div>
<button
onclick=
"javascript: { gameOfLife.stepGame(); render(); }"
>
Step
</button>
<button
class=
"btn btn-primary"
onclick=
"javascript: { gameOfLife.stepGame(); render(); }"
>
Step
</button>
</div>
</div>
<script
src=
"gameOfLife.js"
></script>
<script
src=
"render.js"
></script>
...
...
@@ -17,4 +18,6 @@
render
()
</script>
<link
rel=
"stylesheet"
href=
"style.css"
/>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
render.js
+
13
−
5
View file @
bd7298b6
...
...
@@ -2,21 +2,29 @@
function
render
()
{
let
xmlns
=
"
http://www.w3.org/2000/svg
"
let
cellSize
=
20
let
gameDiv
=
document
.
getElementById
(
"
game
"
)
gameDiv
.
innerHTML
=
""
for
(
let
y
=
0
;
y
<
gameOfLife
.
getH
();
y
++
)
{
let
row
=
document
.
createElement
(
"
div
"
)
let
row
=
document
.
createElement
NS
(
xmlns
,
"
g
"
)
row
.
setAttribute
(
"
class
"
,
"
gamerow
"
)
gameDiv
.
appendChild
(
row
)
for
(
let
x
=
0
;
x
<
gameOfLife
.
getW
();
x
++
)
{
let
t
=
document
.
createElement
(
"
span
"
)
let
t
=
document
.
createElementNS
(
xmlns
,
"
rect
"
)
t
.
setAttribute
(
"
x
"
,
x
*
cellSize
)
t
.
setAttribute
(
"
y
"
,
y
*
cellSize
)
t
.
setAttribute
(
"
width
"
,
cellSize
)
t
.
setAttribute
(
"
height
"
,
cellSize
)
t
.
classList
.
add
(
"
cell
"
)
if
(
gameOfLife
.
isAlive
(
x
,
y
))
{
t
.
innerHTML
=
"
#
"
}
else
{
t
.
innerHTML
=
"
.
"
t
.
classList
.
add
(
"
alive
"
)
}
let
handler
=
function
(
evt
)
{
...
...
This diff is collapsed.
Click to expand it.
style.css
0 → 100644
+
16
−
0
View file @
bd7298b6
.cell
{
fill
:
#ddd
;
stroke
:
#444
;
cursor
:
pointer
;
}
.cell
:hover
{
fill
:
#c4c4c4
;
}
.cell.alive
{
fill
:
#88f
;
}
.cell.alive
:hover
{
fill
:
#5555ff
;
}
/*# sourceMappingURL=style.css.map */
This diff is collapsed.
Click to expand it.
style.css.map
0 → 100644
+
1
−
0
View file @
bd7298b6
{"version":3,"sourceRoot":"","sources":["style.scss"],"names":[],"mappings":"AAIA;EACE,MAJY;EAKZ,QAJa;EAKb;;AAEA;EACE;;AAGF;EACE,MAdY;;AAgBd;EACE","file":"style.css"}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
style.scss
0 → 100644
+
21
−
0
View file @
bd7298b6
$primary-color
:
#88f
;
$empty-color
:
#ddd
;
$border-color
:
#444
;
.cell
{
fill
:
$empty-color
;
stroke
:
$border-color
;
cursor
:
pointer
;
&
:hover
{
fill
:
darken
(
$empty-color
,
10%
);
}
&
.alive
{
fill
:
$primary-color
;
}
&
.alive
:hover
{
fill
:
darken
(
$primary-color
,
10%
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment