The first text game in actionscript3.0 language [people in the ages]

Source: Internet
Author: User

 

/* The first text game in the actionscript3.0 language [the Man of the ages is in the rivers and lakes]
Author: KKK
Date: 2010-07-22
Function.
HONG Xing's other handsome fit guy, Jin Kun, plans to attack John B to help Chen haonan fight for death and death.
At the end of the war, today is not your death or my death
*/
VaR hero: Object = new object ();
VaR BOSS: object = new object ();

Hero. Name = "@ Chen haonan @";
Hero. HP = 100; // life value
Hero. ATT = 90; // Attack Strength
Hero. Def = 88; // defensive capability
Hero. AgI = 60; // agility
Hero. skill1 = "Fist ";
Hero. skill2 = "Tie chain ";
Hero. skill3 = "steel pipe ";

Boss. Name = "# Kun #";
Boss. HP = 120; // life value
Boss. ATT = 92; // Attack Capability
Boss. Def = 90; // defensive strength
Boss. AgI = 22; // agility
Boss. skill1 = "fliggy ";
Boss. skill2 = "Knife ";
Boss. skill3 = "Machete ";

VaR Timer: timer = new timer (1000 );
// Send an event at an interval of 1000 milliseconds
Timer. addeventlistener (timerevent. Timer, round );
// Listen for events
Timer. Start ();

Function whoattacks (A: object, B: Object): Array {
Return A. AgI * Math. Random ()> B. AgI * Math. Random ()? [A, B]: [B, a];
}

Function round (E: timerevent): void {
VaR damage: number;
VaR skillindex: uint;
VaR roundfight: array = whoattacks (hero, boss );
VaR attacker: Object = roundfight [0];
VaR defender: Object = roundfight [1];
Damage = attacker. ATT * Math. Random ()-defender. Def * Math. Random ();
If (damage <= 0 ){
Damage = 0;
} Else {
Damage = math. Ceil (DAMAGE );
// The damage value is rounded up.
}
Defender. HP-= damage;
If (damage <attacker. ATT/3) {// select the attack mode based on the Damage Value
Skillindex = 1;
} Else if (damage <attacker. ATT * 2/3 ){
Skillindex = 2;
} Else {
Skillindex = 3;
}
 
Trace (attacker. Name + "" + defender. Name + "" +
Attacker ["skill" + skillindex] + "," + defender. Name +
"Loss" + damage + "Point HF ");
If (defender. HP <= 0 ){
Trace (defender. Name + "Top 5, down \ n" + attacker. Name +
"Win ");
Timer. removeeventlistener (timerevent. Timer, round );
// Remove the listener

Trace ("\ Ngame over ");
Return;
// Exit the program

}
 
Trace (hero. Name + "HP:" + hero. HP + "\ t" +
Boss. Name + "HP:" + boss. HP + "\ n ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.