How to make animation actors appear randomly

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

How to make animation actors appear randomly

Postby SanDiego1 » Thu Oct 20, 2005 6:03 pm

I am creating a legal game with questions and answers. I am trying to figure out how to make animation actors appear at random in my game. For example, I have created an animation actor called “Torts.” When “Torts” is clicked with the left mouse, one of four questions (also animation actors) will appear at random. I searched the forum but could not find anything on this issue.

I would appreciate any help. Thanks in advance.
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby makslane » Thu Oct 20, 2005 7:35 pm

To show actors in a random position put htis code in the "Create Actor" event:

xscreen = rand(view.width);
yscreen = rand(view.height);

So, actor xscreen coordinate will be some value between 0 and screen width.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby SanDiego1 » Thu Oct 20, 2005 7:44 pm

Thank you, Makslane. You're the best!
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby SanDiego1 » Thu Oct 20, 2005 7:52 pm

Hi again. Sorry to bother you. I don't want the animation actors to appear in random position. I want them to appear at random. For example, if I hit the "Torts" animation actor with the left key, Question 1 replaces the "Torts" actor. Question 2, 3 & 4 don't appear at all. If I run the game again, the "Torts" actor will be replaced by Question 4. Each time I run the game, "Torts" is replaced by a different question at random. Is there any way to do this? Thank you so much!
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby makslane » Fri Oct 21, 2005 4:09 am

If your Torts actor is a text actor, You can just change the text in the "Create Actor" event.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby SanDiego1 » Fri Oct 21, 2005 1:43 pm

"Torts" is an animation actor.
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby makslane » Fri Oct 21, 2005 5:19 pm

If you need display questions is a good idea use an actor text
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby SanDiego1 » Fri Oct 21, 2005 5:56 pm

The problem is that each question has three possible choices - (a), (b) & (c). Depending on the choice selected by the player (whether it is correct or incorrect), the player gains or loses points. I don't know how to write code so that questions and the three possible choices are drawn at random for each category, allow points to be added and subtracted depending on the choice selected and have the answer appear (with a left click) after the player selects one of the choices. I can figure it out if the question, choices and answer are animation actors. Any help you could provide in this regard would be sincerely appreciated. Thanks.
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby Game A Gogo » Sun Oct 23, 2005 6:19 pm

here a quick way to make random animation:

step1: on draw envent, script editor
Code: Select all
anipos=0+(rand([number of frame minus one]);


thats all :wink:

hope it help
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby SanDiego1 » Sun Oct 23, 2005 8:33 pm

Thank you. Your help is greatly appreciated!
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby SanDiego1 » Mon Oct 24, 2005 2:22 pm

It's me again. I added the code you suggested "animpos = 0 + (rand([frames-1]));" in the draw actor - script event. Now, all the frames in the animation play over and over very quickly. Is there any way to set it so that they will stop on just one? I would like to left click on actor and get random animations in another actor. Thank you!
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby makslane » Mon Oct 24, 2005 10:48 pm

Use the "Change Animation Direction" action to stop the animation.
You can place this action in a "Create Actor" event
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby SanDiego1 » Sat Nov 12, 2005 11:09 pm

Thank you for the help. I finally worked out my problem and thought I would share my solution. I had two actors - player and card. I added multiple animations to the card actor so I could get a random draw. On the player actor, I added a left click event so when the left mouse was clicked the card appeared and the player disappeared. The problem I was having was that I would have to use another event (left click, for example) to get the card to stop on one animation. I wanted random animations (cards) to appear without having to click a mouse, etc. so this didn't work.

Here is how I resolved it.

1. I put the multiple animations in the card actor and set the frame rate at 200 per second.

2. I set an event (left click) to destroy the player and create actor the card.

3. On cards, I created an event - Animation Finish - first animation of card actor) and then added Create Timer as the action. The actor was the card and then I hit new timer.

4. On timer, I set "type" as random and then added 125 for maximum and 10 for minium. I named the timer and then hit OK, add and immediate action.

5. Still in card actor, I went to add events and added Timer. On Timer, I selected the timer I created and hit add action. I then went to Change Animation Direction and selected card and stopped. I then hit add and immediate action.

Now, when I left click player, one of the animations in card comes up at random. I tried using the "animpos=0+(rand(number));" but that didn't seem to work. When I added this code, the method I described didn't work. Having set the animations at a frame rate of 200, it is not necessary to put the random code in.

The only thing I don't like is that there is an extremely brief appearance of other animations when the card is called up with the left click on the player. If I use a lesser max rate on the timer, I found that only a few of the animations appear, for whatever reason. I will play around with the numbers to get it right.

Sorry this is so long. I am new to this software as I'm sure others are. I thought I would explain it in detail if others are trying to do the same thing.
SanDiego1
 
Posts: 20
Joined: Wed Oct 12, 2005 1:08 am
Score: 0 Give a positive score

Postby 4erv' » Sat Aug 18, 2007 4:18 pm

how to make an actor apears only in water, not in the sky? :D
Attachments
examl.JPG
screen :D
Gold Basketball 2008 - the first basketball game made with game editor.

User avatar
4erv'
 
Posts: 188
Joined: Sat Jul 07, 2007 10:52 am
Location: in Recycle Bin
Score: 10 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest