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
Before you make a thread asking for help, read this.
User avatar
WolfNinja2
Party member
Posts: 150
Joined: Wed Oct 24, 2012 10:10 pm

Re: Drawing a image from a for loop?

Post by WolfNinja2 »

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

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

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
jjmafiae
Party member
Posts: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Drawing a image from a for loop?

Post by jjmafiae »

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
User avatar
WolfNinja2
Party member
Posts: 150
Joined: Wed Oct 24, 2012 10:10 pm

Re: Drawing a image from a for loop?

Post by WolfNinja2 »

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: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Drawing a image from a for loop?

Post by jjmafiae »

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.
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: Drawing a image from a for loop?

Post by veethree »

In love.load, just move the loading libraries section below the loading images section.

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: 1331
Joined: Tue Jul 24, 2012 8:22 am

Re: Drawing a image from a for loop?

Post by jjmafiae »

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

[]

Post by bekey »

-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
User avatar
WolfNinja2
Party member
Posts: 150
Joined: Wed Oct 24, 2012 10:10 pm

Re: Drawing a image from a for loop?

Post by WolfNinja2 »

veethree : thanks. others : lolidk
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Drawing a image from a for loop?

Post by Roland_Yonaba »

WolfNinja2 wrote:Still, I don't need any of that. Maybe someday but for this little project I'm doing 0.8.0.
0.8.0 is still relevant, and is working fine.
0.9.0 fixes some stuff, and provides better performance.
You have the choice, do not ask to people to convince you to move to 0.9.0, just do what you want to do, and use the version you are comfortable with.
Side note, new concepts have been integrated into 0.9.0. If you feel like you need to master those concepts, then you can start using 0.9.0. Maybe not for some on-going project, but to write small demos for yourself.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 8 guests