Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Scramble cards in animate way

Posted on 2013-11-26
14
Medium Priority
?
407 Views
Last Modified: 2013-11-29
Hello Guys

I have a TflowPanel and some cards on it, I'd like to scramble the cards in a animate way, where the cards could be scrambled as it was change place with another randomly and it is possible to see them floating from a place to another.

Well, I did a kind of scramble only changing the image of the pictures, but nothing visual.

I accept  any animation proposal only to make this more interesting.

Thanks
Alexandre
ScrambleCards.zip
0
Comment
Question by:hidrau
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
14 Comments
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39681299
Made simple example where I animate card following half period of sine. First you must install component TImageWindow (given in another question). I replace all TImage with TImageWindow (dfm as text) in your source. Second, made procedure which move wincontrol object on form. Procedure Scramble will with given two different index of card (Tag value) find object to animate and set new position.

There are parameters to set:
amplitude - how high card goes
step - lower step (from 1..100) - smother animation
delay - delay between two frames

Have fun!
ImageWin.zip
ScrambleCards2.zip
0
 
LVL 1

Author Comment

by:hidrau
ID: 39681320
Sinisav, once again, I thank you a lot. I am gonna try it.

Tell me, what delphi version do you use?
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39681392
For this example Delphi 2007.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Author Comment

by:hidrau
ID: 39681442
For my application, I use Delphi XE4.

I have used for a long time Delphi 7, but now, I am using it only at my job.

I don't like delphi 7 anymore. After working with Delphi XE4, I don't want to work with D7 in my applications.

Have you tried XE4?
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39681472
I work on XE3 too. My example should work on newer versions. Maybe some uses stuff modification is needed.
0
 
LVL 1

Expert Comment

by:livestuff
ID: 39681724
I think you need some pre-work done first before you do your scrambling. Personally, I would  use a TComponentList to store and maintain  TImages (cards).

You could use one list to store the entire deck and another one to store the current hand (7 random cards)

You can dynamically create your lists at runtime and add your all your images to the deck on start up, then randomly select cards from deck to add to current hand.

The TComponentList provides properties and methods to add, delete, rearrange, locate, access, and sort components (TImages).

From Delphi help " TComponentList controls the memory of its components; unless the OwnsObjects property
is set to false (or the components are removed with the Extract method). TComponentList frees its components
when they are removed from the list or when the TComponentList instance is itself destroyed."

OTTOMH

var
img: TImage;
Deck, Hand: TComponentList;
I: Intger;
card: integer;

Rondomize();

Deck:= TComponentList.Create;
try
 //Add cards to deck
 for I:= 1 to 52 do
 begin
  img:= TImage.Create(nil)
  Img.Loadfromfile('card' + IntToStr(I) + '.jpg'  )'
  Deck.Add(img);
 end;
finally
 Deck.Free
end;

Hand:= TComponentList.Create;
try
 //Add cards to list Hand here
 for I:= 1 to 7 do
 begin
   //Card = random # from 1 to 52
   //select the card from the deck and add it to the Hand
 end;
finally
 Hand.Free
end;

//Now
 Step through your hand and display the cards on your form or FlowPanel
adding the animation you need
0
 
LVL 1

Author Comment

by:hidrau
ID: 39682332
Hello Sinisav,

I tried your code but something went wront, the cards disappeared and only a part of one it was displayed.

Take a loo at the image

The result
0
 
LVL 1

Author Comment

by:hidrau
ID: 39682336
Hello  livestuff,

I need to understand many thing on this area. For example, the code that Sinisav gave me, it is very advanced to me. I don't have a good knowledge on delphi, my work is only with database and reports in Delphi.
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39682884
Strange, I start example in XE3 and same happens. Seems that this flowpanel is changed/broken from D2007. Will look ....
0
 
LVL 28

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 39683409
Found! Problem with double buffering. Another example - this time in XE3 (little closer...)
ImageWin.zip
ScrambleCards3.zip
0
 
LVL 1

Author Comment

by:hidrau
ID: 39683763
Thanks, I am gonna try afterwards.

Sinisav, what book could you recommend me to read where I can reach better knowledge on Delphi and animation? That is, if you know one :)
0
 
LVL 28

Expert Comment

by:Sinisa Vuk
ID: 39684075
Mastering ... books by Marco Cantù are good source - and source code of examples are available too....

More components which can help you, to teach you, are on Torry:
http://www.torry.net/pages.php?id=176
http://www.torry.net/pages.php?id=172
...like TAnimator component.
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 39684407
Worked perfectly friend, thanks very much
0
 
LVL 1

Expert Comment

by:livestuff
ID: 39685742
Sorry, It was Holiday here (Thanksgiving) and I had to go away for a couple of days.
I still think you should have gone the data structure router, bt Im glad you got a solution. I haven't looked at it yet.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Suggested Courses

647 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question