An error I am not sure about

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
Atton
Prole
Posts: 15
Joined: Mon Aug 26, 2013 1:38 pm

An error I am not sure about

Post by Atton »

I've been doing a bit of programing more and more often, and found this website after looking on the Garry's Newman's blog.
I did some looking up and found a few videos tutorials, had a few mess ups but I was able to get somewhere. However the videos had quite a bit of age to them and as updates happen errors happen.

The error is located at 136 and the code was referenced from a video.
https://www.youtube.com/watch?v=C0-PlcWilHQ
The one above to be precise, If anyone can provide any advice or help than if you have the time please do so.
Thanks
136
http://pastebin.com/5UNNutYM
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: An error I am not sure about

Post by Azhukar »

Post the entire error message.
User avatar
Doctory
Party member
Posts: 441
Joined: Fri Dec 27, 2013 4:53 pm

Re: An error I am not sure about

Post by Doctory »

well, nobody (as far as i know) uses ATL because it has bugs, i recommend you switch to STI
Atton
Prole
Posts: 15
Joined: Mon Aug 26, 2013 1:38 pm

Re: An error I am not sure about

Post by Atton »

I have attached a picture of the error below. As for ATL being buggy I have not experienced that but again I have never got it to work correctly. If STL is better then I will surely make use of it however I need to figure out how it works. So maybe if anyone has any information on that I could change things to make it work. I am simply very new to game programing for forgive my noobism.

But thanks for the advice.
Attachments
The Error
The Error
error.PNG (41.19 KiB) Viewed 4732 times
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: An error I am not sure about

Post by Azhukar »

You have 2 love.load functions, at line 23 and 36. The second one overwrites the first one, so loadMap() never gets called.
Atton
Prole
Posts: 15
Joined: Mon Aug 26, 2013 1:38 pm

Re: An error I am not sure about

Post by Atton »

Azhukar wrote:You have 2 love.load functions, at line 23 and 36. The second one overwrites the first one, so loadMap() never gets called.
Thanks I have made the changes to it fix however I am still at square one. I simply do not understand how the fix the error at line 123. But thanks for your help anyway.

Code: Select all

loader = require("AdvTiledLoader/Loader")
require("camera")
--require("player")

-- My Code Starts Here
-- This part works fine
function loadMap ()
	loader.path = "maps/"
	map = loader.load("map.tmx")
	map:draw()
	map:setDrawRange(0, 0, map.width * map.tileWidth, map.height * map.tileHeight)
	
	camera:setBounds(0, 0, map.width * map.tileWidth - love.graphics.getWidth(), map.height * map.tileHeight - love.graphics.getHeight() )
end

function drawMap ()
	map:draw()
	love.graphics.setBackgroundColor(255,255,255)
end

