Spieler kann nicht aus die gelbe Box laufen
This commit is contained in:
		
							
								
								
									
										11
									
								
								js/allg.js
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								js/allg.js
									
									
									
									
									
								
							@@ -1,6 +1,8 @@
 | 
			
		||||
// animation
 | 
			
		||||
let playerAnim = [];
 | 
			
		||||
let tomAnim = [];
 | 
			
		||||
let enemyAnim = [];
 | 
			
		||||
//player
 | 
			
		||||
let playerAnimState = 0;
 | 
			
		||||
let runDirection = 0;
 | 
			
		||||
let runSpeed = 12;
 | 
			
		||||
@@ -11,6 +13,9 @@ let playerSprite = document.querySelector("#fuchs img");
 | 
			
		||||
let dIsPressed = false;
 | 
			
		||||
let aIsPressed = false;
 | 
			
		||||
let runAnimation;
 | 
			
		||||
// Map
 | 
			
		||||
const boxBorderLeft = -40;
 | 
			
		||||
const boxBorderRight = 840;
 | 
			
		||||
 | 
			
		||||
fillArrays();
 | 
			
		||||
startAnimation();
 | 
			
		||||
@@ -96,7 +101,11 @@ document.addEventListener('keyup', function(event)
 | 
			
		||||
//---------------------------------------------------------- Move Player ------------------------------------------------------------
 | 
			
		||||
function move()
 | 
			
		||||
{
 | 
			
		||||
    currentPosition = currentPosition + runDirection * runSpeed;
 | 
			
		||||
    let nextPosition = currentPosition + runDirection * runSpeed;
 | 
			
		||||
    if(nextPosition > boxBorderLeft && nextPosition < boxBorderRight)
 | 
			
		||||
    {
 | 
			
		||||
        currentPosition = nextPosition;
 | 
			
		||||
    }
 | 
			
		||||
    player.style.left =  currentPosition + "px";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user