键盘方向键控制人物上下左右行走
演示地址
MYCode
<html>
<head>
<meta charset=utf-8>
<title>html5人物行走</title>
<script>
var canvas;
var ctx;
//role
var role_x=50;
var role_y=50;
var role_width=32;
var role_height=48;
//每个方向有4个状态
role_direction=0;//value[0,3];
role_status=0;//value[0,3];
//box
var box_x=0;
var box_y=0;
var box_width=400;
var box_height=400;
//
var bound_left=0;
var bound_right=box_x+box_width-role_width;
var bound_top=0;
var bound_bottom=box_y+box_height-role_height;
var unit=10;