Help with action script number guessing game
can someone help me in flash cs6 to make a simple guessing game, i just need help with the coding. making a guessing game from 1-100
The constructor is coded to assign a random number for
the user to guess
• In the section of code indicated by the comments
(within the handler function doGuess()), write condition
statements that guide the user to guessing the number
using text written to the output
• Trace out the users' guess, plus a message
• Messages for the user depending how close they are from the
guess, condition each of the following:
• Guesses correctly, +/-1 from the guess, +/-10 from the guess,
+/-20 from the guess, +/-40 from the guess, all other guesses
close, it's actually an in class practice lab. After doing this we have to do another one that needs to be submitted. I just need help with the coding for this because i dont know how to start at all. let alone the actual lab.
Similar Messages
-
Help with action script please
hay guys, im having trouble with changing my action script to
allow multiple layers of the same thing in order to show a greater
sense of depth than the normal application. im using a flash
toutorial on making a sort of matrix like falling text (
link)
and im not completely understanding what to change in order to
accomplish my goal. i tryed to send them a message using their
contact page, but its broken, forcing me to find a forum. im sure
it has something to do with the third group of code where it
identifies what its using. but whenever i change anything there to
either match the identifiers or movie clip names the action script
crashes when i test the movie. any help is appreciated.
im using flash cs3 and made sure to create it all in action
script 2.0
please excuse my spelling, im sure i made a mistake
somewhere."FlashTastic" <[email protected]> wrote in
message news:e4ir4t$ru4$[email protected]..
>I don't think an enterframe will be your best bet.
>
> You might want to use something like
>
> if(_root._currentframe >= _root.totalframes){
> loadMovie("myMovie.swf",_root)
Why in the world would you do that when you can just put a
keyframe on the last frame and ..
loadMovie("myMovie.swf");
tralfaz -
Help with Action script 2.0 please
Hi,
I am new to actionscript and i could really do with some help
please. I am trying to load external movie clips into two different
containers depending on which button is clicked. Sometimes there
may be two conatiners attached to a buuton click, whilst other
buttons may only need to load one movie clip. Here is the action
script i have been using:
button1.onPress = function () {
_root.createEmptyMovieClip("container", 1);
_root.createEmptyMovieClip("container1", 2);
unloadMovie("container1");
loadMovie("scene2.swf", "container");
loadMovie("scene5.swf", "container1");
container._x = 50 ;
container._y = 110 ;
container1._x = 170 ;
container1._y = 5 ;
button2.onPress = function () {
loadMovie("scene6.swf", "container");
unloadMovie("container1");
container._x = 50 ;
container._y = 110 ;
This does load the movies, however i have to press button one
first before button two will work. Ideally i need to be able to
call any movieclip at any time. Can anyone tell me where i am going
wrong?quote:
Originally posted by:
NedWebs
Try moving these lines outside of the button function:
_root.createEmptyMovieClip("container", 1);
_root.createEmptyMovieClip("container1", 2);
You can use "this" instead of "_root"... that'll save any
problem if you ever move this within some other movie. Also, move
the x/y assignments just under those lines since they relate to
them directly.
Hey thankyou for your help, that works now. although if i
move the x and y assignments i would have to create another
container right? Thanks again for your help. -
Help with action script 2.0
I'm a beginner with flash. I created a flash file on my own.
I also created a flash file using a slideshow program. Generally I
like this program. I can insert them into my html with no problem.
I want to load the slideshow.swf file into an empty movie
clip in the flash file I created called products.swf. It works fine
using
loadMovie("slideshow.swf", call_mb_slideshow); (where
call_mb_slideshow is a empty movieclip.)
as long as the all the files are in the same folder. But, I
need the products.swf file with the empty movieclip to be in the
parent folder AND I need the slideshow.swf and the slideshow.xml
file to be in a child folder call musicbox_slideshow. When I change
the code to this:
loadMovie("musicbox_slideshow/slideshow.swf",
call_mb_slideshow);
It loads the slideshow.swf file into the movieclip fine, BUT
it doesn't know where to find the slideshow.xml file that loads the
pictures into the slideshow. It looks for it in the parent folder,
not the child folder.
How do I write the script in products.swf so that it knows
where the slideshow.xml file is? I cannot change the slideshow.swf
file code in any way. I need to do it from products.swf.I can use this code from html. I'm able to say where the swf
and xml file are. I just don't know how to do this using action
script.
<object
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="
http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
width="768" height="576" id="tech" align="middle">
<param name="movie"
value="slideshow.swf?xml_path=musicbox_slideshow/slideshow.xml"
/>
<param name="quality" value="high" />
<embed
src="slideshow.swf?xml_path=musicbox_slideshow/slideshow.xml"
quality="high" width="768" height="576" name="tech" align="middle"
allowScriptAccess="sameDomain" type="application/x-shockwave-flash"
pluginspage="
http://www.macromedia.com/go/getflashplayer"
/>
</object>. -
I have been developing a site and I am having issues with
something that is probably very simple. I have created several
movieclips that expand and contract as you roll over them. I wanted
to make a function/method so that when the user clicks, it takes
them to another scene in this movie. Here is the action script I am
using:
on(release) {
gotoAndPlay("Scene 9");
Unfortunately, this is not working. I thought that perhaps
the on(release) method wouldn't work on these movie clips based on
the action script I was already using to expand/contract the boxes,
but the following code works just fine:
on(release) {
getURL("home.html");
I'm stumped. Can anyone offer a suggestion as to what I
should do? Here is the web address of the page I'm working on, it
has the movie I'm having an issue with.
AndrewJW.com. The
first image on the left next to the word photography links to
another page of the site. The image of the pearl ring next to that
is the one that will not advance to another scene in the movie.
Thanks for any and all input.
AndrewJeckyl>
erm... ok i've to admit my mistake in 2nd script.
_root.gotoAndPlay() takes only ONE argument,
_root.gotoAndPlay("Scene 9", 1); won't works.
Thank for reminding me
actually this make me confuse sometime,
from the code hint in flash,
for
gotoAndPlay,
gotoAndPlay(
frame);
gotoAndPlay(
scene,
frame);
for
MovieClip.gotoAndPlay,
MovieClip.gotoAndPlay(
frame);
so, gotoAndPlay can accept 2 arguments only when use without
"something dot" in front.
if Andrew's script is attached to an instance of button
symbol, we can use
on(release) {
gotoAndPlay("Scene 9", 1);
Since Andrew will attach the script to an instance of
movieclip, he can only use:
on(release) {
gotoAndPlay("Scene 9");
where he have to give the label to the 1st frame of "Scene 9"
same name with the scene.
Am i right Jeckyl?
I heard many people said "scene"+"script"="buggy", but some
time I get it "works". What is your opinion? -
Help with action script to load image
I have a Fla file that is works to slide open doors from
button hit and open sliding doors, but I cannot get an image to
load and display when the door begins to open, can some please
help. I can send th fla file for viewing.I did modify the script. My images were in Adobe RGB (1998) and I modified the script to match them from that to the costco printer one. The images were changed as by looking at the screen, by printing to costco, and looking at the new profile assigned. But they didn't look the same on the screen or printed as those from either Preview or ColorSyncUtility.
I finally wrote a 'shortcut' in iKey to just change all the open images in ColorSync Utility.
Note: Graphic Converter might work. It does change the image on the screen but I haven't printed it. The screen does not look the same as ColorSyncUtility, It does not give you the choice of intent either. -
Help with Action script, experts needed!
Hi, I have a website just put up today, all I need is advice, or better still, someone who can write these actionscripts for my site. Basically, I need to put into function, the three grey buttons, Print/ecard/Download on the lower right portion of the panel. Thanks in advance, I'll buy you coffee
JT
my site: http://www.jetpixels.comquote:
Originally posted by:
NedWebs
Try moving these lines outside of the button function:
_root.createEmptyMovieClip("container", 1);
_root.createEmptyMovieClip("container1", 2);
You can use "this" instead of "_root"... that'll save any
problem if you ever move this within some other movie. Also, move
the x/y assignments just under those lines since they relate to
them directly.
Hey thankyou for your help, that works now. although if i
move the x and y assignments i would have to create another
container right? Thanks again for your help. -
Need help with " Number guessing game " please?
This is what teacher requires us to do for this assignment:
Write a program that plays a simple number guessing game. In this game the user will think of a number and the program will do the guessing. After each guess from the program, the user will either indicate that the guess is correct (by typing �c�), or that the next guess should be higher (by typing �h�), or that it should be lower (by typing �l�). Here is a sample output for a game. In this particular game the user thinks of the number 30:
$java GuessingGameProgram
Guess a number between 0 and 100
Is it 50? (h/l/c): l
Is it 25? (h/l/c): h
Is it 37? (h/l/c): l
Is it 31? (h/l/c): l
Is it 28? (h/l/c): h
Is it 29? (h/l/c): h
Is it 30? (h/l/c): c
Thank you for playing.
$
This program is implementing a binary search algorithm, dividing the range of possible values in half with each guess. You can implement any algorithm that you want, but, all things being equal, binary search is the best algorithm.
Write the program so that the functionality is split between two classes: GuessingGameProgram, and NumberGuesser.
GuessingGameProgram will only be used for its main function. It should instantiate a NumberGuesser, and it will be responsible for the loop that notifies the user of the next guess, reads the �h�, �l�, or �c� from the user, and sends an appropriate message to the number guesser accordingly.
The guesses themselves should all be generated by the NumberGuesser class. Here is a diagram of the members and methods for the class. Notice that the members are unspecified. Feel free to give your NumberGuesser class any members (which we have also been calling fields, or instance variables) that you find useful. Make them all private.
NumberGuesser
NumberGuesser(int upperLimit, int lowerLimit)
int guess()
void higher()
void lower()
The constructor should take two integer arguments, a lower and upper bound for the guesses. In your program the constructor will be called with bounds of 0 and 100.
The guess method should return the same value if it is called more than once without intervening calls to the lower or higher methods. The class should only change its guess when it receives a message indicating that its next guess should be higher or lower.
Enjoy. Focus your attention on the NumberGuesser class. It is more interesting than the GuessingGameProgram class because it is a general-purpose class, potentially useful to anybody who is writing a number guessing game. Imagine, for instance, that a few weeks from now you are asked to write a number guessing game with a graphical Java Applet front end. If you NumberGuesser class is well written, you may be able to reuse it without any modifications.
I'm new to JAVA and I'm set with my 2nd homework where I'm so confused. I know how to do something of this source in C language, but I'm a bit confused with Java. This is the code me and my classmate worked on, I know it's not 100% of what teacher asked, but is there any way possibly you guys could help me? I wrote this program if the game is played less then 10 times, thought I would then re-create a program without it, but now I'm confused, and my class book has nothing about this :( and I'm so confused and lost, can you please help? And out teacher told us that it's due the end of this week :( wish I knew what to do. Thank you so so much.
Here's the code:
import java.text.*;
import java.io.*;
class GuessingGame
public static void main( String[] args ) throws IOException
BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ) );
int guess = 0, limit = 9, x = 0, n, a = 0 ;
double val = 0 ;
String inputData;
for ( x = 1; x <= 10; x++) //number of games played
System.out.println("round " + x + ":");
System.out.println(" ");
System.out.println("I am thinking of a number from 1 to 10. ");
System.out.println("You must guess what it is in three tries. ");
System.out.println("Enter a guess: ");
inputData = stdin.readLine();
guess = Integer.parseInt( inputData );
val = Math.random() * 10 % limit + 1; //max limit is set to 9
NumberFormat nf = NumberFormat.getNumberInstance();
nf.setMaximumFractionDigits(0); //format number of decimal places
String s = nf.format(val);
val = Integer.parseInt( s );
for ( n = 1; n <= 3; n++ ) //number of guess's made
if ( guess == val)
System.out.println("RIGHT!!"); //if guess is right
a = a + 1;
System.out.println("You have won " + a + " out of " + x + " rounds");
System.out.println(" ");
n = 3;
continue;
if (n == 3 && guess != val) //3 guesses and guess is wromg
System.out.println("wrong");
System.out.println("The correct number was " + val);
System.out.println("You have won " + a + " out of " + x + " rounds");
System.out.println(" ");
continue;
//how close guess is to value
if ( guess == val - 1 || val + 1 == guess) //Within 1
System.out.println("hot");
else if ( guess == val - 2 || val + 2 == guess) // Within 2
System.out.println("warm");
else
System.out.println("cold"); // Greater than 3
inputData = stdin.readLine();
guess = Integer.parseInt( inputData );
//ratings
if ( a <= 7)
System.out.println("Your rating is: imbecile.");
else if ( a <= 8)
System.out.println("Your rating is: getting better but, dumb.");
else if (a <= 9)
System.out.println("Your rating is: high school grad.");
else if ( a == 10)
System.out.println("Your rating is: College Grad.!!!");Try this.
By saying that, I expect you ,and your classmate(s), to study this example and then write your own. Hand it in as-is and you'll be rumbled as a homework-cheat in about 20ms ;)
When you have an attempt where you can explain, without refering to notes, every single line, you've cracked it.
Also (hint) comment your version well so your tutor is left with the impression you know what you're doing.
In addition (huge hint) do not leave the static inner class 'NumberGuesser' where it is. Read your course notes and find out where distinct classes should go.
BTW - Ever wonder if course tutors scan this forum for students looking for help and/or cheating?
It's a double edged sword for you newbies. If you ask a sensible, well researched question, get helpful answers and apply them to your coursework, IMHO you should get credit for doing that.
On the other hand, if you simply post your assignment and sit there hoping some sucker like me will do it for you, you should be taken aside and given a good kicking - or whatever modern educational establishments consider appropriate abmonishment ;)
I'd say this posting is, currently, slap bang between the two extreemes, so impress us. Post your solution in the form you intend to hand it in, and have us comment on it.
Good luck!
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class GuessingGame
public static void main(String[] args)
throws Exception
BufferedReader reader= new BufferedReader(
new InputStreamReader(System.in));
NumberGuesser guesser= new NumberGuesser(0, 100);
System.out.println(
"\nThink of a number between 0 and 100, oh wise one...");
int guess= 0;
while (true) {
guess= guesser.guess();
System.out.print("\nIs it " +guesser.guess() +"? (h/l/c) ");
String line= reader.readLine();
if (line == null) {
System.out.println(
"\n\nLeaving? So soon? But we didn't finish the game!");
break;
if (line.length() < 1) {
System.out.println("\nPress a key, you muppet!");
continue;
switch (line.toLowerCase().charAt(0)) {
case 'h':
guesser.higher();
break;
case 'l':
guesser.lower();
break;
case 'c':
System.out.println("\nThank you for playing.");
System.exit(0);
default:
System.out.println(
"\nHow hard can it be? Just press 'h' 'l' or 'c', ok?");
continue;
if (guess == guesser.guess()) {
System.out.println(
"\nIf you're going to cheat, I'm not playing!");
break;
private static class NumberGuesser
private int mLower;
private int mUpper;
private int mGuess;
NumberGuesser(int lowerLimit, int upperLimit)
mLower= lowerLimit;
mUpper= upperLimit;
makeGuess();
private void makeGuess() {
mGuess= mLower + ((mUpper - mLower) / 2);
int guess() {
return mGuess;
void higher()
mLower= mGuess;
makeGuess();
void lower()
mUpper= mGuess;
makeGuess();
} -
AC3 help (number guessing game)
Hello I have a problem, im fairly new to action script and flash in general but heres my code:
//These are the variables.
var beginMessage:String;
var randomNumber:uint;
var guess:uint;
//It disables the play again button so only the guess button is usable.
playagain_btn.enabled =false;
guess_btn.enabled = true;
//shows a message in the message_txt box.
beginMessage="Choose a number between 1 - 100.";
message_txt.text=beginMessage;
//Basically only allows numbers between 0-9...
input_txt.restrict="0-9";
input_txt.text="";
//This stores a random number between 100 and 1.
randomNumber = Math.floor(Math.random() * 100 + 1);
//Adds an event listener to the guess button.
guess_btn.addEventListener(MouseEvent.CLICK, yourGuess);
function yourGuess(event:MouseEvent):void {
guess=uint(input_txt.text);
//This checks if the guessed number is greater than the random number.
if (guess > randomNumber) {
message_txt.text = "Your guess, " + guess + " is too damn high.";
//This checks if the guessed number is lower than the random number.
else if (guess < randomNumber) {
message_txt.text = "Your guess, " + guess + " is too low.";
//This displays a message when the correct number is guessed.
else{
message_txt.text = "congratulations ,the number is " + randomNumber + ".";
winGame();
function winGame():void{
//Disables the guess button and enables the play again button.
guess_btn.enabled = false;
playagain_btn.enabled = true;
//This removes a listener from the yourguess button and adds a
//listener to playagain
guess_btn.removeEventListener(MouseEvent.CLICK, yourGuess);
playagain_btn.addEventListener(MouseEvent.CLICK, guessAgain);
function guessAgain(event:MouseEvent):void{
//Runs the init() method.
init();
//Runs the init() method.
init();
//this part of the script is for the number
//Declare variables
var numOfGuesses:uint ;
var numOfGuessesMessage:String;
function init():void {
//Displays a message showing the total number of guessing remaining
numOfGuesses = 6;
numOfGuessesMessage = " Guesses remaining";
guess_txt.text = numOfGuesses + numOfGuessesMessage;
if(numOfGuesses == 0){
message_txt.text = "The number was " + randomNumber + ".";
guess_txt.text = "you lose!!!!!! D:!!.";
winGame();
function yourGuess(event:MouseEvent):void {
guessMessage();
function guessMessage():void{
//Only decrement the numOfGuesses if the text field contains characters.
if(input_txt.length > 1 && numOfGuesses != 0){
numOfGuesses--;
guess_txt.text = numOfGuesses + numOfGuessesMessage;
And my errors are duplicate function definition. theres the code its crying about.
function yourGuess(event:MouseEvent):void {
guessMessage();
what Im doing here is making a number guessing game, everything works but the number of guesses wont go down.Put a trace in the function where you try to decrease the number of guesses and see if the logic is letting you get in to change it...
function guessMessage():void {
//Only decrement numofGuess if the input field has characters.
trace(input_txt.length, numOfGuesses)
if(input_txt.length > 1 && numOfGuesses != 0){
numOfGuesses--;
guess_txt.text = numOfGuesses + numOfGuessesMessage;
//When guesses have ran out, A message will appear saying you can reset.
if(numOfGuesses == 0){
message_txt.text = "The number I was thinking was " + randomNumber + ".";
guess_txt.text = "Press play again to try again";
winGame(event:MouseEvent);
If you happen to be changing frames where you leave the frame with this code and then come back to it, then you are likely running into this line again....
numOfGuesses = 6;
which resets the number of guesses. -
I need help with my serial number. I downloaded soundbooth cs3 to restore my downloaded purchase, but my serial number is not being accepted. I have 16 more days to resolve this. I don't need tech support, I just need the software I purchased to work for me. That's not to much to ask, is it? Can anyone from adobe help me please?
ChrisError "The serial number is not valid for this product" | Creative Suite
-
this is my current code it works ok, but i need a bit of help with when they get it right, and I have to start converting it to graphical in Borland Jbuilder.
import java.io.*;
import java.util.*;
public class Numb{
public static void main (String [] args){
//Game State
int magicNumb = Math.abs(new Random().nextInt() % 100) + 1;
//Output instructions
System.out.println("I Feel Numb!");
System.out.print("Do you feel Loved? Y/N");
//Read from input
InputStreamReader inStream = new InputStreamReader(System.in);
BufferedReader keyboard = new BufferedReader(inStream);
String line = null;
try{
line=keyboard.readLine();
}catch(IOException ioe){}
boolean acrobat = true;
//If they pressed y let them play
if(line.equalsIgnoreCase("y")){
//Game stuff goes here
System.out.println("Don't Expect Suggest a NUMBer between 1 and 100");
System.out.print("Enter a guess:");
//LOOP
while (acrobat=true){
//Read user input
{try{
line=keyboard.readLine();
}catch(IOException ioe){}
//Convert the inpt to an int value
int guess = (int)Integer.parseInt(line);
//If Right
if (guess==magicNumb)
System.out.println("Green Light Seven Eleven You stop in for a pack of cigaretes");
acrobat=false;
//If too High
if (guess>magicNumb)
System.out.println("Too Much is Not Enough");
//If too Low
if (guess<magicNumb)
System.out.println("Gimme Some more, Gimme some more");}
}Ok what i need help with is when they get the
integer, i need to either state another message and
quit, or give them the option to play again?Okay, so, your overall code structure will look something like this: do {
play();
again = askIfPlayAgain();
} while again;
void play() {
do {
ask for a guess
give answer
} while (incorrect);
} You don't have to use do/while. Plain old while will work.
The main points are:
1) You need two loops. The inner one keeps going within one round until they guess correctly, and the outer one keeps starting new rounds until they quit.
2) You should break the problem down into smaller, more elemental pieces, rather than stuffing everything into one big blob in main.
#1 will help you solve this problem, but #2 is an absolutely essential skill to learn. -
Help with two scripts - Mounting remote DMG and Checking which network I'm connected to
Hey guys, I need some help with two separate scripts:
1. The first script I'm trying to create to mount a DMG stored remotely on another Mac using an AppleScript or shell script. Using the following:
set cmd to "hdiutil mount 'afp://username:[email protected]/Lion/Users/username/Desktop/Test.sparseim age'"
do shell script cmd
results in the following error:
error "hdiutil: mount failed - not recognized" number 1
I'm not very experienced regarding AppleScript or using hdiutil, could somebody point out what's wrong with my script?
2. The second script I'm working on to try and essentially prevent the 'Could Not Find Server' Finder dialog when a network mount is unavailable. I guess what I'd like it to do is detect which network I'm connected to, and if I'm connected to the correct network, then mount the shares, otherwise just fail silently without any errors. From the searching I've done, using try statements should do this, but they do not, and I'm still presented with an error dialog after the server cannot be found.
Does anybody have any suggestions on this script? Also, I've seen some tips regarding detecting which wireless network the Mac is connected to, which could work, but what about when connected via Ethernet?
Thanks!Edit: I need to clarify on my first script request:
I need to mount the DMG on the remote Mac, not on the Mac I'm running the script from. -
Problem with action script calculations
I have a simple action script 3 code that will not calculate the correct answer on my PC. I'm running flash cs5 on Window 7 OS. I can move the file to another machine running flash cs4 and it works, but when I run it on my laptop, I get funky answers. see cold below. I have uninstalled and reinstalled cs5 , run the cleanscript for cs5 and cs4 to make sure everything was removed. I have uninstalled and reinstalled flash player. but nothing seems to work. Any help will be appreciated. It acts like Action Script 3 is corrupt or something else that related to Action Script 3. Everything else seems to work. I also have a preloader running with the same issue. It is should be showing the percentage completed but it go 2 5 50 4 32 or something funky like that. Please help.
the code I'm using.
function calculateTotal(evtObject:MouseEvent):void {
var price:Number;
var totalCost:Number;
var numberOfJerseys:Number;
if (jerseyType.text == "2") {
price = 12;
if (jerseyType.text == "1") {
price = 10;
if (playerNames.text == "Y" || playerNames.text == "y") {
price += 1.50;
numberOfJerseys = int(numberOfPlayers.text) +int(numberOfCoaches.text);
totalCost = numberOfJerseys*price;
total.text = String(totalCost);
calc_btn.addEventListener(MouseEvent.CLICK, calculateTotal);
the preloader percentage is
var percent:int = amtLoaded*100
percent_txt.text = String(percent);HELLO,
just check navigateToURL() -
I need help with shooting in my flash game for University
Hi there
Ive tried to make my tank in my game shoot, all the code that is there works but when i push space to shoot which is my shooting key it does not shoot I really need help with this and I would appriciate anyone that could help
listed below should be the correct code
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
listed below is my entire code
import flash.display.MovieClip;
//declare varibles to create mines
//how much time before allowed to shoot again
var cTime:int = 0;
//the time it has to reach in order to be allowed to shoot (in frames)
var cLimit:int = 12;
//whether or not the user is allowed to shoot
var shootAllow:Boolean = true;
var minesInGame:uint;
var mineMaker:Timer;
var cursor:MovieClip;
var index:int=0;
var tankMine_mc:MovieClip;
var antiTankmine_mc:MovieClip;
var maxHP:int = 100;
var currentHP:int = maxHP;
var percentHP:Number = currentHP / maxHP;
function initialiseMine():void
minesInGame = 15;
//create a timer fires every second
mineMaker = new Timer(6000, minesInGame);
//tell timer to listen for Timer event
mineMaker.addEventListener(TimerEvent.TIMER, createMine);
//start the timer
mineMaker.start();
function createMine(event:TimerEvent):void
//var tankMine_mc:MovieClip;
//create a new instance of tankMine
tankMine_mc = new Mine();
//set the x and y axis
tankMine_mc.y = 513;
tankMine_mc.x = 1080;
// adds mines to stage
addChild(tankMine_mc);
tankMine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal(evt:Event):void{
evt.target.x -= Math.random()*5;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseMine();
//declare varibles to create mines
var atmInGame:uint;
var atmMaker:Timer;
function initialiseAtm():void
atmInGame = 15;
//create a timer fires every second
atmMaker = new Timer(8000, minesInGame);
//tell timer to listen for Timer event
atmMaker.addEventListener(TimerEvent.TIMER, createAtm);
//start the timer
atmMaker.start();
function createAtm(event:TimerEvent):void
//var antiTankmine_mc
//create a new instance of tankMine
antiTankmine_mc = new Atm();
//set the x and y axis
antiTankmine_mc.y = 473;
antiTankmine_mc.x = 1080;
// adds mines to stage
addChild(antiTankmine_mc);
antiTankmine_mc.addEventListener(Event.ENTER_FRAME, moveHorizontal);
function moveHorizontal_2(evt:Event):void{
evt.target.x -= Math.random()*10;
if (evt.target.x >= stage.stageWidth)
evt.target.removeEventListener(Event.ENTER_FRAME, moveHorizontal);
removeChild(DisplayObject(evt.target));
initialiseAtm();
function moveForward():void{
bg_mc.x -=10;
function moveBackward():void{
bg_mc.x +=10;
var tank_mc:Tank;
// create a new Tank and put it into the variable
// tank_mc
tank_mc= new Tank;
// set the location ( x and y) of tank_mc
tank_mc.x=0;
tank_mc.y=375;
// show the tank_mc on the stage.
addChild(tank_mc);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onMovementKeys);
//creates the movement
function onMovementKeys(evt:KeyboardEvent):void
//makes the tank move by 10 pixels right
if (evt.keyCode==Keyboard.D)
tank_mc.x+=5;
//makes the tank move by 10 pixels left
if (evt.keyCode==Keyboard.A)
tank_mc.x-=5
//checking if the space bar is pressed and shooting is allowed
if(evt.keyCode == 32 && shootAllow){
//making it so the user can't shoot for a bit
shootAllow = false;
//declaring a variable to be a new Bullet
var newBullet:Bullet = new Bullet();
//changing the bullet's coordinates
newBullet.y = tank_mc.y + tank_mc.width/2 - newBullet.width/2;
newBullet.x = tank_mc.x;
//then we add the bullet to stage
addChild(newBullet);
if (tank_mc.hitTestObject(antiTankmine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(antiTankmine_mc);
if (tank_mc.hitTestObject(tankMine_mc))
//tank_mc.gotoAndPlay("hit");
currentHP -= 10;
// remove anti tank mine
removeChild(tankMine_mc);
//var maxHP:int = 100;
//var currentHP:int = maxHP;
//var percentHP:Number = currentHP / maxHP;
//Incrementing the cTime
//checking if cTime has reached the limit yet
if(cTime < cLimit){
cTime ++;
} else {
//if it has, then allow the user to shoot
shootAllow = true;
//and reset cTime
cTime = 0;
function updateHealthBar():void
percentHP = currentHP / maxHP;
healthBar.barColor.scaleX = percentHP;
if(currentHP <= 0)
currentHP = 0;
trace("Game Over");
updateHealthBar();USe the trace function to analyze what happens and what fails to happen in the code you showed. trace the conditional values to see if they are set up to allow a shot when you press the key
-
I need help with this script please ASAP
So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
The script (Sorry if it's a bit long):
#------------Startup-------------
display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
set Lolz to (button returned of the result)
if Lolz is "Cyaaaa" then
killapp()
else if Lolz is "Take the Quiz" then
do shell script "say -v samantha Ok starting in 3…2…1…GO!"
#------------Question 1-----------
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 2--------
display dialog "Most children were taught
to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------------Question 3---------
display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
set A3 to (button returned of the result)
if A3 is "Great Awakening" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-----------Question 4--------
display dialog "_______ was
a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
set A4 to (button returned of the result)
if A4 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 5-------
display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
set A5 to (button returned of the result)
if A5 is "Land" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 6--------
display dialog "The first step toward guaranteeing these rights came in 1215. That
year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
set A6 to (button returned of the result)
if A6 is "Magna Carta" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 7--------
display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
set A7 to (button returned of the result)
if A7 is "Parliament" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 8-----
display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
set A8 to (button returned of the result)
if A8 is "King James II" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 9------
display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
set A9 to (button returned of the result)
if A9 is "William/Mary/Glorius Revolution" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 10-----
display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
set A10 to (button returned of the result)
if A10 is "Rights" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 11------
display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
set A11 to (button returned of the result)
if A11 is "Ohio" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------Question 12---------
display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
set A12 to (button returned of the result)
if A12 is "George Washington" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 13-------
display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
set A13 to (button returned of the result)
if A13 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 14------
display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
set A14 to (button returned of the result)
if A14 is "" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-------Question 15-------
display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
set A15 to (button returned of the result)
if A15 is "Command an attack against French" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------TheLolQuestion-----
display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
set LOOL to (button returned of the result)
if LOOL is "Mr.White" then
do shell script "say -v samantha Congratulations…you…have…common…sense"
else
do shell script "say -v alex Do…you…have…eyes?"
#------END------
display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
set endmenu to (button returned of the result)
if endmenu is "I did!" then
do shell script "say -v samantha Your awesome"
else
do shell script "say -v alex Go outside and run a lap"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end ifUse code such as:
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
#----------Question 2--------
display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
(90444)
Maybe you are looking for
-
Hello Gurus I have a sales order with 5 items, the requirement is suppose all the the 8 items have different delivery dates eg: item 1 - 06.01.2009, item 2 - 15.02.2009, item 3 - 03.03.2009, item 4 - 25.01.2009, item 5 - 03.02.2009. The need is i wa
-
Itunes set up wont open. Windows 7
I downloaded the reccomended Itunes64setup.exe. However when I try to click on it to open it a error message dispaying 'itunes64setup.exe in not a valid win32 application.' I have a brand new computer and according to my box it is running Windows 7 6
-
Running report in concurrent manager using unix shell script to create PDF
Hi, I need help urgently, we are in the process of migrating from 10.7 to 11i. My problem is we have a report created in 10.7 that is ran through concurrent manager using shell scripts(host) and the output is stored as .pdf, in 10.7, it works perfect
-
I have an "Indent" question. How do create the following format in Pages? I want the subsequent text after the first indent to indent automatically and then turn off when I hit a double space for the next speaker. Is this possible? Example: Thomas
-
Have just purchased a beast of a Mac Pro. Will be using this for editing a feature film. Problem is I need to buy and download Adobe Premiere Pro. My internet speed in the office is abysmal and it would take forever to download. Thats why I was thin