Adressing table-content for manipulation

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
TurtleSlap
Prole
Posts: 9
Joined: Fri Jul 31, 2015 7:45 am

Adressing table-content for manipulation

Post by TurtleSlap »

Hey all,

i finished the tile-based part of my game, i am able now to build a map with different tiles (see attachment),

now i want to be able to adress specific tiles with my mouse and activate them to insert a card or watch the content of this table value..

as you can see, i draw the map with a loop for my table and used a tileset to create the map :)

Code: Select all

Quads = {
    love.graphics.newQuad(0,   0, TileW, TileH, tilesetW, tilesetH), -- 1 = grass
    love.graphics.newQuad(64,  0, TileW, TileH, tilesetW, tilesetH), -- 2 = box
    love.graphics.newQuad(0,  64, TileW, TileH, tilesetW, tilesetH), -- 3 = flowers
    love.graphics.newQuad(64, 64, TileW, TileH, tilesetW, tilesetH),  -- 4 = boxtop
	love.graphics.newQuad(128, 0, TileW, TileH, tilesetW, tilesetH),  -- 5 = Basis-Karte
	love.graphics.newQuad(128,64,TileW, TileH, tilesetW, tilesetH),  -- 6 = Ereignis-Karte
	love.graphics.newQuad(192,0,TileW, TileH, tilesetW, tilesetH),  -- 7 = Siedlung
	love.graphics.newQuad(0,128,TileW, TileH, tilesetW, tilesetH),  -- 8 = Holz
	love.graphics.newQuad(64,128,TileW, TileH, tilesetW, tilesetH),  -- 9 = Straße
	love.graphics.newQuad(128,128,TileW, TileH, tilesetW, tilesetH),  -- 10 = Erz
	love.graphics.newQuad(192,64,TileW, TileH, tilesetW, tilesetH)  -- 11 = Leer
	
	
  }
  
  TileTable = {
  
     { 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,7 ,9 ,7 ,9 ,7 ,1 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,10,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,5 ,5 ,5 ,5 ,5 ,5 ,5 ,5 ,6 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,10,1 ,10,1 ,10,1 ,10,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,9 ,7 ,9 ,7 ,9 ,7 ,9 ,1 ,1 ,1 ,1 },           
     { 1 ,1 ,1 ,1 ,1 ,8 ,1 ,8 ,1 ,8 ,1 ,8 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
     { 1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 },
	 { 11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11 }
     
  }
now my question: how could i adress the values ?

something like
boardcontent = {}
board[6][5] = "farm" <- gives back some points for my ressources
board[5][5] = "empty" <- able to use as a slot for another card

my goal is to draw a tile-based map, and are able to adress every single tile with the mouse and are able to do something with it (check, insert a card, or rotate (connect with new ressource-points).

Sorry for my questions if i bother you, but i try hard and do as much by myself as i could.

so far,

TurtleS
Attachments
7.love
new attachment with current map
(3.07 MiB) Downloaded 65 times
Post Reply

Who is online

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