Notes
![]() ![]() Notes - notes.io |
adding it to an objects current position gives you the new position
to find a objects current position you use object.y/x + object.height/width these finds sides (up,down,left,right) depending on what you put in
basically saying: objects position + how far an object will move = new position
when a object is moving it doesnt have a current position only a updating new position
when an object isnt moving it doesnt have a new position because only moving objects dont have current positions, they are constantly moving and dont have time to have a current position. also meaning an object that isnt moving cannot have a new position, saying that is basically saying a moving object isnt moving and a object that isnt moving is moving.(in canvas terms)
acceleration is a force that causes velocity to increase over time. gravity is a natural force that does this.
this is a basic gist of what velocity is and does when added to the current position
the equation were thinking of is
if(object.y + object.height + object.velocityY <= canvas.height){
object.velocityY += gravity;
}else object.velocityY = 0
lets break it down:
if the (objects new position less than or equal to the bottom of the canvas){
object will be affected by gravity
}
else if the object position is greater than the bottom of the canvas than the object will no longer be affected by gravity.
the only thing i found confusing was the fact that i had to calculate if the object was touching the canvas with the new position?
shouldnt i have done it with the current position?
well it has to do with the fact that an object in motion always has a new postion and no current position.
if you were to only put: object.y + object.height
the response would be invalid because a moving object doesnt have a new position and because it has an invalid return the object would just fall through the canvas because it is only calculating the current position (which it doesnt have) and because it doesnt have one since its moving it cant calculate anything so it just falls through.
but with: object.y + object.height + object.velocityY
the response WOULD be valid because it calculates the new position which in a moving object is basically its position? but what makes it valid?
an object in movement only has a new position, no current position. think of frames like a ladder, every time you touch a rung thats your new position, but everytime you begin moving that rung becomes your currentish position but the second you touch the next rung imagine velocity being added and that rung becomes your new position. its confusing but thats basically what it is.
basically it gives a valid position to the equation and its able to calculate it. that it. whenever your detecting moveent, you should always add the velocity.
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team