2D Collision Game
Nov 17, 2023
v.0
A simple 2D game where cubes collide and interact with a wall, tracking the number of collisions. HTML5 canvas JavaScript 2D game Collision Cube

Versions  

Bugs  
None!

Get This App On Your Website

1. Copy the code above with the iframe and link.
2. Paste the code into your website.
3. Resize the iframe to fit your website.

Javascript, HTML, CSS Code

                javascript
function checkCollision(cube1, cube2) {
return cube1.x < cube2.x + cube2.width &&
cube1.x + cube1.width > cube2.x &&
cube1.y < cube2.y + cube2.height &&
cube1.y + cube1.height > cube2.y;
}

function resolveCollision(cube1, cube2) {
const velocityDiff = cube1.velocity - cube2.velocity;

// Calculate the new velocities after the collision
const newVelocity1 = (cube1.velocity * (cube1.mass - cube2.mass) + (2 * cube2.mass * cube2.velocity)) / (cube1.mass + cube2.mass);
const newVelocity2 = (cube2.velocity * (cube2.mass - cube1.mass) + (2 * cube1.mass * cube1.velocity)) / (cube1.mass + cube2.mass);

// Update the velocities of the cubes
cube1.velocity = newVelocity1;
cube2.velocity = newVelocity2;

collisions++;
updateCollisionInfo();
}

NEW APPS

These are apps made by the community!

FAQ

What is Calculator Tools?

Calculator Tools allows you to instantly create and generate any simple one page web app for free and immediately have it online to use and share. This means anything! Mini apps, calculators, trackers, tools, games, puzzles, screensavers... anything you can think of that the AI can handle.

The AI uses Javacript, HTML, and CSS programming to code your app up in moments. This currently uses GPT-4 the latest and most powerful version of the OpenAI GPT language model.

What Do You Mean Make An App?

Have you ever just wanted a simple app but didn't want to learn programming or pay someone to make it for you? Calculator Tools is the solution! Just type in your prompt and the AI will generate a simple app for you in seconds. You can then customize it to your liking and share it with your friends.

AI has become so powerful it is that simple these days.

Does This Use ChatGPT?

It uses GPT-4 which is the most powerful model for ChatGPT.

Calculator Tools does not remember things from prompt to prompt, each image is a unique image that does not reference any of the images or prompts previously supplied.