angle fix and background

This commit is contained in:
rsninja722 2020-04-18 20:14:09 -04:00
parent 468006bb47
commit 228768e356
3 changed files with 8 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -4,7 +4,8 @@ page_preloader.show(true);
images = [
"assets/images/",
"level.png"
"level.png",
"level_2.png"
];
audio = [
@ -72,6 +73,7 @@ function draw() {
case globalStates.playing:
camera.zoom = 1;
drawWorldBlocks();
imgIgnoreCutoff(sprites.level_2,0,0,0,4,4);
player.draw();
break;
// paused
@ -84,7 +86,7 @@ function draw() {
break;
//building - to be used only in development
case globalStates.building:
imgIgnoreCutoff(sprites.level,0,0);
buildDraw();
break;
}

View File

@ -96,17 +96,19 @@ Player.prototype.moveLeg = function(){
// move selected leg towards mouse
// console.log(curLeg.angle.toPrecision(5),pointTo(curLeg,target).toPrecision(5));
curLeg.angle = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed);
var angleDif = turn(curLeg.angle, pointTo(curLeg, target), constants.player.leg_speed) - curLeg.angle;
curLeg.angle += angleDif;
// var angle = pointTo(curLeg,target);
curLeg.x2 = curLeg.x + curLeg.len * Math.cos(curLeg.angle);
curLeg.y2 = curLeg.y + curLeg.len * Math.sin(curLeg.angle);
// Collision
if(collidingWithWorld({x:curLeg.x2,y:curLeg.y2,w:4,h:4})){
if(collidingWithWorld({x:curLeg.x2,y:curLeg.y2,w:2,h:2})){
this.collided = true;
curLeg.x2 = lastX;
curLeg.y2 = lastY;
curLeg.angle -= angleDif;
return 0;
}