# Math random help

**URL:** <https://forum.kirupa.com/t/math-random-help/292677>\
**Category:** flash\
**Created:** [July 17, 2009, 12:30pm UTC](https://forum.kirupa.com/t/math-random-help/292677 "2009-07-17T12:30:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![farban](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@farban](https://forum.kirupa.com/u/farban)\
**Post date:** [July 17, 2009, 12:30pm UTC](https://forum.kirupa.com/t/math-random-help/292677/1 "2009-07-17T12:30:25Z")

</div>

Hey there

I am making a game where red squares spawn on the right side of the screen. So far the red squares spawn all the way up and down the height of the stage.

The problem is that i want the red squares to spawn only in areas randomly below a certian height of the stage

This is the code so far

```auto
enemy.x = 470 ;
                enemy.y = Math.random() * stage.stageHeight;

```

This code makes the red squares spawn all the way up and down the height of the stage

Thanks for any help
