# Random Achievement system

**URL:** https://discourse.processing.org/t/random-achievement-system/31063
**Category:** Coding Questions
**Created:** [July 5, 2021, 3:31am UTC](https://discourse.processing.org/t/random-achievement-system/31063 "2021-07-05T03:31:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gyrosis](https://avatars.discourse-cdn.com/v4/letter/g/aeb1de/32.png) [@Gyrosis](https://discourse.processing.org/u/Gyrosis)
#### Post date: [July 5, 2021, 3:31am UTC](https://discourse.processing.org/t/random-achievement-system/31063/1 "2021-07-05T03:31:35Z")

</div>

How would I create an achievement system so when I kill an X amount of random enemies in a random X amount of time.

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [July 7, 2021, 2:14pm UTC](https://discourse.processing.org/t/random-achievement-system/31063/2 "2021-07-07T14:14:20Z")

</div>

Hi @Gyrosis ,

Welcome to the forum! 😉

What code do you have so far? Have you thought about some solutions or have ideas on how to solve this problem?

Do you already have a player that can kill enemies and an achievement system?

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [July 7, 2021, 2:33pm UTC](https://discourse.processing.org/t/random-achievement-system/31063/3 "2021-07-07T14:33:09Z")

</div>

I don’t fully understand, but you could do something like:

```auto
int till = millis() + random(30,60)*1000; //random time in millisecond, which is between 30 and 60 secodns away
int neededScore = random( (till-millis()) * 0.1, (till-millis()) * 0.2);
//you have to kill between 1 and 2 enemies every 10 seconds untill time runs out.
boolean chechDone(int till, int neededScore, int score) {
   returned(score>=neededScore && millis()<till);
}

```
