Cards and tile-based playboard for rivals of catan

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

Cards and tile-based playboard for rivals of catan

Hey everyboy,

i delevop a game for my work and it is called "rivals of catan" u may hear of it.
Actually i'm searching for a good solution to create a tilebased playboard, to fill every single tile with a different card, but all i could find were examples with collisions or something like that.

my second issues is the idea of develop every card.. should i use tables to set every card with attributes or is there a better way?

this is how the board looks in the middle of the game :

this is why i need your help.. i've searched every thread and tried so much, but can't find any solution.
Maybe you know a good way!?

Sorry for the post in the general forum!

if i did something wrong, please correct me and sorry for my english ( english isn't my native language)

So far TurtleS

Rickton
Party member
Posts: 128
Joined: Tue Mar 19, 2013 4:59 pm
Contact:

Re: Cards and tile-based playboard for rivals of catan

For the board, you could use a table with coordinates as the keys and the card as the table's content.

For example, if this is the game board:

Code: Select all

|hill|town|farm|
|farm|lake|hill|

You could store it as
board[1][1] = "hill"
board[1][2] = "town"
board[1][3] = "farm"
etc.

(You could also reverse it so the x-coordinate is first, and the y-coordinate is second, since that's usually how it's written.)

Then, when you're drawing the gameboard, just loop through that table and draw whatever card at whatever location it needs to be.

For the cards themselves, you'd probably use tables to hold the attributes of the card, yes.
Possession - Escape from the Nether Regions, my roguelike made in LÖVE for the 2013 7-Day Roguelike Challenge
And its sequel, simply called Possession , which is available on itch.io or Steam, and whose engine I've open-sourced!

TurtleSlap
Prole
Posts: 9
Joined: Fri Jul 31, 2015 7:45 am

Re: Cards and tile-based playboard for rivals of catan

Ah okay thanks for your answer, i understand the idea behind it.

at first the gameboard looks like this

|empty||empty|.....|empty||empty|
|empty||empty|.....|empty||empty|
|empty||empty|.....|empty||empty|
|filled | .. 8x times ..........|filled |
|empty||empty|.....|empty||empty|
|empty||empty|.....|empty||empty|
|empty||empty|.....|empty||empty|

and the player could decide at what empty space he would put his road, farm or town.

so i have to create a empty map, with only the middle line is filled up with table contents (card).
and after that, the player can choose a tile and put the card into this table right?

sorry, its kinda hard to understand the mindset behind lua.. as a bloody beginner

thanks for your great help!

i going to search for a code-snippet for creating a card

so far,

TurtleS

TurtleSlap
Prole
Posts: 9
Joined: Fri Jul 31, 2015 7:45 am

Re: Cards and tile-based playboard for rivals of catan

Hello all,

this is my first update of the Game. i created the menu , drawing something (via tutorial steps) as you can see , everything seems fine.
now i tried to include a 2-dimensional table, but i can't figure out why it doesn't work..

i tried to implament

Code: Select all

local MapTable = {}
local Maximum_X, Maximum_Y = 32, 16
local Start_X, Start_Y = 64, 32

for y = 1,Maximum_Y do
local row = {}
for x = 1,Maximum_X do
table.insert(row,2)
end
table.insert(MapTable,row)
end
end

function love.draw()
for y,row in ipairs(MapTable) do
for x,idx in ipairs(row) do
love.graphics.draw(Tileset[idx], Start_X + 32*(x-1), Start_Y + 32*(y-1))
end
end
end
but all they give back is "Tileset is not defined (value:nil)".

I found tables over tables.. but cant figure out how it should work for my example..

also my cards have 4 sides with each a different attribute (0-3 ressources)
and i thought about:

Code: Select all

rival.cards = {}
rival.cards[1].name = "farm"
rival.cards[1].typeRessource = "hay"
rival.cards[1].topRessource = 0
rival.cards[1].rightRessource = 1
rival.cards[1].bottomRessource = 2
rival.cards[1].leftRessource = 3

rival.cards[2].name = "town"
rival.cards[2].typeRessource = "Win-Point"
rival.cards[2].amountPoints = 1

etc.

would this be the correct use of tables for my cards?

lovely greetings

TurtleS
Attachments
z6.love
Rivals of Catan first Steps

Xugro
Citizen
Posts: 80
Joined: Wed Sep 29, 2010 8:14 pm

Re: Cards and tile-based playboard for rivals of catan

TurtleSlap wrote:now i tried to include a 2-dimensional table, but i can't figure out why it doesn't work..
[...]
but all they give back is "Tileset is not defined (value:nil)".
You never declared the table Tileset. You must create the table first and fill it with images.
TurtleSlap wrote:also my cards have 4 sides with each a different attribute (0-3 ressources)
[...]
would this be the correct use of tables for my cards?
You could save the number of resources in one variable:

Code: Select all

rival.cards[1].Ressource = 3

TurtleSlap
Prole
Posts: 9
Joined: Fri Jul 31, 2015 7:45 am

Re: Cards and tile-based playboard for rivals of catan

Hey all,

i found a Tutorial about tiles and maps with them, but did he make a mistake?
The only thing missing is the “here” of “grass goes here”. We encode that “here” in two variables, called x and y. Their calculation is very simple. For x, we use rowIndex and the tile width; for y, columnIndex and the tile height.

Code: Select all

local x = (columnIndex-1)*TileW
local y = (rowIndex-1)*TileH
he gave the x columIndex and the y the rowindex. he switched the index on purpose or what?

Code: Select all

for rowIndex=1, #TileTable do
local row = TileTable[rowIndex]
for columnIndex=1, #row do
local number = row[columnIndex]
local x = (columnIndex-1)*TileW
local y = (rowIndex-1)*TileH
love.graphics.draw(Tileset, Quads[number], x, y)
end
end
it confuse me alot

so far,

TurtleS

Who is online

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