Tetris Game


SUBMITTED BY: Lama9999

DATE: Feb. 24, 2024, 10:52 a.m.

FORMAT: HTML

SIZE: 1.4 kB

HITS: 821

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Basic Tetris HTML Game</title>
  5. <meta charset="UTF-8">
  6. <style>
  7. html, body {
  8. height: 100%;
  9. margin: 0;
  10. }
  11. body {
  12. background: black;
  13. display: flex;
  14. align-items: center;
  15. justify-content: center;
  16. }
  17. canvas {
  18. border: 1px solid white;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <canvas width="320" height="640" id="game"></canvas>
  24. <script>
  25. // Funktion zum Generieren einer zufälligen Ganzzahl im Bereich [min, max]
  26. function getRandomInt(min, max) {
  27. min = Math.ceil(min);
  28. max = Math.floor(max);
  29. return Math.floor(Math.random() * (max - min + 1)) + min;
  30. }
  31. // Generiere eine neue Tetromino-Sequenz
  32. const tetrominoSequence = [];
  33. function generateSequence() {
  34. const sequence = ['I', 'J', 'L', 'O', 'S', 'T', 'Z'];
  35. while (sequence.length) {
  36. const rand = getRandomInt(0, sequence.length - 1);
  37. const name = sequence.splice(rand, 1)[0];
  38. tetrominoSequence.push(name);
  39. }
  40. }
  41. // Weitere Funktionen und Spiellogik hier einfügen
  42. // Starte das Spiel
  43. generateSequence();
  44. // ...
  45. </script>
  46. </body>
  47. </html>

comments powered by Disqus