Rocks = {}
function Rocks_spawn(x, y, rock)
table.insert(Rocks, {x= x, y = y, rock = rock})
end
function Rocks_draw()
for i,v in ipairs(Rocks) do
love.graphics.setColor(0, 0, 0)
love.graphics.draw(v.rock, v.x, v.y)
end
end
function love.load()
require ("Rock")
require ("anal")
RockMoveS = 200
RockMoveX = 355
RockMoveY = 255
Boulder = love.graphics.newImage("Rock.png")
Rockmonster = love.graphics.newImage("Rockmonster.png")
backround = love.graphics.newImage("backround.png")
spritesheet = love.graphics.newImage("spritesheet.png")
spritesheet:setFilter("nearest", "nearest")
animation = newAnimation(spritesheet, 45, 45, 0.1, 2)
Rocks_spawn(5, 200, Boulder)
end
function love.update(dt)
if love.keyboard.isDown("d") and love.keyboard.isDown("s") then
RockMoveS = 210
end
if love.keyboard.isDown("a") and love.keyboard.isDown("s") then
RockMoveS = 210
end
if love.keyboard.isDown("a") and love.keyboard.isDown("w") then
RockMoveS = 205
end
if love.keyboard.isDown("d") and love.keyboard.isDown("w") then
RockMoveS = 205
end
if love.keyboard.isDown("w") then
RockMoveY = RockMoveY - RockMoveS*dt
animation:update(dt)
end
if love.keyboard.isDown("s") then
RockMoveY = RockMoveY + RockMoveS*dt
animation:update(dt)
end
if love.keyboard.isDown("d") then
RockMoveX = RockMoveX + RockMoveS*dt
animation:update(dt)
end
if love.keyboard.isDown("a") then
RockMoveX = RockMoveX - RockMoveS*dt
animation:update(dt)
end
if RockMoveY > 555 then
RockMoveY = 555
end
if RockMoveX > 755 then
RockMoveX = 755
end
if RockMoveY < 0 then
RockMoveY = 0
end
if RockMoveX < 0 then
RockMoveX = 0
end
end
function love.draw()
love.graphics.draw(backround, 0, 0)
Rocks_draw()
animation:draw(RockMoveX, RockMoveY, 0, 1)
end
Last edited by BEANSFTW on Tue Sep 25, 2012 10:53 pm, edited 1 time in total.
Table is the name given to the sole structure in lua programming. If you honestly don't know what they are and how to use them, it means you don't understand what you've been doing until now and, as Nixola did, I fear I must recommend you to read on Lua programming (either the official book or a tutorial, just google it). However, if you have a more specific question, try to explain it better to us.
Either way, good luck.
Did my comment help/offended you? Use the Karma button!! LÖVEing each day...
In the Rocks_draw() function you set the colors to (0,0,0), black, so nothing is showing up because (probably) your background is black.Just change it to (255,255,255) and it should draw correctly.
Nice way to entirely change the topic BEANSFTW, lol!!!!!
Now everyone who sees mine and Nixola's comment will think we are crazy. Okay, but for your current question, as Dola said, when you set the color to be black (0,0,0), your rocks will be drawn with the color you chose (in your case black), and therefore appear as black objects. Change it to (255,255,255 -- white) to maintain the original color of the image.
Did my comment help/offended you? Use the Karma button!! LÖVEing each day...