继续
来源:互联网 发布:js防水涂料配方 编辑:程序博客网 时间:2024/04/26 20:58
创建背景框和可移动方块
function love.load()
player = {grid_x = 256,
grid_y = 256,
act_x = 200,
act_y = 200,
speed = 16 }
map = {
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1 },
{ 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1 },
{ 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1 },
{ 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 },
{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }
}
end
function love.update(dt)
--player.act_y = player.act_y - (player.act_y - player.grid_y)*dt
--player.act_x = player.act_x - (player.act_x - player.grid_x)*dt
player.act_y = player.act_y - (player.act_y - player.grid_y)*dt*player.speed
player.act_x = player.act_x - (player.act_x - player.grid_x)*dt*player.speed
end
function love.draw()
for y = 1, #map do
for x = 1, #map[1] do
if map[y][x] == 1 then
love.graphics.rectangle("line", x * 32, y * 32, 32, 32)
end
end
end
love.graphics.rectangle("fill", player.act_x, player.act_y, 32, 32)
end
function love.keypressed(key)
if key == "up" then
if testMap(0,-1) then
player.grid_y = player.grid_y - 32
end
--player.grid_y = player.grid_y - 32
elseif key == "down" then
if testMap(0,1) then
player.grid_y = player.grid_y + 32
end
--player.grid_y = player.grid_y + 32
elseif key == "left" then
if testMap(-1,0) then
player.grid_x = player.grid_x - 32
end
--player.grid_x = player.grid_x - 32
elseif key == "right" then
if testMap(1,0) then
player.grid_x = player.grid_x + 32
end
--player.grid_x = player.grid_x + 32
end
end
function testMap(x,y)
if map[(player.grid_y / 32) + y][(player.grid_x / 32) + x] == 1 then
return false
end
return true
end
- 继续
- 继续
- 继续
- 继续
- 继续
- 继续~~
- 继续
- 继续
- 继续
- 继续
- 继续
- 继续
- 继续?
- 继续
- 继续...
- 继续。。。
- 继续。。
- 继续
- Checkstyle配置文件的简要说明
- HTK工具搭建识别器的总体框架
- MyBatis多参数传递之Map方式示例——MyBatis学习笔记之十三
- Ubuntu 12.04更新源地址列表更改方法
- 研磨设计模式之 单例模式-4
- 继续
- 移位运算符
- ios配置信息
- 创建参数文件spfile.ora pfile.ora
- Linux USB subsystem --- USB create HCD
- oracle 常用 sql语句
- Mybatis各种模糊查询
- 装饰模式
- 恢复服务器端初始化参数文件(SPFILE)