cloneindex: from beginnning or end?

You must understand the Game Editor concepts, before post here.

cloneindex: from beginnning or end?

Postby Killagram » Thu Sep 25, 2008 12:28 pm

I have been trying to make a card game with a deal and a shuffle option and each time i run the game without shuffling i get a different result. Sometimes the deck starts with Kings and descends and sometimes it starts with Aces and ascends. Is there any way to control the clone order or is it random each time? Starting at 0 and starting at 51 are two very different things!
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
-Brian W. Kernighan
User avatar
Killagram
 
Posts: 31
Joined: Sun Aug 10, 2008 8:49 pm
Score: 5 Give a positive score

Re: cloneindex: from beginnning or end?

Postby Kalladdolf » Thu Sep 25, 2008 1:03 pm

here's how I would do it:
create an actor variable ("order").
Code for every card on draw actor:
Code: Select all
ChangeZDepth("Event Actor", order/10);

Now you can control every individual card by using the "order" variable (...) .
To shuffle the cards:
Card -> Create Actor -> Script editor ->
Code: Select all
order = rand(10); // 0 is at the bottom of the pile, 10 is at the front.

Also this has the advantage that you can change the order of the card right in the middle of the game (depending on what you do with it).
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: cloneindex: from beginnning or end?

Postby Killagram » Thu Sep 25, 2008 1:16 pm

well the shuffle part was relatively easy (ChangeZDepth("Event Actor", rand(52)/100) but i can't count on the order of the cloneindex so i can't use any arrays or structs on it that's my problem.....
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."
-Brian W. Kernighan
User avatar
Killagram
 
Posts: 31
Joined: Sun Aug 10, 2008 8:49 pm
Score: 5 Give a positive score

Re: cloneindex: from beginnning or end?

Postby Thanx » Sat Sep 27, 2008 1:48 pm

It's not supposed to be randomly picking the clone order. In my stratagy games everything works just fine. The first tile is always 0, and they're always in perfect order. Find the problem elsewhere. Maybe there's some code there you don't want which is causing the problem?

What I do when I encounter some wierd bug I don't expect I always go through all the possible places for codes that may be influencing...
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest