したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | メール | |
レス数が1スレッドの最大レス数(1000件)を超えています。残念ながら投稿することができません。

コテと名無しの2025初夏から夏 雑談もチラ裏も 3

479オセロ(1):2025/06/08(日) 07:04:03 ID:wLrf/Ggs
>>473
ChatGPTに書かせた以下のコードを .html ファイルとして保存してブラウザで開くと、実際に遊ぶことができますね
それとも、最新の品薄転売状態のスイッチ2の状況に対する皮肉的(?)なコメントなんでしょうか(*ノω・*)テヘ?

(1)――――――――――――――――――――――――――――――――
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>オセロゲーム</title>
<style>
body { font-family: sans-serif; text-align: center; }
table { border-collapse: collapse; margin: 20px auto; }
td {
width: 50px; height: 50px;
border: 1px solid #000;
background-color: green;
cursor: pointer;
position: relative;
}
.piece {
width: 40px; height: 40px;
border-radius: 50%;
position: absolute;
top: 5px; left: 5px;
}
.black { background-color: black; }
.white { background-color: white; }
</style>
</head>
<body>
<h1>オセロゲーム</h1>
<table id="board"></table>
<p id="turn">黒の番です</p>

<script>
const SIZE = 8;
const board = [];
const table = document.getElementById('board');
const turnText = document.getElementById('turn');
let currentPlayer = 'black';

function createBoard() {
for (let y = 0; y < SIZE; y++) {
board[y] = [];
const row = table.insertRow();
for (let x = 0; x < SIZE; x++) {
const cell = row.insertCell();
cell.dataset.x = x;
cell.dataset.y = y;
cell.addEventListener('click', handleClick);
board[y][x] = '';
}
}
setPiece(3, 3, 'white');
setPiece(4, 4, 'white');
setPiece(3, 4, 'black');
setPiece(4, 3, 'black');
}

function setPiece(x, y, color) {
board[y][x] = color;
const cell = table.rows[y].cells[x];
cell.innerHTML = `<div class="piece ${color}"></div>`;
}
(1)――――――――――――――――――――――――――――――――




掲示板管理者へ連絡 無料レンタル掲示板