Embedded Codes For Games

Nov 4th, 2019
Never
Cheat codes for games

The width of the game window will auto-adjust to fit the available space on PC, tablet or smartphone. The games are made in HTML5 and will run in any web browser. No flash player needed. How to embed a game. Simply copy the embed code below and paste it where you want the game to appear on your page. Make sure to copy the complete code. Free games for your website, simply copy and paste the code of each game you want to add to your page. We did all of the work for you. Your source for fun, free games, services, freeware. Example code for shooting game

Not a member of Pastebin yet?Sign Up, it unlocks many cool features!
  1. <html>
  2. <title></title>
  3. html, body {
  4. margin: 0;
  5. body {
  6. display: flex;
  7. justify-content: center;
  8. canvas {
  9. }
  10. </head>
  11. <canvas width='400' height='400'></canvas>
  12. var canvas = document.getElementById('game');
  13. var grid = 16;
  14. x: 160,
  15. // snake velocity. moves one grid length every frame in either the x or y direction
  16. dy: 0,
  17. // keep track of all grids the snake body occupies
  18. // length of the snake. grows when eating an apple
  19. };
  20. x: 320,
  21. };
  22. // @see https://stackoverflow.com/a/1527820/2124254
  23. return Math.floor(Math.random() * (max - min)) + min;
  24. // game loop
  25. requestAnimationFrame(loop);
  26. // slow game loop to 15 fps instead of 60 (60/15 = 4)
  27. return;
  28. count = 0;
  29. context.clearRect(0,0,canvas.width,canvas.height);
  30. snake.x += snake.dx;
  31. // wrap snake position horizontally on edge of screen
  32. snake.x = canvas.width - grid;
  33. else if (snake.x >= canvas.width) {
  34. }
  35. // wrap snake position vertically on edge of screen
  36. snake.y = canvas.height - grid;
  37. else if (snake.y >= canvas.height) {
  38. }
  39. // keep track of where snake has been. front of the array is always the head
  40. // remove cells as we move away from them
  41. snake.cells.pop();
  42. // draw apple
  43. context.fillRect(apple.x, apple.y, grid-1, grid-1);
  44. context.fillStyle = 'green';
  45. // drawing 1 px smaller than the grid creates a grid effect in the snake body so you can see how long it is
  46. context.fillRect(cell.x, cell.y, grid-1, grid-1);
  47. if (cell.x apple.x && cell.y apple.y) {
  48. // canvas is 400x400 which is 25x25 grids
  49. apple.y = getRandomInt(0, 25) * grid;
  50. // check collision with all cells after this one (modified bubble sort)
  51. for (var i = index + 1; i < snake.cells.length; i++) {
  52. // snake occupies same space as a body part. reset game
  53. if (cell.x snake.cells[i].x && cell.y snake.cells[i].y) {
  54. snake.y = 160;
  55. snake.maxCells = 4;
  56. snake.dy = 0;
  57. apple.y = getRandomInt(0, 25) * grid;
  58. }
  59. }
  60. document.addEventListener('keydown', function(e) {
  61. // prevent snake from backtracking on itself by checking that it's
  62. // not already moving on the same axis (pressing left while moving
  63. // left won't do anything, and pressing right while moving left
  64. // shouldn't let you collide with your own body)
  65. // left arrow key
  66. snake.dx = -grid;
  67. }
  68. else if (e.which 38 && snake.dy 0) {
  69. snake.dx = 0;
  70. // right arrow key
  71. snake.dx = grid;
  72. }
  73. else if (e.which 40 && snake.dy 0) {
  74. snake.dx = 0;
  75. });
  76. requestAnimationFrame(loop);
  77. </body>
Embedded Codes For Games
RAW Paste Data

Embed Flash Games

Games With Embed Code