Drawaria Jump Game

New drawaria Jump Game!

  1. // ==UserScript==
  2. // @name Drawaria Jump Game
  3. // @namespace http://tampermonkey.net/
  4. // @version 2024-10-06
  5. // @description New drawaria Jump Game!
  6. // @author YouTube Drawaria
  7. // @match https://drawaria.online/game
  8. // @license MIT
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=drawaria.online
  10. // @grant none
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. // Remove the "Cannot GET /dinosaur" text
  15. document.body.innerHTML = "";
  16. // Change the tab title
  17. document.title = "Drawaria Jump Game";
  18. // Change the tab icon
  19. const link = document.createElement("link");
  20. link.rel = "icon";
  21. link.href = "/favicon-32x32.png";
  22. document.head.appendChild(link);
  23. // Add music when the game starts
  24. const audio = document.createElement('audio');
  25. audio.src = 'https://ia601307.us.archive.org/0/items/gdps-2.2-song-500476/500476.mp3';
  26. audio.loop = true;
  27. audio.autoplay = true;
  28. document.body.appendChild(audio);
  29. // Create the game area
  30. const gameArea = document.createElement('div');
  31. gameArea.id = 'gameArea';
  32. gameArea.style.position = 'relative';
  33. gameArea.style.width = '100vw';
  34. gameArea.style.height = '100vh';
  35. gameArea.style.overflow = 'hidden';
  36. document.body.appendChild(gameArea);
  37. // Style the game background with gray squares
  38. const shapesStyle = document.createElement('style');
  39. shapesStyle.innerHTML = `
  40. #gameArea {
  41. background: linear-gradient(#87ceeb, #f7f7f7);
  42. overflow: hidden;
  43. }
  44. .background-square {
  45. position: absolute;
  46. width: 80px; /* Square size */
  47. height: 80px; /* Square size */
  48. background: rgba(128, 128, 128, 0.5); /* Gray color */
  49. }
  50. @keyframes moveShapes {
  51. 0% {
  52. transform: translateY(0);
  53. }
  54. 100% {
  55. transform: translateY(100vh);
  56. }
  57. }
  58. `;
  59. document.head.appendChild(shapesStyle);
  60. // Create the background with gray squares
  61. for (let i = 0; i < 50; i++) {
  62. const square = document.createElement('div');
  63. square.classList.add('background-square');
  64. square.style.left = Math.random() * 100 + 'vw';
  65. square.style.top = Math.random() * 100 + 'vh';
  66. gameArea.appendChild(square);
  67. }
  68. // Create the ground
  69. const ground = document.createElement('div');
  70. ground.id = 'ground';
  71. ground.style.position = 'absolute';
  72. ground.style.bottom = '0';
  73. ground.style.width = '100%';
  74. ground.style.height = '50px';
  75. ground.style.background = '#e0c568';
  76. ground.style.borderTop = '5px solid #a67c00';
  77. gameArea.appendChild(ground);
  78. // Create the dinosaur
  79. const dinosaur = document.createElement('div');
  80. dinosaur.style.position = 'absolute';
  81. dinosaur.style.bottom = '50px';
  82. dinosaur.style.left = '50px';
  83. dinosaur.style.width = '40px';
  84. dinosaur.style.height = '40px';
  85. dinosaur.style.backgroundColor = '#808080'; // Dark gray color
  86. dinosaur.style.transition = 'bottom 0.1s';
  87. gameArea.appendChild(dinosaur);
  88. // Create the game title and logo
  89. const titleDisplay = document.createElement('h1');
  90. titleDisplay.innerText = 'Drawaria Jump Game';
  91. titleDisplay.style.position = 'absolute';
  92. titleDisplay.style.top = '120px'; // Position title below logo
  93. titleDisplay.style.left = '50%';
  94. titleDisplay.style.transform = 'translateX(-50%)';
  95. titleDisplay.style.color = '#000'; // Text color
  96. gameArea.appendChild(titleDisplay);
  97. // Create score, time, and creator displays
  98. let score = 0;
  99. const scoreDisplay = document.createElement('div');
  100. scoreDisplay.style.position = 'absolute';
  101. scoreDisplay.style.top = '10px';
  102. scoreDisplay.style.left = '10px';
  103. scoreDisplay.style.fontSize = '20px';
  104. gameArea.appendChild(scoreDisplay);
  105. const timeDisplay = document.createElement('div');
  106. timeDisplay.style.position = 'absolute';
  107. timeDisplay.style.top = '40px';
  108. timeDisplay.style.left = '10px';
  109. timeDisplay.style.fontSize = '20px';
  110. gameArea.appendChild(timeDisplay);
  111. const creatorDisplay = document.createElement('div');
  112. creatorDisplay.style.position = 'absolute';
  113. creatorDisplay.style.top = '70px';
  114. creatorDisplay.style.left = '10px';
  115. creatorDisplay.style.fontSize = '20px';
  116. creatorDisplay.innerText = 'Creator: YouTube Drawaria';
  117. gameArea.appendChild(creatorDisplay);
  118. // Update score and time
  119. setInterval(() => {
  120. scoreDisplay.innerText = `Score: ${score}`;
  121. const now = new Date();
  122. timeDisplay.innerText = `Time: ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`;
  123. }, 1000);
  124. // Create obstacles container
  125. const obstacles = document.createElement('div');
  126. obstacles.style.position = 'absolute';
  127. obstacles.style.width = '100%';
  128. obstacles.style.height = '100%';
  129. gameArea.appendChild(obstacles);
  130. // Create points container
  131. const pointItems = document.createElement('div');
  132. pointItems.style.position = 'absolute';
  133. pointItems.style.width = '100%';
  134. pointItems.style.height = '100%';
  135. pointItems.style.zIndex = '2';
  136. gameArea.appendChild(pointItems);
  137. // Create power-ups container
  138. const powerUps = document.createElement('div');
  139. powerUps.style.position = 'absolute';
  140. powerUps.style.width = '100%';
  141. powerUps.style.height = '100%';
  142. powerUps.style.zIndex = '2';
  143. gameArea.appendChild(powerUps);
  144. // Move the dinosaur
  145. let dinosaurPosition = 50;
  146. let isJumping = false;
  147. document.addEventListener('keydown', (event) => {
  148. if (event.code === 'Space' || event.code === 'ArrowUp') {
  149. if (!isJumping) {
  150. isJumping = true;
  151. dinosaur.style.bottom = '200px';
  152. setTimeout(() => {
  153. dinosaur.style.bottom = '50px';
  154. isJumping = false;
  155. }, 800);
  156. }
  157. }
  158. if (event.code === 'ArrowRight') {
  159. dinosaurPosition += 10;
  160. dinosaur.style.left = dinosaurPosition + 'px';
  161. }
  162. if (event.code === 'ArrowLeft') {
  163. dinosaurPosition -= 10;
  164. dinosaur.style.left = dinosaurPosition + 'px';
  165. }
  166. });
  167. // Create obstacles
  168. const createObstacle = () => {
  169. const obstacle = document.createElement('div');
  170. obstacle.style.position = 'absolute';
  171. obstacle.style.width = '30px';
  172. obstacle.style.height = '60px';
  173. obstacle.style.backgroundColor = 'red';
  174. obstacle.style.bottom = '50px';
  175. obstacle.style.left = '100%';
  176. obstacles.appendChild(obstacle);
  177. let obstacleInterval = setInterval(() => {
  178. const obstaclePosition = parseInt(window.getComputedStyle(obstacle).getPropertyValue('left'));
  179. if (obstaclePosition < -60) {
  180. obstacle.remove();
  181. clearInterval(obstacleInterval);
  182. } else {
  183. obstacle.style.left = (obstaclePosition - 5) + 'px';
  184. }
  185. checkCollisionWithObstacle(obstacle);
  186. }, 30);
  187. };
  188. // Create points
  189. const createPoint = () => {
  190. const point = document.createElement('div');
  191. point.style.position = 'absolute';
  192. point.style.width = '20px';
  193. point.style.height = '20px';
  194. point.style.backgroundColor = 'yellow';
  195. point.style.borderRadius = '50%';
  196. point.style.bottom = '200px'; // Match max dinosaur jump height
  197. point.style.left = '100%';
  198. pointItems.appendChild(point);
  199. let pointInterval = setInterval(() => {
  200. const pointPosition = parseInt(window.getComputedStyle(point).getPropertyValue('left'));
  201. if (pointPosition < -20) {
  202. point.remove();
  203. clearInterval(pointInterval);
  204. } else {
  205. point.style.left = (pointPosition - 5) + 'px';
  206. }
  207. checkCollisionWithPoint(point);
  208. }, 30);
  209. };
  210. // Create power-up
  211. const createPowerUp = () => {
  212. const powerUp = document.createElement('div');
  213. powerUp.style.position = 'absolute';
  214. powerUp.style.width = '20px';
  215. powerUp.style.height = '20px';
  216. powerUp.style.backgroundColor = 'blue';
  217. powerUp.style.borderRadius = '50%';
  218. powerUp.style.bottom = '100px'; // Match dinosaur jump height
  219. powerUp.style.left = '100%';
  220. powerUps.appendChild(powerUp);
  221. let powerUpInterval = setInterval(() => {
  222. const powerUpPosition = parseInt(window.getComputedStyle(powerUp).getPropertyValue('left'));
  223. if (powerUpPosition < -20) {
  224. powerUp.remove();
  225. clearInterval(powerUpInterval);
  226. } else {
  227. powerUp.style.left = (powerUpPosition - 5) + 'px';
  228. }
  229. checkCollisionWithPowerUp(powerUp);
  230. }, 30);
  231. };
  232. // Check collision with obstacles
  233. const checkCollisionWithObstacle = (obstacle) => {
  234. const dinoRect = dinosaur.getBoundingClientRect();
  235. const obsRect = obstacle.getBoundingClientRect();
  236. if (
  237. dinoRect.left < obsRect.right &&
  238. dinoRect.right > obsRect.left &&
  239. dinoRect.bottom > obsRect.top &&
  240. dinoRect.top < obsRect.bottom
  241. ) {
  242. alert('You hit an obstacle! Your final score is: ' + score);
  243. location.reload();
  244. }
  245. };
  246. // Check collision with points
  247. const checkCollisionWithPoint = (point) => {
  248. const dinoRect = dinosaur.getBoundingClientRect();
  249. const pointRect = point.getBoundingClientRect();
  250. if (
  251. dinoRect.left < pointRect.right &&
  252. dinoRect.right > pointRect.left &&
  253. dinoRect.bottom > pointRect.top &&
  254. dinoRect.top < pointRect.bottom
  255. ) {
  256. score += 10;
  257. point.remove();
  258. }
  259. };
  260. // Check collision with power-ups
  261. const checkCollisionWithPowerUp = (powerUp) => {
  262. const dinoRect = dinosaur.getBoundingClientRect();
  263. const powerUpRect = powerUp.getBoundingClientRect();
  264. if (
  265. dinoRect.left < powerUpRect.right &&
  266. dinoRect.right > powerUpRect.left &&
  267. dinoRect.bottom > powerUpRect.top &&
  268. dinoRect.top < powerUpRect.bottom
  269. ) {
  270. score += 20; // Increase score for collecting power-up
  271. powerUp.remove();
  272. }
  273. };
  274. // Create obstacles, points, and power-ups periodically
  275. setInterval(createObstacle, 1500);
  276. setInterval(createPoint, 2000);
  277. setInterval(createPowerUp, 5000);
  278. // Display the score every second
  279. setInterval(() => {
  280. scoreDisplay.innerText = `Score: ${score}`;
  281. }, 1000);
  282. })();