This is a web-based capsule machine, where users can shake the machine, see what is inside of the machine, turn the handle, and collect capsules containing toys.
I used AI to help me debug and in the readme
This is a web-based capsule machine, where users can shake the machine, see what is inside of the machine, turn the handle, and collect capsules containing toys.
I used AI to help me debug and in the readme
I built a web-based capsule machine that contains random toys in capsules. I learned how to use physics such as gravity, velocity and friction, used collision between objects and used animation for motion.
And I figured out my nothing was showing turns out I need to link the JS and CSS.
So I made a video but it is not showing cause I guess it’s too big of a file so here are the images of the before and after.
Log in to leave a comment
### CSS
P.S. There are a lot of errors in my code right now, so nothing is showing up properly at the moment and sorry for showing the same image
Log in to leave a comment
- Turned into an array of objects
- Each capsule stored such as (DOM elements, position, rotation, radius, velocity, acceleration, bounce and linked toy elements)
- Assigned each capsule a random starting position inside the machine
- Set the initial movement direction up
### <u>Movement</u>
- Each capsule moves using velocity and acceleration
- Velocity increases over time based on the acceleration
- Friction slowly reduces movement
- Helper function adds force to velocity
### <u>Helper function</u>
- Created functions to move objects smoothly and prevent overlap
- Returns a correct position
- Used for collision separation
### <u>Shake Effect</u>
- Random velocity direction for all capsules
- Reset movement
- Add shake class to the machine
- Remove shake class
### <u>Animation</u>
- Controls open and close machine flap
Also I don't have a new picture of my results
Log in to leave a comment
Log in to leave a comment