## Drawing a image from a for loop?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
WolfNinja2
Party member
Posts: 150
Joined: Wed Oct 24, 2012 10:10 pm

### Re: Drawing a image from a for loop?

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...

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}
--
for k,v in pairs(buttons) do
g.draw(v.pic, v.x, v.y)
end
end
--

end
main.lua

Code: Select all

require "player"
require "bullet"
require "enemy"
require "powerups"
--

--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

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")

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
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
end
end

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

### Re: Drawing a image from a for loop?

It's faster, less bugs and much more, I don't see a reason not to upgrade.

another reason is that love-android isn't ported to 0.8.0 but only to 0.9.0

It takes less than 5 minutes to port a small game to 0.9.0

WolfNinja2
Party member
Posts: 150
Joined: Wed Oct 24, 2012 10:10 pm

### Re: Drawing a image from a for loop?

Still, I don't need any of that. Maybe someday but for this little project I'm doing 0.8.0.

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

### Re: Drawing a image from a for loop?

dude, goto the front page download the installer and change 5 lines of code and BOOOOOM 0.9.0!!!!

The performance improvement is noticeable, trust me.

veethree
Inner party member
Posts: 814
Joined: Sat Dec 10, 2011 7:18 pm

### Re: Drawing a image from a for loop?

As for 0.9.0, It's definitely worth updating, For now i think most of us still have 0.8.0 installed, But after some time i bet most of us wont, So if you post your 0.8.0 .loves asking for help we'll have to re-download it to be able to help, Or just not help at all.

jjmafiae
Party member
Posts: 1333
Joined: Tue Jul 24, 2012 8:22 am

### Re: Drawing a image from a for loop?

i migrated to 0.9.0 over 6 months ago, It's amazing.

bekey
Party member
Posts: 255
Joined: Tue Sep 03, 2013 6:27 pm

### []

-snip-
Last edited by bekey on Fri Jan 24, 2014 2:22 am, edited 1 time in total.
love2d.org forum removal spell: http://pastebin.com/iVqJrbKN

WolfNinja2
Party member
Posts: 150
Joined: Wed Oct 24, 2012 10:10 pm

### Re: Drawing a image from a for loop?

veethree : thanks. others : lolidk

Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm