# Fps game: goto after 5 shoots or 20 seconds

**URL:** <https://forum.kirupa.com/t/fps-game-goto-after-5-shoots-or-20-seconds/181975>\
**Category:** Uncategorized\
**Created:** [March 14, 2006, 5:46pm UTC](https://forum.kirupa.com/t/fps-game-goto-after-5-shoots-or-20-seconds/181975 "2006-03-14T17:46:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dirksmith](https://avatars.discourse-cdn.com/v4/letter/d/47e85d/32.png) [@dirksmith](https://forum.kirupa.com/u/dirksmith)\
**Post date:** [March 14, 2006, 5:46pm UTC](https://forum.kirupa.com/t/fps-game-goto-after-5-shoots-or-20-seconds/181975/1 "2006-03-14T17:46:07Z")

</div>

Hi

I’m working on a simple first person game - converting it to a banner ad.

I’d like the timeline to move to an end game frame after 5 shoots or after 20 seconds - any ideas on how the script below controlling the game can be modigied to achieve this?

Thanx

Dirk

```auto
var i;
// gunfire sounds
var gunfire = new Sound();
gunfire.attachSound("gunfire");
_root.hit1.onPress = function() {
    gunfire.start();
    i++;
    
    _root.bull.duplicateMovieClip("bulletNew", i);
    if (i == 10) {
        i = 0;
    }
    // hit test on target
    if (_root.target_mc.hitTest(_root._xmouse, _root._ymouse, false)) {
        _root.gun.gotoAndPlay(2);
        _root.target_mc._x = 0;
        _root.target_mc._y = random(90);
    }
};
// initialise stuff
_root.onLoad = function() {
    // hide the mouse
    Mouse.hide();
};
//loop
_root.onEnterFrame = function() {
    //put cross hairs to mouse coords
    _root.gun._x = _root._xmouse;
    _root.gun._y = _root._ymouse;
    // target move
    _root.target_mc._x += 10;
    if (_root.target_mc._x<0 || _root.target_mc._x>Stage.width) {
        _root.target_mc._x = 0;
        _root.target_mc._y = random(90);
    }
    
};

```
