Lua - 喜欢执行器/编译器类型的东西
我不确定它的技术术语,但它使我的 lua 代码运行,这才是真正困扰我的事情:)
不管怎样,我正在为类似 RPG 的游戏制作(目前)地图渲染器,但它渲染了玩家,但不渲染地图,我不明白为什么。
player = {
image = "",
x=0,
y=0,
}
function love.load()
love.graphics.setMode(640,480,false,true,0)
love.graphics.setCaption("2D RPG game")
player.image = love.graphics.newImage("Player_Boy.png")
G = love.graphics.newImage("Grass.png")
W = love.graphics.newImage("Water.png")
B = love.graphics.newImage("Beach.png")
end
Level = {
{G,G,G,G,G},
{G,G,G,G,W},
{G,G,G,W,W},
{G,W,W,W,W},
}
function love.draw()
love.graphics.draw(player.image, player.x, player.y, 0, 1, 1, 0,0)
--This, below, is not working.
for i = 1, #Level do
for o = 1, #Level[i] do
love.graphics.draw(Level[i][o],i*16-16,o*16-16,0,1,1,0,0)
end
end
end
I'm unsure of it's technical term, but it makes my lua code run, and that's all that realy bothers me :)
Anyway, I'm making (for now) a map renderer for an RPG-like game, but it renders the player, but doesn't render the map, I can't see why.
player = {
image = "",
x=0,
y=0,
}
function love.load()
love.graphics.setMode(640,480,false,true,0)
love.graphics.setCaption("2D RPG game")
player.image = love.graphics.newImage("Player_Boy.png")
G = love.graphics.newImage("Grass.png")
W = love.graphics.newImage("Water.png")
B = love.graphics.newImage("Beach.png")
end
Level = {
{G,G,G,G,G},
{G,G,G,G,W},
{G,G,G,W,W},
{G,W,W,W,W},
}
function love.draw()
love.graphics.draw(player.image, player.x, player.y, 0, 1, 1, 0,0)
--This, below, is not working.
for i = 1, #Level do
for o = 1, #Level[i] do
love.graphics.draw(Level[i][o],i*16-16,o*16-16,0,1,1,0,0)
end
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在初始化
G
和W
之前初始化Level
。将
Level
初始化移至love.load()
。(此外,您应该避免在这种规模下使用全局变量,这是一种不好的风格。)
You initialize
Level
beforeG
andW
are initialized.Move
Level
initialization tolove.load()
.(Also, you should avoid using global variables at that scale, it is a bad style.)