function love.load()
require "conf.lua"
require "block_damage.lua"
rect = {x = 0, y = 0, width = 40, height = 40, health = 100}
controls = {down = "down", up = "up", left = "left", right = "right"}
love.graphics.setFont(nokiafc22)
end
function love.draw()
love.graphics.rectangle("fill",rect.x,rect.y,rect.width,rect.height)
end
function love.update(dt)
if love.keyboard.isDown(controls.down) then
rect.y = rect.y + 200*dt
end
if love.keyboard.isDown(controls.up) then
rect.y = rect.y - 200*dt
end
if love.keyboard.isDown(controls.left) then
rect.x = rect.x - 200*dt
end
if love.keyboard.isDown(controls.right) then
rect.x = rect.x + 200*dt
end
warpScreen()
end
function warpScreen()
local width = love.graphics.getWidth()
local height = love.graphics.getHeight()
if rect.x <= -40 then
rect.x = (width + 40) - rect.width
elseif rect.x >= (width) then
rect.x = (width - 40) - width
end
if rect.y <= -40 then
rect.y = (height + 40) - rect.height
elseif rect.y >= (height) then
rect.y = (height - 40) - height
end
end
function love.load()
love.graphics.setColor(255,0,0)
end
function drawDamageBlock(x,y)
size = {x = 40, y = 40}
love.graphics.rectangle("fill",x,y,size.x,size.y)
end
function love.draw()
drawDamageBlock(100,100)
end
When i run the game, it draws the damage block but not the player... and also the damage block is white and its men't to be red...
Any help?
The callbacks don't get called for each file, there's only one of them, the one defined last, and files do mess with each other. So when you load the second file, it overrides the love.draw in the first one. Similarly, love.load in the second file never gets called, since it is only loaded after love.load has been called.
MarekkPie wrote:Well...when you bump something that is still on the main page...only 30 minutes after you first replied to it...yeah, your karma is going down.
Thanks, btw. If you are gonna post, help me, if you gonna be trollin' around, then don't post.
If you think that decreasing my karma is gonna affect me in any way, then you're wrong. I signed up to this forum because I wanted other people to help me. I don't give a crap at all.
Basically you don't want to define things like love.draw or love.load outside of main.lua, what you should do is maybe rename them to blockdamageDraw or something and then call that within love.draw in main.lua so you have something like:
function love.draw()
love.graphics.rectangle("fill",rect.x,rect.y,rect.width,rect.height)
blockdamageDraw()
end
Side note: You don't need to require conf.lua, löve does that automatically, and you should probably leave off the .lua in the file name when using require.
Evil_Bartek wrote:I signed up to this forum because I wanted other people to help me. I don't give a crap at all.
Well, that's sad. See, if everyone dislikes you for not obeying to the forum rules, they won't help you either. So please do, for all of us.
Yeah I actually don't care in that moment or in any other moment. I found a way better engine which is called flixel and use AS3 so in any second now this account been deleted. O btw. if you want to see which is better (flixel or love2d) then check some pages like: http://spottedsun.com/flixel-2-0-vs-love2d/ http://forums.tigsource.com/index.php?P ... 793.0;wap2
Well there you have it.
(I predict that I will be banned)
So according to me:
If you want to be a real game programmer, then use the java based programming languages, I can name you way more people that were famous for making AS3 games than Lua games...
Bye!
PS.Trolololololo lololo lololo oy oy oyo yoyoyo