Initializing
Liveweave
Web
expand_more
home
Home
data_object
CSS Explorer
arrow_outward
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
outbox_alt
Generative AI
arrow_outward
frame_source
Python Playground
New
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Save
account_circle
Login
settings
Settings
expand_more
14
px
Live mode
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script type="text/javascript" src="js/tetris.js"></script> <title>テトリス-コピー(2)</title> <style> #canvas{ background-color: #FFFFFF; border: 1px solid black; } </style> </head> <body onload = "draw()"> <canvas id="canvas" width="200" height="500" /> </body> </html>
.lw { font-size: 60px; }
/* Write JavaScript here */ var x = 0; var y = 0; //Zå—ブãƒãƒƒã‚¯ã®ä¸€ç²’一粒ã®åº§æ¨™ var w = 20; var h = 20; //ブãƒãƒƒã‚¯ä¸€ç²’ã®å¤§ãã• //draw(); setInterval("down()",500); function down(){ if(y < 460){ y = y + 20; draw(); } } function draw(){ var canvas = document.getElementById('canvas'); if (canvas.getContext){ var zType = canvas.getContext('2d'); zType.clearRect(0,0,200,500); zType.fillStyle = "#000000"; zType.fillRect(x,y, w, h); zType.fillRect(x + 20,y, w, h); zType.fillRect(x + 20,y + 20, w, h); zType.fillRect(x + 40,y + 20, w, h); // zType.clearRect(0,0,200,500); zType.strokeStyle = "#ffffff"; zType.strokeRect(x,y, w, h); zType.strokeRect(x + 20,y, w, h); zType.strokeRect(x + 20,y + 20, w, h); zType.strokeRect(x + 40,y + 20, w, h); //Zå— /* var iType = canvas.getContext('2d'); iType.clearRect(0,0,200,500); iType.fillStyle = "#000000"; iType.fillRect(x,y, w, h); iType.fillRect(x + 20,y, w, h); iType.fillRect(x + 40,y, w, h); iType.fillRect(x + 60,y, w, h); iType.strokeStyle = "#ffffff"; iType.strokeRect(x,y, w, h); iType.strokeRect(x + 20,y, w, h); iType.strokeRect(x + 40,y, w, h); iType.strokeRect(x + 60,y, w, h); //Iå— */ /* var iType = canvas.getContext('2d'); iType.fillRect(100, 100, 10, 10); iType.fillRect(100, 111, 10, 10); iType.fillRect(100, 122, 10, 10); iType.fillRect(100, 133, 10, 10); //Iå— */ } } document.onkeydown = cursor; function cursor(evt){ if(evt.which == 37 && x > 0 && y < 460){ //左を押ã—ãŸæ™‚ã®ãƒ–ãƒãƒƒã‚¯ã®å‹•ã x = x - 20; } if(evt.which == 39 && x < 140 && y < 460){ //å³ã‚’押ã—ãŸæ™‚ã®ãƒ–ãƒãƒƒã‚¯ã®å‹•ã x = x + 20; } if(evt.which == 40 && y < 460){ //下を押ã—ãŸæ™‚ã®ãƒ–ãƒãƒƒã‚¯ã®å‹•ã y = y + 20; } if(evt.which == 38 && y < 460){ //上を押ã—ãŸæ™‚ã®ãƒ–ãƒãƒƒã‚¯ã®å‹•ã var zType = canvas.getContext('2d'); zType.clearRect(0,0,200,500); zType.fillStyle = "#000000"; zType.fillRect(x,y, w, h); zType.fillRect(x + 20,y, w, h); zType.fillRect(x + 20,y + 20, w, h); zType.fillRect(x + 40,y + 20, w, h); // zType.clearRect(0,0,200,500); zType.strokeStyle = "#ffffff"; zType.strokeRect(x,y, w, h); zType.strokeRect(x + 20,y, w, h); zType.strokeRect(x + 20,y + 20, w, h); zType.strokeRect(x + 40,y + 20, w, h); zType.clearRect(0,0,200,500); zType.fillStyle = "#000000"; zType.fillRect(x + 20,y,w,h); zType.fillRect(x + 20,y + 20,w,h); zType.fillRect(x,y + 20,w,h); zType.fillRect(x,y + 40,w,h); zType.strokeStyle = "#ffffff"; zType.strokeRect(x + 20,y,w,h); zType.strokeRect(x + 20,y + 20,w,h); zType.strokeRect(x,y + 20,w,h); zType.strokeRect(x,y + 40,w,h); } draw(); }