-- Stuff beyond this message is sourced from others.
function love.load()
	loadMap()
	world = 	{
				gravity = 1536,
				ground = 512,
				}
				
	player = 	{
				x = 256,
				y = 256,
				x_vel = 0,
				y_vel = 0,
				jump_vel = -1024,
				speed = 512,
				flySpeed = 700,
				state = "",
				h = 32,
				w = 32,
				standing = false,
				}
	function player:jump()
		if self.standing then
			self.y_vel = self.jump_vel
			self.standing = false
		end
	end
	
	function player:right()
		self.x_vel = self.speed
	end
	
	function player:left()
		self.x_vel = -1 * (self.speed)
	end
	
	function player:stop()
		self.x_vel = 0
	end
	
	function player:collide(event)
		if event == "floor" then
			self.y_vel = 0
			self.standing = true
		end
		if event == "cieling" then
			self.y_vel = 0
		end
	end
	
	function player:update(dt)
		local halfX = self.w / 2
		local halfY = self.h / 2
		
		self.y_vel = self.y_vel + (world.gravity * dt)
		
		self.x_vel = math.clamp(self.x_vel, -self.speed, self.speed)
		self.y_vel = math.clamp(self.y_vel, -self.flySpeed, self.flySpeed)
		
		local nextY = self.y + (self.y_vel*dt)
		if self.y_vel < 0 then
			if not (self:isColliding(map, self.x - halfX, nextY - halfY))
				and not (self:isColliding(map, self.x + halfX - 1, nextY - halfY)) then
				self.y = nextY
				self.standing = false
			else
				self.y = nextY + map.tileHeight - ((nextY - halfY) % map.tileHeight)
				self:collide("cieling")
			end
		end
		if self.y_vel > 0 then
			if not (self:isColliding(map, self.x-halfX, nextY + halfY))
				and not(self:isColliding(map, self.x + halfX - 1, nextY + halfY)) then
					self.y = nextY
					self.standing = false
			else
				self.y = nextY - ((nextY + halfY) % map.tileHeight)
				self:collide("floor")
			end
		end
		
		local nextX = self.x + (self.x_vel * dt)
		if self.x_vel > 0 then
			if not(self:isColliding(map, nextX + halfX, self.y - halfY))
				and not(self:isColliding(map, nextX + halfX, self.y + halfY - 1)) then
				self.x = nextX
			else
				self.x = nextX - ((nextX + halfX) % map.tileWidth)
			end
		elseif self.x_vel < 0 then
			if not(self:isColliding(map, nextX - halfX, self.y - halfY))
				and not(self:isColliding(map, nextX - halfX, self.y + halfY - 1)) then
				self.x = nextX
			else
				self.x = nextX + map.tileWidth - ((nextX - halfX) % map.tileWidth)
			end
		end
		
		self.state = self:getState()
	end
	
	function player:isColliding(map, x, y)
		local layer = map.tl["Solid"] -- I get and error here and as far as I know this is the only major one. The ERROR is still here
		local tileX, tileY = math.floor(x / map.tileWidth), math.floor(y / map.tileHeight)
		local tile = layer.tileData(tileX, tileY)
		return not(tile == nil)
	end
	
	function player:getState()
		local tempState = ""
		if self.standing then
			if self.x_vel > 0 then
				tempState = "right"
			elseif self.x_vel < 0 then
				tempState = "left"
			else
				tampState = "stand"
			end
		end
		if self.y_vel > 0 then
			tempState = "fall"
		elseif self.y_vel < 0 then
			tempState = "jump"
		end
		return tempState
	end
end

function love.draw()
	drawMap()
	camera:set()
	
	love.graphics.setColor( 0, 0, 0 )
	love.graphics.rectangle("fill", player.x - player.w/2, player.y - player.h/2, player.w, player.h)
	
	love.graphics.setColor( 255, 255, 255 )
	map:draw()
	
	camera:unset()
end

function love.update(dt)
	if dt > 0.05 then
		dt = 0.05
	end
	if love.keyboard.isDown("d") then
		player:right()
	end
	if love.keyboard.isDown("a") then
		player:left()
	end
	if love.keyboard.isDown(" ") and not(hasJumped) then
		player:jump()
	end
	
	player:update(dt)
	
	camera:setPosition( player.x - (love.graphics.getWidth()/2), player.y - (love.graphics.getHeight()/2))
end

function love.keyreleased(key)
	if (key == "a") or (key == "d") then
		player.x_vel = 0
	end
end


davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: An error I am not sure about

Post by davisdude »

Without your code I can't be sure, but it appears it's an error in ATL and not your code. I don't know what specifically, just that that's the problem. If you post your code, we could help you. But I would recommend switching to STI.
AFAIK it uses the same syntax (not an expert here, never really used either of them), and if not, the switch should be minimally painful, as STI is fairly well documented.
Not to mention STI is still being developed, while ATL has possible problems still (like the one you've encountered).

Like I said, we can't be sure unless you posted all of your code, but the problem more than likely isn't in your code.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Atton
Prole
Posts: 15
Joined: Mon Aug 26, 2013 1:38 pm

Re: An error I am not sure about

Post by Atton »

davisdude wrote:Without your code I can't be sure, but it appears it's an error in ATL and not your code. I don't know what specifically, just that that's the problem. If you post your code, we could help you. But I would recommend switching to STI.
AFAIK it uses the same syntax (not an expert here, never really used either of them), and if not, the switch should be minimally painful, as STI is fairly well documented.
Not to mention STI is still being developed, while ATL has possible problems still (like the one you've encountered).

Like I said, we can't be sure unless you posted all of your code, but the problem more than likely isn't in your code.
I will take your advice and make the switch to STI since it seems better. I have also posted all of the game files involved in this I do not expect anyone to be able to fix them. There is a metric ton of code build into ATL but I will try using STI.
Attachments
game.zip
(57.29 KiB) Downloaded 81 times
Post Reply

Who is online

Users browsing this forum: Google [Bot], Semrush [Bot] and 1 guest