enox10mx
New Member
- Messages
- 29
- Reaction score
- 0
- Points
- 0
Hello.
I am making a game with javascript, and need to know how to make two images touch each other.
Each image is inside a div with an ID of:
or
.
Here is the page's code:
Ignore the "shortcut.add" and the excessive BR's, but that's my page.
May somebody help me do collision checking.
I am making a game with javascript, and need to know how to make two images touch each other.
Each image is inside a div with an ID of:
Code:
player
Code:
wall
Here is the page's code:
HTML:
<head><style>DIV.movable { position:absolute; }</style><script type="text/javascript" src="http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js"></script></head><body><div id="player" class="movable"><img src="http://eno.x10.mx/favicon_pakkit.png"></div>
<br />
<br />
<div id="wall" class="movable"><img src="wall.png"></div>
<br /><script language="javascript">document.getElementById("ufo").style.top = 1;document.getElementById("ufo").style.left = 1;var position;var pos2;pos2 = 1;position = 1;function movemedown() {position = position + 5;document.getElementById("ufo").style.top = position;document.getElementById("ufo").style.left = pos2;}function up() {position = position - 5;document.getElementById("ufo").style.top = position;}function left() {pos2 = pos2 - 5;document.getElementById("ufo").style.left = pos2;}function right() {pos2 = pos2 + 5;document.getElementById("ufo").style.left = pos2;}shortcut.add("Ctrl+Down",function() { movemedown();});shortcut.add("Ctrl+Up",function() { up()});shortcut.add("Ctrl+Left",function() { left();});shortcut.add("Ctrl+Right",function() {right();});</script><br /><br /><br /><br /><br /></body>
May somebody help me do collision checking.
Last edited: