From 93191197e6ac56d9f90cf66ca7f991ae9a4c581f Mon Sep 17 00:00:00 2001 From: lplopez-wpi <56080197+lplopez-wpi@users.noreply.github.com> Date: Mon, 4 Oct 2021 11:36:09 -0400 Subject: [PATCH 1/4] Create index.html snake snake --- index.html | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 00000000..976044e5 --- /dev/null +++ b/index.html @@ -0,0 +1,197 @@ + + + + Cheaters in Tarkov time to Snake Up + + + + +
0
+ + + + + + + From 8571a7fd6e829e7524ba75bcb5296ec2ceb137d2 Mon Sep 17 00:00:00 2001 From: lplopez-wpi <56080197+lplopez-wpi@users.noreply.github.com> Date: Mon, 4 Oct 2021 11:36:25 -0400 Subject: [PATCH 2/4] Create server.js --- server.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 server.js diff --git a/server.js b/server.js new file mode 100644 index 00000000..02c2ffb4 --- /dev/null +++ b/server.js @@ -0,0 +1,9 @@ +const express = require('express') +const path = require("path"); +const app = express() +const port = 3000 +app.use(express.static('public')) +app.get('/', function (req, res) { + res.sendFile('public/index.html') +}) +app.listen(port) From faa8da8c1c73127ec6c201cc88ba70f0e0128b13 Mon Sep 17 00:00:00 2001 From: lplopez-wpi <56080197+lplopez-wpi@users.noreply.github.com> Date: Mon, 4 Oct 2021 11:42:36 -0400 Subject: [PATCH 3/4] Update README.md --- README.md | 62 ++++++------------------------------------------------- 1 file changed, 6 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 3ae10a92..959c5631 100644 --- a/README.md +++ b/README.md @@ -1,61 +1,11 @@ Assignment 4 - Creative Coding: Interactive Multimedia Experiences -=== +## Cheaters in Tarkov time to Snake Up -Due: October 4th, by 11:59 AM. - -For this assignment we will focus on client-side development using popular audio/graphics/visualization technologies. The goal of this assignment is to refine our JavaScript knowledge while exploring the multimedia capabilities of the browser. - -[WebAudio / Canvas / Three Tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/webaudio_canvas_three.md) -[SVG + D3 tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/using_svg_and_d3.md) - -Baseline Requirements ---- - -Your application is required to implement the following functionalities: - -- A server created using Express. This server can be as simple as needed. -- A client-side interactive experience using at least one of the following web technologies frameworks. - - [Three.js](https://threejs.org/): A library for 3D graphics / VR experiences - - [D3.js](https://d3js.org): A library that is primarily used for interactive data visualizations - - [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D raster drawing API included in all modern browsers - - [SVG](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D vector drawing framework that enables shapes to be defined via XML. - - [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API): An API for audio synthesis, analysis, processing, and file playback. -- A user interface for interaction with your project, which must expose at least four parameters for user control. [tweakpane](https://cocopon.github.io/tweakpane/) is highly recommended for this, but you can also use regular HTML `` tags (the `range` type is useful to create sliders). You might also explore interaction by tracking mouse movement via the `window.onmousemove` event handler in tandem with the `event.clientX` and `event.clientY` properties. Consider using the [Pointer Events API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events) to ensure that that both mouse and touch events will both be supported in your app. -- Your application should display basic documentation for the user interface when the application first loads. - -The interactive experience should possess a reasonable level of complexity. Some examples: -### Three.js -- A generative algorithm creates simple agents that move through a virtual world. Your interface controls the behavior / appearance of these agents. -- A simple 3D game... you really want this to be a simple as possible or it will be outside the scope of this assignment. -- An 3D audio visualization of a song of your choosing. User interaction should control aspects of the visualization. -### Canvas -- Implement a generative algorithm such as [Conway's Game of Life](https://bitstorm.org/gameoflife/) (or 1D cellular automata) and provide interactive controls. Note that the Game of Life has been created by 100s of people using ; we'll be checking to ensure that your implementation is not a copy of these. -- Design a 2D audio visualizer of a song of your choosing. User interaction should control visual aspects of the experience. -### Web Audio API -- Create a screen-based musical instrument using the Web Audio API. You can use projects such as [Interface.js](http://charlie-roberts.com/interface/) or [Nexus UI](https://nexus-js.github.io/ui/api/#Piano) to provide common musical interface elements, or use dat.GUI in combination with mouse/touch events (use the Pointer Events API). Your GUI should enable users to control aspects of sound synthesis. If you want to use higher-level instruments instead of the raw WebAudio API sounds, consider trying the instruments provided by [Tone.js]() or [Gibber](https://github.com/charlieroberts/gibber.audio.lib). -### D3.js -- Create visualizations using the datasets found at [Awesome JSON Datasets](https://github.com/jdorfman/Awesome-JSON-Datasets). Experiment with providing different visualizations of the same data set, and providing users interactive control over visualization parameters and/or data filtering. Alternatively, create a single visualization with using one of the more complicated techniques shown at [d3js.org](d3js.org) and provide meaningful points of interaction for users. - -Deliverables ---- - -Do the following to complete this assignment: - -1. Implement your project with the above requirements. -3. Test your project to make sure that when someone goes to your main page on Glitch/Heroku/etc., it displays correctly. -4. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it. -5. Fork this repository and modify the README to the specifications below. *NOTE: If you don't use Glitch for hosting (where we can see the files) then you must include all project files that you author in your repo for this assignment*. -6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`. - -Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions) ---- - -## Your Web Application Title - -your hosting link e.g. http://a4-charlieroberts.glitch.me +your hosting link e.g. https://a4-lplopez-wpi.glitch.me/ Include a very brief summary of your project here. Images are encouraged when needed, along with concise, high-level text. Be sure to include: -- the goal of the application -- challenges you faced in realizing the application -- the instructions you present in the website should be clear enough to use the application, but if you feel any need to provide additional instructions please do so here. +The goal of the application was to create snake. One of the streamers I watch on Twitch will play this onstream when they are loading into a match to spice things up. Sometimes its scribble.io or snake.io. I wanted to create the original snake game. +In the game of Snake, the player uses the arrow keys to move the snake around on screen. As the snake eats the food that appears on the board it will progressively get larger. The game ends when the snake hits the edge of the board or hits itself. At this time please refresh the page to start a new game! Thanks for playing! + +Remember, ARROW KEYS! NOT WASD! From 35690aee98cbca99c967dfdadf513bda7e9cd4ca Mon Sep 17 00:00:00 2001 From: lplopez-wpi <56080197+lplopez-wpi@users.noreply.github.com> Date: Mon, 4 Oct 2021 11:53:19 -0400 Subject: [PATCH 4/4] Update index.html --- index.html | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/index.html b/index.html index 976044e5..7a15bb45 100644 --- a/index.html +++ b/index.html @@ -38,28 +38,21 @@ ] let score = 0; - // True if changing direction let changing_direction = false; - // Horizontal velocity let food_x; let food_y; let dx = 10; - // Vertical velocity let dy = 0; - // Get the canvas element const snakeboard = document.getElementById("snakeboard"); - // Return a two dimensional drawing context const snakeboard_ctx = snakeboard.getContext("2d"); - // Start game main(); gen_food(); document.addEventListener("keydown", change_direction); - // main function called repeatedly to keep the game running function main() { if (has_game_ended()) return; @@ -75,21 +68,14 @@ }, 100) } - // draw a border around the canvas function clear_board() { - // Select the colour to fill the drawing snakeboard_ctx.fillStyle = board_background; - // Select the colour for the border of the canvas snakeboard_ctx.strokestyle = board_border; - // Draw a "filled" rectangle to cover the entire canvas snakeboard_ctx.fillRect(0, 0, snakeboard.width, snakeboard.height); - // Draw a "border" around the entire canvas snakeboard_ctx.strokeRect(0, 0, snakeboard.width, snakeboard.height); } - // Draw the snake on the canvas function drawSnake() { - // Draw each part snake.forEach(drawSnakePart) } @@ -100,17 +86,11 @@ snakeboard_ctx.strokeRect(food_x, food_y, 10, 10); } - // Draw one snake part function drawSnakePart(snakePart) { - // Set the colour of the snake part snakeboard_ctx.fillStyle = snake_col; - // Set the border colour of the snake part snakeboard_ctx.strokestyle = snake_border; - // Draw a "filled" rectangle to represent the snake part at the coordinates - // the part is located snakeboard_ctx.fillRect(snakePart.x, snakePart.y, 10, 10); - // Draw a border around the snake part snakeboard_ctx.strokeRect(snakePart.x, snakePart.y, 10, 10); } @@ -130,11 +110,8 @@ } function gen_food() { - // Generate a random number the food x-coordinate food_x = random_food(0, snakeboard.width - 10); - // Generate a random number for the food y-coordinate food_y = random_food(0, snakeboard.height - 10); - // if the new food location is where the snake currently is, generate a new food location snake.forEach(function has_snake_eaten_food(part) { const has_eaten = part.x == food_x && part.y == food_y; if (has_eaten) gen_food(); @@ -147,7 +124,6 @@ const UP_KEY = 38; const DOWN_KEY = 40; - // Prevent the snake from reversing if (changing_direction) return; changing_direction = true; @@ -175,20 +151,14 @@ } function move_snake() { - // Create the new Snake's head const head = {x: snake[0].x + dx, y: snake[0].y + dy}; - // Add the new head to the beginning of snake body snake.unshift(head); const has_eaten_food = snake[0].x === food_x && snake[0].y === food_y; if (has_eaten_food) { - // Increase score score += 10; - // Display score on screen document.getElementById('score').innerHTML = score; - // Generate new food location gen_food(); } else { - // Remove the last part of snake body snake.pop(); } }