Page 1 of 1

### Hearthstone-like card hold mechanic?

Posted: Mon Jan 21, 2019 2:17 am
Hey guys, its been awhile since i last asked a question, huh? so what are we waiting for! I'm working on a bakugan-like game and i'm trying to make card holding mechanic that similar to hearthstone. I made something like that:

Code: Select all

``````cards=0;
lp=love.graphics;

function love.keypressed(key)
if key=="w" then
cards=cards+1;
elseif key=="s" then
cards=cards-1;
end
end

function love.draw()
for i=1, cards do
if i%2==0 then
lp.setColor(255, 40, 40);
else
lp.setColor(30, 30, 30);
end

lp.push();
lp.rotate(220+(i*220)-220);
lp.rectangle("fill", 100+(i*100)-100, 100-(i*5)-5, 140, 205);
lp.pop();
end
end
``````

It almost works good but the display not the same as the one one the hearthstone.

So the question here is, i guess, how can i reorganize the rotation of the cards whenever a new card added to our hand? or should i put limits like if cards==5 or cards==3 etc.

### Re: Hearthstone-like card hold mechanic?

Posted: Mon Jan 21, 2019 3:59 am
>lp.rotate(220+(i*220)-220);

I would abstract it out; its a trail and error thing and the logic shouldn't be part of the for loop as the third card in the hand of three shouldn't be rotated the same as the third card in the hand of 10.

I would write two different functions, hand_draw_logic() that setups some global variables with the knowledge of how many cards there are, and a second draw_card(), the references those global variables but handles whatever card logic thing you need and simply takes its number position

### Re: Hearthstone-like card hold mechanic?

Posted: Mon Jan 21, 2019 5:36 am
my take

still needs some y angle hacking as well as a smarter rotation but have fun i always hated frame stacking logic

pay attention to the units of the lib your using, you made 2 bugs from ignoring the api.

### Re: Hearthstone-like card hold mechanic?

Posted: Mon Jan 21, 2019 10:44 am
nikneym wrote:
Mon Jan 21, 2019 2:17 am

Code: Select all

``````		lp.rotate(220+(i*220)-220);
``````