lextoon
Donkey Kong
- 4/7/09
- 331
- 14
- Thread starter
- #41
Về cái vụ jump, như mình nói, nó vướn vào phần trọng lực, mà cái này rất là nhức đầu vì nó không cho kéo thả mà bắt buộc dùng code , thú thật là mình vẫn chưa làm được nên đành mượn 1 đoạn code của game khác, có lẽ vì vậy mà nó hoạt động không ổn định
Về cái tện, mình tạm sửa rùi, nhưng mình vẫn muốn 1 cái tên có chữ X trong đó, nên đang suy nghĩ
Về cái hướng dẫn, mình đã ghi rõ là phải xem hướng dẫn cơ bản mà, trong file rar tên hướng dẫn cơ bản trong link, mình có chứa 5 cái video hướng dẫn do 1 người nào đó (không phải mình) làm, tại vì post youtube qua sợ die link do vi phạm bản quyền, nên mình đưa lên mediafire, bạn coi xong 5 đoạn video đó là hiểu à
Mã:
if (keyboard_check(vk_right) && !instance_position(x+17,y,obj_Ground))
{x += 4;}
if (keyboard_check(vk_left) && !instance_position(x-17,y,obj_Ground))
{x -= 4;}
if (keyboard_check(vk_up) && Up == 0) //Checks for the Up Arrow key to be pressed, and checks makes sure a jump isn't already happening
{Up = 1; //Sets Up to 1
aSp = 0; //Resets aSp to 0, otherwise, the jump won't happen properly
}
Sp = 8; //The speed at which to move up/down with
//Hei = 0.4; //The height of the jump, should never be greater than half of Sp
if (Up != 0) //Makes sure a jump isn't happening
{if (aSp <= Sp && Up == 1) //If aSp isn't equal to Sp, increment by a little amount to give the a jump a soft middle
{aSp += Hei;} //Adds Hei to aSp to slow down the jump, until aSp is equal to the up speed
if (aSp >= Sp && Up == 1) //Stops the object from moving up if aSp greater than the Up Speed
{Up = 2;}//Sets up to 2 so that the object will stop moving up
if (aSp >= 0 && Up == 2)// Makes sure the object is in the middle of the jump
{aSp -= Hei;}//Reduce aSp to make the second half of the jump has a soft beginning
if (aSp <= 0 && Up == 2 && (instance_position(x-(sprite_width/2)+1,y+(sprite_height/2)+1,
obj_Ground) || instance_position(x+(sprite_width/2)-1,y+(sprite_height/2)+1,
obj_Ground))) //Checks to make sure aSp is 0 or less and also to make sure there is a floor object underneath. If there is a floor object, it will make the character stop.
{Up = 0;}//Set Up to 0 so that another jump can occur
if (Up == 1)//When up equals one (meaning the object is moving up), move up at the speed of Sp minus aSp. This gives the jump a soft middle
{y -= Sp-aSp;}
if (Up == 2 && !instance_position(x-15,y+17,obj_Ground) && !instance_position(x+15,y+17,obj_Ground)) //Checks to make sure the ground isn't under the object.
{y += Sp-aSp;}//When Up equals 2 (meaning the object is moving down), add the down speed of Sp minus aSp.
if (Up == 2 && (instance_position(x-15,y+17,obj_Ground) || instance_position(x+15,y+17,obj_Ground))) //THIS IS ONLY USED IF YOUR GAME INVOLVES PLATFORMS OF DIFFERENT HEIGHTS. If you just have a flat ground, omit this if statement.
{Up = 0}//Set Up to 0 to stop the jump
}
if (!instance_position(x-15,y+17,obj_Ground) && !instance_position(x+15,y+17,obj_Ground) && Up == 0)//ONLY USED IF YOUR GAME INVOLVES PLATFORMS OF DIFFERENT HEIGHTS.
{Up = 2; aSp = 8;}//If you walk to the edge of a platform, drop down to the next platform or the ground.
if ((instance_position(x-15,y-17,obj_Ground) || instance_position(x+15,y-17,obj_Ground)) && Up != 0) //If there is a block above the character, reverse the jump direction
{Up = 2;}
if (instance_position(x,y+32,obj_ChangeJump1)) Hei = 0.2; //Makes the jump twice as long and high
if (instance_position(x,y+32,obj_ChangeJump2)) Hei = 0.4; //Makes the Jump Normal
if (instance_position(x,y+32,obj_ChangeJump3)) Hei = 0.8; //Makes the Jump Half as long and high
if (instance_position(x-15,y+17,obj_Ground) || instance_position(x+15,y+17,obj_Ground)) //This moves the block to the right y position to help prevent the character from going through walls
{if (frac(round(y/32)/2) == 0) y = (round(y/32)*32)-16;}
Về cái tện, mình tạm sửa rùi, nhưng mình vẫn muốn 1 cái tên có chữ X trong đó, nên đang suy nghĩ
Về cái hướng dẫn, mình đã ghi rõ là phải xem hướng dẫn cơ bản mà, trong file rar tên hướng dẫn cơ bản trong link, mình có chứa 5 cái video hướng dẫn do 1 người nào đó (không phải mình) làm, tại vì post youtube qua sợ die link do vi phạm bản quyền, nên mình đưa lên mediafire, bạn coi xong 5 đoạn video đó là hiểu à
để vọc thêm nữa 


