## Hearthstone-like card hold mechanic?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
nikneym
Prole
Posts: 49
Joined: Sat Mar 09, 2013 1:22 pm
Contact:

### Hearthstone-like card hold mechanic?

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.

monkyyy
Citizen
Posts: 52
Joined: Fri Mar 16, 2012 5:29 pm

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

>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

monkyyy
Citizen
Posts: 52
Joined: Fri Mar 16, 2012 5:29 pm

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

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.
Attachments
main.lua

grump
Party member
Posts: 631
Joined: Sat Jul 22, 2017 7:43 pm

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

nikneym wrote:
Mon Jan 21, 2019 2:17 am

Code: Select all

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