credits keep crashing

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.
Post Reply
User avatar
CanadianGamer
Party member
Posts: 132
Joined: Tue Jun 30, 2015 1:23 pm
Location: Canada
Contact:

credits keep crashing

Post by CanadianGamer »

Hi guys

so I'm making this game but whenever I try to test the credits It crashes anyone know why
Attachments
main.lua
main
(1.37 KiB) Downloaded 180 times
credits.lua
credits
(365 Bytes) Downloaded 196 times
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: credits keep crashing

Post by Eamonn »

Whoops, seems like we need some assets, first. font1.ttf, font2.ttf and background.png

I'll work on finding a solution and edit this post if I find one, but could you please upload some assets? You could zip the files and just upload the archive to the forums or Google Drive or something.
"In those quiet moments, you come into my mind" - Liam Reilly
User avatar
CanadianGamer
Party member
Posts: 132
Joined: Tue Jun 30, 2015 1:23 pm
Location: Canada
Contact:

Re: credits keep crashing

Post by CanadianGamer »

sorry for bothering you I figured it out
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
User avatar
Eamonn
Party member
Posts: 550
Joined: Sat May 04, 2013 1:29 pm
Location: Ireland

Re: credits keep crashing

Post by Eamonn »

CanadianGamer wrote:sorry for bothering you I figured it out
The for loop in the credits menu was causing the problem. I fixed it using a simple gamestate variable, to replace your title variable. Here's the code anyway:

main.lua:

Code: Select all


require('credits')

gamestate = 'title'

function love.load()
	--backgroundImg = love.graphics.newImage('assets/background.png')
	title = true
	--font1 = love.graphics.newFont('assets/font1.ttf', 125)
	--font2 = love.graphics.newFont('assets/font2.ttf', 50)
end

function love.update()
	mouseX = love.mouse.getX()
	mouseY = love.mouse.getY()
	mouseIsPressed = love.mouse.isDown('l')

	--play button
	if gamestate == 'title' then
		if mouseX >= 100 and
		mouseX <= 210 and
		mouseY >= 200 and
		mouseY <= 240 and
		mouseIsPressed == true then
			gamestate = 'play'
		--help button
		elseif mouseX >= 100 and
		mouseX <= 210 and
		mouseY >= 250 and
		mouseY <= 290 and
		mouseIsPressed == true then
			gamestate = 'help'
		--credits button
		elseif mouseX >= 100 and
		mouseX <= 300 and
		mouseY >= 300 and
		mouseY <= 340 and
		mouseIsPressed == true then
			love.graphics.setNewFont(50)
			gamestate = 'credits'
		--quit button
		elseif mouseX >= 100  and
		mouseX <= 210 and
		mouseY >= 350 and
		mouseY <= 390 and
		mouseIsPressed == true then
			love.event.quit()
		end
	end

	if gamestate == 'credits' then
		-- Some form of credits updating
	elseif gamestate == 'title' then
		-- Some form of title updating
	elseif gamestate == 'help' then
		-- Some form of help updating
	elseif gamestate == 'play' then
		-- Some form of play upating
	end
end



function love.draw()
	--love.graphics.draw(backgroundImg, 0, 0)
	if gamestate == 'title' then
		love.graphics.setNewFont(20)
		love.graphics.print('Ninja  Dodge', 20, 20)
		love.graphics.setNewFont(40)
		love.graphics.print('Play', 100, 200)
		love.graphics.print('Help', 100, 250)
		love.graphics.print('Credits', 100, 300)
		love.graphics.print('Quit', 100, 350)
	elseif gamestate == 'credits' then
		credits()
	end

	love.graphics.print(mouseX, 100, 100)
end
credits.lua:

Code: Select all

-- credits
isOn = true
function credits()
	if gamestate == 'credits' then
		keyDown = love.keyboard.isDown('escape')
		if keyDown == true then
			isOn = false
		end
		love.graphics.print('coded by: CanadianGamer', 30, 30)
		love.graphics.print('ideas by: CanadianGamer', 30, 70)
		love.graphics.print('everything else by: CanadianGamer', 30, 110)
	end
end
You were also calling some love.draw() functions in love.update(dt). Be sure to separate drawing and updating code into separate functions ( eg credits_load(), credits_update(dt), credits_draw() )

Have a great day!
"In those quiet moments, you come into my mind" - Liam Reilly
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 4 guests