Tile Map help

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.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Tile Map help

Post by coffee »

Roland_Yonaba wrote:I'm unsure, maybe you should post your source. Guessing you're using coffee's snippet as a base-code, take into account that setting x,y at 1 results in this (obviously)
You should be more sure of that because you (obviously) forgot to notice and say that the +32px (or whatever size) offset would also happen anyway in your snippets first post proposal. So don't really care which snippet he was using as base right?
Your code:

Code: Select all

for y=1, #map do
   for x=1, #map[1] do 
   love.graphics.draw(tile[map[y][x]], x * tileWidth, y * tileHeight)
   end
end
Since x and y also both start at 1, the first tile would never be draw at 0,0 true?

And "my" snippet was actually Coke's own code where I only fixed the blue screen errors (as intended). I wanted show him why the errors were happening in his original code, nothing more.
coke905
Citizen
Posts: 52
Joined: Tue Jun 05, 2012 1:46 am

Re: Tile Map help

Post by coke905 »

That Whiff Of Steam game is it sidescrolling rpg or top down rpg
coke905
Citizen
Posts: 52
Joined: Tue Jun 05, 2012 1:46 am

Re: Tile Map help

Post by coke905 »

Anyone know how i can create a for loop or something to make collision detections or to create more then one object

here is my collision detection code

function Basic_Disabled_Movement(dt)
Collision = false
if isColliding(Player.x,Player.y,Player.Image:getWidth(),Player.Image:getHeight(), 150, 150, 200, 200) -> This is where i want to add objects because i dont want to have to do this every single time for every single object that i dont want my character to walk through
Collision = true
elseif Collision == false then
Player.x = Player.x - Player.Speed * dt
Pressing_Left = true
Player_Facing = 180
end

end

This is the Itemfile im making

function InitItems()
Boxes = {}
Boxes.1x = 150
Boxes.1y = 150
Boxes.1width = 200
Boxes.1height = 200


end

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

Re: Tile Map help

Post by Roland_Yonaba »

coffee wrote: So don't really care which snippet he was using as base right?
Sorry, I get your point. I was no more considering my snippet, but you're clearly right, it features the same issue.
*Thanks* pointing that out.
coke905 wrote: Anyone know how i can create a for loop or something to make collision detections or to create more then one object
You should have made a search, there's a lot of thread about collision detection.
Optionnally, you can check this, on the wiki.
As a collision detection function returns a boolean, I suggest cast that value, then process accordingly.
coke905
Citizen
Posts: 52
Joined: Tue Jun 05, 2012 1:46 am

Re: Tile Map help

Post by coke905 »

Well that what i have but i was wondering how to stop the player from moving through the rectangle any suggestions. Player.x = 0 doesnt do anything either does Player.x = Player.x + 0


for my tilemap how would i draw the tiles at the bottom not the top
function Draw_Map1()
for y = 1, map1_display_h do
for x = 1, map1_display_w do
love.graphics.draw(tile[map1[y][x]], (x - 1) * 76, (y - 1) * 51)
end
end
end

Cause the land i want at the bottom, im making a side scroller
coke905
Citizen
Posts: 52
Joined: Tue Jun 05, 2012 1:46 am

Re: Tile Map help

Post by coke905 »

nvm got the bottom tilemap fixed, now i just need collisions
coke905
Citizen
Posts: 52
Joined: Tue Jun 05, 2012 1:46 am

Re: Tile Map help

Post by coke905 »

K im running into a problem no matter what i change my map1_display_w to whats drawn doesn't get further here is my code


function Init_Map()
map1_display_w = 10
map1_display_h = 2

map1 = {
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
}

tile = {}

for i = 0 ,4 do
tile = love.graphics.newImage( "Images/Maps/tile"..i..".png" )
end

end

function Draw_Map1() -> this is in different file
for y = 1, map1_display_h do
for x = 1, map1_display_w do
love.graphics.draw(tile[map1[y][x]], 10 + (x - 1) * 76, 500 + (y - 1) * 51)
end
end
end
User avatar
Roland_Yonaba
Inner party member
Posts: 1563
Joined: Tue Jun 21, 2011 6:08 pm
Location: Ouagadougou (Burkina Faso)
Contact:

Re: Tile Map help

Post by Roland_Yonaba »

Hey,

1. You made 3 posts in a row. Use Edit button, instead of making tons of posts in a row.
2. Use code tags when you want to include a snippet of code in a post. I already said that before.
3. Post your *.love file, while stating clearly what the problem is.Actually, it is a bit unclear to me. (Maybe because i'm kinda hungry, now :x )
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Tile Map help

Post by Robin »

Roland is right, even if he might have worded it a little bit harshly. (I don't blame you, Roland.)

Two things I see without even having a .love (you still need to upload one, though):

Code: Select all

	
	for i = 0 ,4 do
		tile[i] = love.graphics.newImage( "Images/Maps/tile"..i..".png" )
	end
Lua tends to count from 1, although in your particular case that is not a problem.

Code: Select all

	for y = 1, map1_display_h do
		for x = 1, map1_display_w do
You should replace that with

Code: Select all

	for y = 1, #map1 do
		for x = 1, #map1[y] do
That will automatically use the right dimensions.
Help us help you: attach a .love.
coke905
Citizen
Posts: 52
Joined: Tue Jun 05, 2012 1:46 am

Re: Tile Map help

Post by coke905 »

K i dont understand what game tags are and i dont know what you mean by uploading .love file. My problem is no matter what value i change map1_display_w or map1_display_h as it doesn't change what it draws to. Im changing the table aswell.
Post Reply

Who is online

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