简体   繁体   中英

moving object in html/css/javascript detecting collision with other objects

I want to make a moving man in css/html/javascript, also detect collisions with other objects. Any idea how to do it? or any pointers to the same will do great.

The first try is look at rapahel js project it uses canvas, second it is a pretty hard thing to do as you want your own physics engine at 2 D level, but i guess with some math formulas you could do it, but everything that you need as an object should be scripted in js to be sure to get the collision effect.

Some design patterns should help you to make your code better.

Good luck.

Pretty much any basic game tutorial covers the topics you asked. If you can't find a javascript version of that, just get anything in a language you are familiar and try to code the same thing in javascript.

to draw things somewhat in the same way these tutorials probably do, use a div with "position:relative" and its children with "position:absolute" and use "top" and "left" css style proprieties to position the boxes/sprites/whatever.

I am pretty sure you can figure out what to do if you follow these tips.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM