0 Members and 4 Guests are viewing this topic.
X set to 3104 (48.5 when divided by 64)Y set to 2080 (32.5 when divided by 64)Game loop:Change Xdt to XdChange Ydt to YdCheck if 1 pixel above the player is solid-if so, multiply VY by -1Check if player can move down-if not, set VY (VY is the velocity of Y axis) to 0-if it can move down, subtract 8 from VYCheck if left button pressed-if so, check pixels and if it can go left, subtract 64 to Xd-If it cannot move left, check if to the left and above 1 pixel is clear, and if so, subtract 64 from Xd and add 64 to Yd and Ym, so it moves diagonal(Same with going right, except it adds 64 to Xd, not subtracts)Checks if center button pressed-If so, check if 1 pixel above the player is clear, and if so, change VY to 64Add VY to YdChange xt to Xdt - Xd Change yt to VY + Ym and then multiply it by -1Change xtt to Xd/-64Change ytt to Yd/64Add xt to exAdd yt to eyMove enemy and suchChange ex64 to ex/64Change ey64 to ey/64Draw all the stuff. Draws the enemy by using ex64 and ey64End game loop;
X=3104 ;sets X-coordinate to 3104Y=2080 ;Sets Y-coordinate to 2080XE=4128 ;Sets Enemy X coordinateYE=2080 ;Sets Enemy Y coordinateVy=0 ;Zero out the y velocity// Now you are ready to do the gravity stuff!// First we update the velocity:Vy =Vy+4 ;Increments the Y velocity by 4//Now we update positionYE =YE-Vy ;Subtracts the new velocity from the position of the enemyY =Y+Vy ;Adds the new velocity to the position of you//Now you divide the positions by 64 and use those as the coordinates :)