Created
November 4, 2012 18:11
-
-
Save MattRoelle/4012826 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rect = new Rect(x+dx,y,w,h); | |
if (collides()) { | |
rect = new Rect(x+(dx/2), y,w,h); | |
if (collides()) { | |
rect = new Rect(x+(dx/4), y,w,h); | |
if (collides()) { | |
rect = new Rect(x+(dx/8), y,w,h); | |
if (collides()) { | |
if (dx > 0) { | |
int index = getIndexOfCollidingBlock(); | |
if (index != 999) { | |
Block collidingBlock = Blocks.blocks.get(index); | |
collidingBlock.baseX += 20; | |
collidingBlock.update(); | |
if (!collidingBlock.collideWithAnything()) { | |
Blocks.blocks.get(index).baseX += 20; | |
Blocks.blocks.get(index).update(); | |
} | |
} | |
} | |
else if (dx < 0) { | |
int index = getIndexOfCollidingBlock(); | |
if (index != 999) { | |
Block collidingBlock = Blocks.blocks.get(index); | |
collidingBlock.baseX -= 20; | |
collidingBlock.update(); | |
if (!collidingBlock.collideWithAnything()) { | |
Blocks.blocks.get(index).baseX -= 20; | |
Blocks.blocks.get(index).update(); | |
} | |
} | |
} | |
cantDx = true; | |
rect = oldRect; | |
dx *= -1; | |
} else { | |
x += (dx/8); | |
} | |
} else { | |
x += (dx/4); | |
} | |
} | |
else { | |
x += (dx/2); | |
} | |
} | |
else { | |
x += dx; | |
} | |
rect = new Rect(x,y+dy,w,h); | |
if (collides()) { | |
rect = new Rect(x, y+(dy/2),w,h); | |
if (collides()) { | |
rect = new Rect(x, y+(dy/4),w,h); | |
if (collides()) { | |
rect = new Rect(x, y+(dy/8),w,h); | |
if (collides()) { | |
cantDy = true; | |
rect = oldRect; | |
} else { | |
y += (dy/8); | |
dy = 0; | |
} | |
} else { | |
y += (dy/4); | |
dy = 0; | |
} | |
} | |
else { | |
y += (dy/2); | |
dy = 0; | |
} | |
} | |
else { | |
y += dy; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment