# Slight problem

**URL:** <https://forum.kirupa.com/t/slight-problem/184054>\
**Category:** Uncategorized\
**Created:** [April 1, 2006, 11:45am UTC](https://forum.kirupa.com/t/slight-problem/184054 "2006-04-01T11:45:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)\
**Post date:** [April 1, 2006, 11:45am UTC](https://forum.kirupa.com/t/slight-problem/184054/1 "2006-04-01T11:45:50Z")

</div>

ive got a slight problem with a bit of codeing .the code fires perfectly in the right direction and everything but the problem is, is that the bullet speeds up every time the character fires. and also i cant get the bullet to interact with anything else

\*\*

```auto
**
onClipEvent (load) { 
   sr_bullets = 0; 
} 
onClipEvent (enterFrame) { 
   function fur(s_name:String) { 
      duplicateMovieClip(_root.sand0, s_name, _root.enemy1.getDepth()-1); 
      _root[s_name]._x = _root.char._x; 
      _root[s_name]._y = _root.char._y; 
      _root[s_name]._rotation = _root.charhelp._rotation; 
   } 
   function updat_bulle_positio(s_name:String) { 
      _root[s_name]._y -= 1*Math.cos(_root[s_name]._rotation*(Math.PI/180)); 
      _root[s_name]._x += 1*Math.sin(_root[s_name]._rotation*(Math.PI/180)); 
   } 
   i = 0; 
   while (i<=sr_bullets) { 
      updat_bulle_positio("sand" add i); 
      i++; 
   } 
   if (Key.isDown(Key.SPACE)) { 
      sr_bullets++; 
      new_sname = "sand" add sr_bullets; 
      fur(new_sname); 
   } 
   if ("sand" add sr_bullets.hitTest(_root.enemy1)) { 
      _root.enemy1.gotoAndStop(15); 
   } 
} 

```

the game file is at

[[COLOR=#0000ff]http://www.freewebs.com/shlar/samnleogame.fla[/COLOR]](http://www.freewebs.com/shlar/samnleogame.fla)

cheers

---

<div class="post-metadata">

**Author:** ![RichL](https://avatars.discourse-cdn.com/v4/letter/r/e79b87/32.png) [@RichL](https://forum.kirupa.com/u/RichL)\
**Post date:** [April 2, 2006, 1:16am UTC](https://forum.kirupa.com/t/slight-problem/184054/2 "2006-04-02T01:16:40Z")

</div>

not exactly sure why your code isnt working…but i replaced all the code on that frame with the following and it sorted out the bullet speed okay (not sure what other “interaction” wasn’t working)

nr\_bullets = 0;  
rot = 0;

bListener = new Object();  
bListener.onKeyDown = function() {  
if (Key.isDown(Key.SPACE)) {  
nr\_bullets++;  
new\_bname = “bullet”+nr\_bullets;  
duplicateMovieClip(\_root.bullet0,new\_bname,nr\_bullets);  
\_root[new\_bname].\_x = \_root.enemy1.\_x;  
\_root[new\_bname].\_y = \_root.enemy1.\_y;  
\_root[new\_bname].\_rotation = \_root.enemy1.\_rotation;  
}  
}  
Key.addListener(bListener);

onEnterFrame = function () {  
for(i=1;i\<=nr\_bullets;i++){  
rot = \_root[“bullet”+i].\_rotation;  
\_root[“bullet”+i].\_y -= 3_Math.cos(rot_(Math.PI/180));  
\_root[“bullet”+i].\_x += 3_Math.sin(rot_(Math.PI/180));  
}  
};  
stop();

---

<div class="post-metadata">

**Author:** ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)\
**Post date:** [April 2, 2006, 9:07am UTC](https://forum.kirupa.com/t/slight-problem/184054/3 "2006-04-02T09:07:02Z")

</div>

cheers thanks thats been a great help

---

<div class="post-metadata">

**Author:** ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)\
**Post date:** [April 2, 2006, 9:26am UTC](https://forum.kirupa.com/t/slight-problem/184054/4 "2006-04-02T09:26:46Z")

</div>

ok so ive put the code into y game now and it works PERFECTLY for fireing and is a great help  
but im still not sure what instance name to use to make the bullets interact with anything else  
becuase ive put and litle extra code on the end to make the bullets kill the enemy but it isnt working and doin what i say  
could you please just help me out. it is probably me being an idiot and using the wrong instance name so if you could just correct it i would be extreamly greatful

```auto

onClipEvent (load) {
 sr_bullets = 0;
 srot = 0;
 sListener = new Object();
}
onClipEvent (enterFrame) {
 sListener.onKeyDown = function() {
  if (Key.isDown(Key.SPACE)) {
   sr_bullets++;
   new_sname = "sand"+sr_bullets;
   duplicateMovieClip(_root.sand0, new_sname, sr_bullets);
   _root[new_sname]._x = _root.char._x;
   _root[new_sname]._y = _root.char._y;
   _root[new_sname]._rotation = _root.charhelp._rotation;
  }
 };
 Key.addListener(sListener);
 onEnterFrame = function () {
  for (i=1; i<=sr_bullets; i++) {
   srot = _root["sand"+i]._rotation;
   _root["sand"+i]._y -= 10*Math.cos(srot*(Math.PI/180));
   _root["sand"+i]._x += 10*Math.sin(srot*(Math.PI/180));
  }
[COLOR=red] if [COLOR=black](_root[/COLOR]["[COLOR=blue]sand[/COLOR]"+[COLOR=yellowgreen]i[/COLOR]].[COLOR=royalblue]hitTest[/COLOR][COLOR=black](_root[/COLOR].[COLOR=darkorange]enemy1[/COLOR][COLOR=black]))[/COLOR] {
  [COLOR=black] _root[/COLOR]["[COLOR=blue]sand[/COLOR]"+[COLOR=yellowgreen]i[/COLOR]]._x = 7484928;
  [COLOR=black] _root[/COLOR]["[COLOR=blue]sand[/COLOR]"+[COLOR=yellowgreen]i[/COLOR]]._y = 2749284;
   [COLOR=lime][COLOR=black]_root[/COLOR].[COLOR=sandybrown]enemy1[/COLOR].[COLOR=black]gotoAndStop[/COLOR]([COLOR=black]15[/COLOR]);[/COLOR]
   [COLOR=black]_root[/COLOR].[COLOR=sandybrown]score[/COLOR] [COLOR=black]= _root.[/COLOR][COLOR=sandybrown]score[/COLOR][COLOR=black]+10[/COLOR];
 [/COLOR][COLOR=black] [/COLOR][COLOR=red]}
[/COLOR] };
}

```

---

<div class="post-metadata">

**Author:** ![woopsedoo](https://avatars.discourse-cdn.com/v4/letter/w/a87d85/32.png) [@woopsedoo](https://forum.kirupa.com/u/woopsedoo)\
**Post date:** [April 2, 2006, 9:29am UTC](https://forum.kirupa.com/t/slight-problem/184054/5 "2006-04-02T09:29:17Z")

</div>

actually no worries ive worked it out

THANKS for all of your help
