Re: Drawing a image from a for loop?
Posted: Sat Jan 18, 2014 5:10 pm
Took out that function and just called the table at the top of the file. It gives me the same exact error. Code now.
Is there any big reason to update to 0.9.0? I just didn't see a reason too...
menu.lua
main.lua
Is there any big reason to update to 0.9.0? I just didn't see a reason too...
menu.lua
Code: Select all
buttons = {}
--
buttons["Start"] = {x = 250, y = 350, width = 100, height = 50, pic = img_btnStart, picClick = img_btnStart_click, click = false, state = 0}
--
function DRAW_MENU()
for k,v in pairs(buttons) do
g.draw(v.pic, v.x, v.y)
end
end
--
function UPDATE_MENU(dt)
end
Code: Select all
require "player"
require "bullet"
require "enemy"
require "menu"
require "powerups"
--
function love.load()
--GLOBAL VARIABLES
g = love.graphics
ScreenWidth = g.getWidth()
ScreenHeight = g.getHeight()
gameTime = love.timer.getTime()
mouse_x = love.mouse.getX()
mouse_y = love.mouse.getY()
killCount = 0
--LOADING LIBRARIES
LOAD_PLAYER()
LOAD_BULLET()
LOAD_ENEMY()
LOAD_POWERUPS()
--LOADING IMAGES
bg = g.newImage("Resources/Pictures/background.png")
img_enemy = g.newImage("Resources/Pictures/enemy.png")
img_btnStart = g.newImage("Resources/Pictures/button_start-1.png")
img_btnStart_click = g.newImage("Resources/Pictures/button_start-2.png")
img_bullet = g.newImage("Resources/Pictures/bullet.png")
img_bulletLeft = g.newImage("Resources/Pictures/bulletLeft.png")
img_bulletRight = g.newImage("Resources/Pictures/bulletRight.png")
img_bulletDown = g.newImage("Resources/Pictures/bulletDown.png")
img_healthPickup = g.newImage("Resources/Pictures/healthPickup.png")
--Gamestates --- 0:Menu -1:In-Game
gamestate = 0
end
--
function love.keypressed(key)
player.shoot(key)
end
--
function love.update(dt)
if gamestate == -1 then
if player.alive then
UPDATE_PLAYER(dt)
UPDATE_BULLET(dt)
UPDATE_ENEMY(dt)
UPDATE_POWERUPS(dt)
end
elseif gamestate == 0 then
UPDATE_MENU(dt)
end
end
--
function love.draw()
if gamestate == -1 then
g.setColor(255, 255, 255 ,255)
g.draw(bg, 0, 0)
DRAW_PLAYER()
DRAW_POWERUPS()
DRAW_BULLET()
DRAW_ENEMY()
if player.alive == false then
GAME_OVER()
end
elseif gamestate == 0 then
DRAW_MENU()
end
end