ActionScript 2.0 - Basic Platformer

Описание к видео ActionScript 2.0 - Basic Platformer

Here's me programming a basic platformer in AS2. :) And due to MiniGameMan asking so kindly, here's the code in the description for you to Copy-and-Paste and edit, so you can learn for yourself! :D

onClipEvent(load)
{
speed = 5;
gravity = 0;
r = _height / 2;
jumping = false;
jumpheight = 10;
}

onClipEvent(enterFrame)
{
if(Key.isDown(Key.RIGHT))
{
_x += speed;
}

if(Key.isDown(Key.LEFT))
{
_x -= speed;
}

if(Key.isDown(Key.UP) && !jumping)
{
gravity = -jumpheight;
jumping = true;
}

if(!_root.ground.hitTest(_x, _y, true))
{
gravity++;
_y += gravity;
} else
{
jumping = false;
gravity = 0;
}

while(_root.ground.hitTest(_x, _y - 1 + r, true))
{
jumping = false;
_y--;
}
}

Комментарии

Информация по комментариям в разработке