# Help on my code. EMERGENCY

**URL:** https://forum.makecode.com/t/help-on-my-code-emergency/22337
**Category:** Help
**Created:** [September 8, 2023, 9:43pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337 "2023-09-08T21:43:03Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 8, 2023, 9:43pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/1 "2023-09-08T21:43:03Z")

</div>

![Screenshot 2023-09-09 at 6.59.42 am](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a027354ce1fbfe5bab44f6dc86370a1724ef1ea6.png)

Is there any thing wrong with this code. What I am trying to do is when player overlaps with treasure and has under 2 life then add a life, or else add 1 point. When I tried it in the arcade it doesn’t seem to work. The heart won’t even be destroyed. Help please!!!

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 8, 2023, 9:43pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/2 "2023-09-08T21:43:26Z")

</div>

Can you include a link to your game? It can help users debug faster.

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 8, 2023, 9:48pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/3 "2023-09-08T21:48:10Z")

</div>

Off the top of my head, I’d guess you need to change the condition to  
if ( life \<= 1). Notice that the score part of the statement never will destroy the heart, since there’s no destroy block inside.

Also, you want to destroy ‘otherSprite’ instead of ‘Winner’ since there are lots of ‘Winner’ hearts being created and you only want to destroy the one that has been overlapped.

Finally, notice that the overlap statement uses ‘Treasure’ and the projectile uses ‘treasure’. I believe that the program sees those as two separate kinds.

Hope that helps!

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 8, 2023, 10:44pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/4 "2023-09-08T22:44:35Z")

</div>

Yes sure. Here is the link

> **[Assessment](https://arcade.makecode.com/S97700-78891-24300-25285)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 8, 2023, 10:50pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/5 "2023-09-08T22:50:04Z")

</div>

Yep, those changes work. Here’s the code that I modified to test it.  
 ![Screenshot by Dropbox Capture](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/9/97c460e36bd422da7120a38392941c9a5b462c0a.png)

Notice that I had to remove the “treasure” variable from the field and then select the ‘Treasure’ kind from the dropdown list.

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 8, 2023, 10:51pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/6 "2023-09-08T22:51:07Z")

</div>

It’s looking really good so far!

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 8, 2023, 11:17pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/7 "2023-09-08T23:17:41Z")

</div>

OMG. THANKYOU SOOOOO MUCH. This is for my assessment task, it worked!!! Also what code should I use if I want to make that if you miss a spaceship it is the end of the game?

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 8, 2023, 11:28pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/8 "2023-09-08T23:28:23Z")

</div>

Ooh, there’s a couple of things you could do there.

1. Add a sprite to the left side and when the ship collides with the sprite, the game is over  
(See this tutorial - [https://arcade.makecode.com/#tutorial:/tutorials/blazing](https://arcade.makecode.com/#tutorial:/tutorials/blazing))

2. Since you already have ships auto destroy, you can use the “on sprite destroyed” block and put a game over inside of that…but if you do, you’ll need to change the ship’s type when it’s hit by a projectile or else hitting the ship with a projectile will end the game, too.

 ![Screenshot by Dropbox Capture](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/3/35f445e62be493c8d990a8fb009645165cd3491b.png)

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 8, 2023, 11:29pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/9 "2023-09-08T23:29:35Z")

</div>

Also on the on start block, when I reached 80 score it does’t seem to appear “Good job, you win” on the screen.

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 8, 2023, 11:30pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/10 "2023-09-08T23:30:07Z")

</div>

It doesn’t look like you’re telling it to. Do you have this block anywhere?  
 ![Screenshot by Dropbox Capture](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/8/847d9d924733b661a5cd94d6c1ee171da1c5d8ca.png)

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 9, 2023, 5:37pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/11 "2023-09-09T17:37:11Z")

</div>

![Screenshot 2023-09-09 at 9.50.07 am](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5fa8cceac3fa3271d4dcffbde3eab376f06f5e0a.png)

I have this block here

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 9, 2023, 5:37pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/12 "2023-09-09T17:37:21Z")

</div>

What does it mean when I need to change the ship’s type.

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 9, 2023, 5:41pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/13 "2023-09-09T17:41:04Z")

</div>

actually is it possible to make if you miss a spaceship you lose a life?

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 11, 2023, 5:47pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/14 "2023-09-11T17:47:39Z")

</div>

Also can I import music from outside into makecode?

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 11, 2023, 5:53pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/15 "2023-09-11T17:53:14Z")

</div>

I mean to change the ship’s kind, like I showed in the sample blocks:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/7/77b25b6ea754c317edaa5eed204e97c61d3ed1e0.png)

You can make it lose a life by adding a `change life by -1` instead of a game over.

Then, make sure that you not only change the message of the game over, but call the game over, too:  
 ![Screenshot by Dropbox Capture](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/bedd812a05acc37623f7ecbe59d94c11147b4308.png)

Finally, we don’t have a way to import a song directly, but if you have the sheet music for it, you can recreate it using our music editor 🙂

---

<div class="post-metadata">

### Author: ![annie](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@annie](https://forum.makecode.com/u/annie)
#### Post date: [September 11, 2023, 9:25pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/16 "2023-09-11T21:25:17Z")

</div>

Ok sure, thankyou so much

---

<div class="post-metadata">

### Author: ![Ray1](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@Ray1](https://forum.makecode.com/u/Ray1)
#### Post date: [September 12, 2023, 4:49pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/17 "2023-09-12T16:49:10Z")

</div>

Whenever enemy touches the main character, I lose the game completely but I had 2 hearts so idk why I lose game when I am supposed to be on 1 life in total

---

<div class="post-metadata">

### Author: ![KIKIvsIT](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kikivsit/32/10492_2.png) [@KIKIvsIT](https://forum.makecode.com/u/KIKIvsIT)
#### Post date: [September 12, 2023, 4:49pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/18 "2023-09-12T16:49:57Z")

</div>

Would you please include the link for the newest version of your game?

---

<div class="post-metadata">

### Author: ![Ray1](https://avatars.discourse-cdn.com/v4/letter/r/94ad74/32.png) [@Ray1](https://forum.makecode.com/u/Ray1)
#### Post date: [September 12, 2023, 10:39pm UTC](https://forum.makecode.com/t/help-on-my-code-emergency/22337/19 "2023-09-12T22:39:15Z")

</div>

I fixed the problem, thank you
