A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: [MX04] [Help]Spaceship Game Coding

  1. #1
    Needs help with flash.
    Join Date
    Aug 2007
    Location
    earth
    Posts
    15

    [MX04] [Help]Spaceship Game Coding

    Hi, i'm making one of those spaceship shooter games.
    but i have a few problems,

    1. at the end of the level, you fight this boss, but when you defeat the boss how can you make it that it'll go to the next scene/frame (or something)
    i tried to attempt it with: (if you really wanted to know)

    Code:
    if (boss=dead) gotoAndPlay("2", 1);
    2. You start off in the game with 10 lives. But when you have 0 lives, how do u make the game say game over or something?

    any help would be appreciated thanks.
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    You can make a full shooter but can't deal with simple gotoAndPlay?

    1) So how did you code for your boss to loose life? that's the variable you got to check. Everytime it's hit you go

    Lifeboss -= 5 (or whatever value)

    and if (Lifeboss == 0) bla bla bla

    2) just create a frame or a scene with your gfx "game over" and gotoAndplay it!
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

  3. #3
    Needs help with flash.
    Join Date
    Aug 2007
    Location
    earth
    Posts
    15
    1.
    well actually, i made it that if something hit the boss, the boss would play 1 frame, and the health would play 1 frame, and every frame, the health lowers by 1.
    and did u mean that the
    Lifeboss -= 5
    boss would lose 5 life or would it equal to 5 life?

    2.
    I still don't get it, wouldn't it need some kind of coding that would take it to the frame/scene gameover?

  4. #4
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    1.

    So put in the begining of your game - before it actually starts

    LifeBoss = 50

    then during the game, everytime he's hit:

    LifeBoss -= 5

    which means that the value in "LifeBoss" will decrease of 5 units everytime he's hurt.

    Then check

    if (Lifeboss == 0) { gotoAndPlay (your scene)}

    2.

    It's the same bit of code, when your final boss life is down to zero, then

    if (LifeFinalboss == 0) { gotoAndPlay (your gameoverscene)}

    check "gotoAndPlay" in the help for the exact syntax of what you need because you can go to a specific scene, or a specific frame, or a specific frame in a scene.

    Now, get famous, earn 350 millions and remember me!
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

  5. #5
    Needs help with flash.
    Join Date
    Aug 2007
    Location
    earth
    Posts
    15
    1.
    so i put: lifeboss = 200 (the real amount) in a frame or in the MC? (im assuming the MC)

    and i put: lifeboss -= 3 (wep dmg) into the MC/frame: of the boss
    : of the weapon
    (im assuming the MC of the wep)

    and i also put: if (lifeboss == 0) { gotoAndPlay ("2",1)} into the frame right?

    btw, dont i need to name anything or something (like the instace names)

    2.
    okay... but i was kinda talking about the player u were controlling, not the boss but still, wouldn't i need to name something called "lifefinalboss"?

    P.S. I doubt i'd get a game as Club Penguin and earn 350 mil until MAYBE in the future (still doubt it) cuz this is still kinda my first flash game... but what i CAN do is remember you tho... (which i might so happenly forget lol)

  6. #6
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    1. No you put that info in a frame.

    Usually I have a frame labeled "init" that just set all the variable before anything start.

    BossLife is a variable, it has nothing to do with your mc, and it doesn't matter if your MC has no instance name at all.

    Lets say if you create a button and put this code on it:

    on (press) {

    my_cool_variable += 5
    trace (my_cool_variable)

    }

    then your variable wil increase of 5 each time you press.

    What happened visually on the screen (the damage done) is just a illustration of LifeBoss decreasing.

    So your duty is to have the two happening at the same time (play the next frame animation AND decrease the variable value)

    2. lifefinalboss is just another variable.

    Again just set the original value of it in a frame

    Life = 200

    and then change it in the code on another frame.

    The way you will know your game is finished and it's time to go to the "gameover" screen is when you kill your last boss (I suppose)


    Off course you can choose to name those variables the way you want. Just don't use spaces in the name or anything dodgy like @#%...
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

  7. #7
    Needs help with flash.
    Join Date
    Aug 2007
    Location
    earth
    Posts
    15
    1.
    but shouldnt i put: lifeboss -= 3 into the weapon's MC?
    cuz it was gonna turn out like this:

    Code:
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.BOSS1)) {
    		_root.BOSS1.Play();
    		lifeboss -= 3 
    	}
    }
    2.
    I just decided to have the life as a MC, where if an enemy hits you the life would play(); and if you were to get an extra life, it would go prevFrame(); meaning you'd only have a max of 10 lives.

    3. (new problem)
    i decided to add a store in the game after the boss...
    ur score in the game is the currency in the shop, but then if you bought something too expensive for you (meaning u dont have enough score) your score would go negative, is there anyway to fix that?

    4. (yet another XD)
    in the shops (as told above) you can buy bombs and new weapons, how would i make it that u can use the weapon/bomb only if you've bought it?
    (im okay with the quantity that when u use a bomb, if it touches the player (which it will always do) the bomb would play(); )

  8. #8
    Senior Member
    Join Date
    Apr 2005
    Posts
    467
    1. yep you got that right - pfeeew!

    2. ok

    3. well you can't buy something if you don't have the money can you?

    so you just need to check

    if value_of_cool_gun is equal or smaller to Total_amount_of_currency - if not then just sent a message "go get a job, space dude"

    4. when you buy a bomb you set a variable on, let's say Got_bomb = 1

    then when the player press the key for the bomb you just check if Got_bomb == 1

    All the questions here are of pure logic and don't depend on Flash features.
    Hope nobody knows I am still on Flash 5
    ______________________________________
    All artists are prepared to suffer for their work
    but why are so few prepared to learn to draw?(Banksy)

  9. #9
    Needs help with flash.
    Join Date
    Aug 2007
    Location
    earth
    Posts
    15
    sorry if this is bumping the thread but i havent went on very much but anyways, my new errors...

    1.
    okay.. i put lifeboss1 -= 3 into the weapon's MC
    i also put: set(lifeboss1, 200); into the beggining of the boss's first frame of the MC
    and i put: if (lifeboss1 == 0) {gotoAndStop (1222)} frames where the boss is in the screen.
    so far it doesnt work
    NOTE: -frame 1222 is the shop.
    -lifeboss1 is the variable for BOSS1's health

    2.
    for the life i put:
    Code:
    set(life, 10);
    if (life == 0) {
    	gotoAndStop("2", 1);
    }
    into the the player's LIFE frames.

    and i put:
    Code:
    _root.dead = Number(_root.dead)+1;
    _root.score = 0;
    _root.HEALTH.Play();
    life -= 1
    into the player's MC

    same as the last, didnt work...
    NOTE:
    -life is the variable for the player's health
    -HEALTH is the MC that keeps track of your lives/life nad will go down everytime your hit and up everytime you get lives

    3.
    could you add code to that?(the exact)
    NOTE:
    -"The-Gun" is called, beam
    -and i use _root.score to calculate the score

    4.
    Code:
    if (beam1 == 1) {onClipEvent (load) {
    	beamMoveSpeed = 25;
    	this._x = _root.player._x+30;
    	this._y = _root.player._y;
    }
    onClipEvent (enterFrame) {
    	this._x += beamMoveSpeed;
    	if (this._x>600) {
    		this.removeMovieClip();
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.ENEMY1)) {
    		_root.ENEMY1.Play();
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.ENEMY2)) {
    		_root.ENEMY2.Play();
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.ENEMY3)) {
    		_root.ENEMY3.Play();
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.ENEMY4)) {
    		_root.ENEMY4.Play();
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.ENEMY5)) {
    		_root.ENEMY5.Play();
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.BOSS1)) {
    		_root.BOSS1.Play(); Play(); Play();
    		lifeboss1 -= 3
    	}
    }
    onClipEvent (enterFrame) {
    	if (this.hitTest(_root.BOSS1)) {
    		_root.BOSSHEALTH1.Play(); Play(); Play();
    	}
    }
    }
    ERROR: Statement must appear within on/onClipEvent handler
    i put: if (beam1 == 1) {...}
    there because, the variable: beam1 is set to 0, so when you actually buy the weapon, beam1 will add 1. causing the statement true.

    but because of the error, it wont work...
    NOTE: -beam1 refers to the weapon's MC's variable (hope i said that right )
    P.S. i added the NOTES to help understand the questions.
    Last edited by ~ZOMG~; 08-16-2007 at 06:19 PM. Reason: added an extra space

  10. #10
    Wait- what now? tidenburg's Avatar
    Join Date
    Dec 2005
    Posts
    1,471
    ZOMGERS! Do you actually use that many on enter frame events
    "I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."

  11. #11
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    Quote Originally Posted by tidenburg
    ZOMGERS! Do you actually use that many on enter frame events
    Who cares about that many enterframes when he has over 1444 frames?? :O
    I don't have a photograph, but you can have my footprints. They're upstairs in my socks.

  12. #12
    Needs help with flash.
    Join Date
    Aug 2007
    Location
    earth
    Posts
    15
    actually, there's only suppose to be about 400 frames, but since i added a timer, i had to add about 1000 more frames XD.

  13. #13
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    I think you do this in a not so efficient way...
    I don't have a photograph, but you can have my footprints. They're upstairs in my socks.

  14. #14
    Wait- what now? tidenburg's Avatar
    Join Date
    Dec 2005
    Posts
    1,471
    ^
    agreed
    "I'd only told them the truth. Was that so selfish? Our integrity sells for so little, but it is all we really have. It is the very last inch of us, but within that inch, we are free."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center