# Using array of images to spawn enemies in game

**URL:** https://discourse.processing.org/t/using-array-of-images-to-spawn-enemies-in-game/44341
**Category:** Beginners
**Created:** [April 24, 2024, 11:19am UTC](https://discourse.processing.org/t/using-array-of-images-to-spawn-enemies-in-game/44341 "2024-04-24T11:19:08Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 24, 2024, 11:45am UTC](https://discourse.processing.org/t/using-array-of-images-to-spawn-enemies-in-game/44341/2 "2024-04-24T11:45:44Z")

</div>

Hello @dsdsdsds,

> [@dsdsdsds](#):
>
> I’m not sure where to start. Any guidance would be greatly appreciated.

A good place to start:

> [@Guidelines—Asking Questions](https://discourse.processing.org/t/guidelines-asking-questions/2147):
>
> Summary (TL;DR) Ask complete questions to get better answers! Be specific. For example: I want to load an image. I tried using createImg() , and I expected the image to be on canvas, but what happened instead was the image showing up below the canvas. Isolate your problem and work in small steps. Share only the code directly related to your problem if it is part of a bigger project, and if something isn’t working, try the smallest code that could do the thing you want. Can we run your code to …

Break down what is required first:

1. Array of images \< Assuming you have already done this.
2. Access a random element of the array.  
This reference may help:  
[random() / Reference / Processing.org](https://processing.org/reference/random_.html)  
You will have to convert the _float_ to an _int_ to access elements of array:  
[int() / Reference / Processing.org](https://processing.org/reference/intconvert_.html)
3. Search for _timer_ (or related keywords) in this forum for examples of timers.
4. Write some code to understand each element above.
5. Start piecing the elements of code together and later integrate it into your project.

`:)`

---

_[View the full topic](https://discourse.processing.org/t/using-array-of-images-to-spawn-enemies-in-game/44341)._
