# Space Rocks 3D!

**URL:** https://forum.makecode.com/t/space-rocks-3d/6334
**Category:** Show & Tell
**Tags:** game, featured-game
**Created:** [February 24, 2021, 3:59pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334 "2021-02-24T15:59:47Z")
**Posts on this page:** 20
**Page:** 3

<div class="post-metadata">

### Author: ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)
#### Post date: [February 26, 2021, 8:42pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/41 "2021-02-26T20:42:52Z")

</div>

> [@UnsignedArduino](#):
>
> Great game BTW! Wish my brain was big enough to make something like this…

Same here!

> [@kwx](#):
>
> sorry about the radical modifications

Don’t be! This game is epic!

---

<div class="post-metadata">

### Author: ![ggiscool](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ggiscool/32/3431_2.png) [@ggiscool](https://forum.makecode.com/u/ggiscool)
#### Post date: [February 26, 2021, 11:13pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/42 "2021-02-26T23:13:58Z")

</div>

> [@GameGod](#):
>
> > [@UnsignedArduino](#):
> >
> > Great game BTW! Wish my brain was big enough to make something like this…
> 
> Same here!

same here

---

<div class="post-metadata">

### Author: ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)
#### Post date: [February 26, 2021, 11:14pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/43 "2021-02-26T23:14:12Z")

</div>

It’s actually amazing how far this sim has gone

---

<div class="post-metadata">

### Author: ![2ndClemens](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/2ndclemens/32/809_2.png) [@2ndClemens](https://forum.makecode.com/u/2ndClemens)
#### Post date: [February 26, 2021, 11:15pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/44 "2021-02-26T23:15:19Z")

</div>

v5 still crashes on Meowbit when all lives are lost.  
I will try to look into the code when I have some time, maybe if I add a little pause before the game over screen.  
I remember, I had a crash too at the end of my game [Pergamon arcade](https://forum.makecode.com/t/pergamon-arcade/1078)  
I think there will be a makecode arcade compatible shield for micro:bit v2 announced in the blog.  
This looks like a perfect fit for Space Rocks 3D. Navigating with the tilt and compass sensors 🙂

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [February 27, 2021, 2:41am UTC](https://forum.makecode.com/t/space-rocks-3d/6334/45 "2021-02-27T02:41:17Z")

</div>

> [@2ndClemens](#):
>
> I will try to look into the code when I have some time, maybe if I add a little pause before the game over screen.

Try this version which has some cleanup logic at game over, does that help?

> **[Space Rocks 3D (v6)](https://arcade.makecode.com/89668-30446-67569-02409)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Other changes:

- Fix the sprite Z order so that explosion now happen outside the cockpit
- Updated laser animation
- Shortened the pause between waves
- Some code cleanups and restructuring. For example there’s now a `useCockpit` variable you can set to false if you prefer the open-space experience.

---

<div class="post-metadata">

### Author: ![wimberlyw](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/wimberlyw/32/235_2.png) [@wimberlyw](https://forum.makecode.com/u/wimberlyw)
#### Post date: [March 1, 2021, 3:43am UTC](https://forum.makecode.com/t/space-rocks-3d/6334/46 "2021-03-01T03:43:30Z")

</div>

This is insane…howwww lol.

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [March 1, 2021, 3:45am UTC](https://forum.makecode.com/t/space-rocks-3d/6334/47 "2021-03-01T03:45:55Z")

</div>

> **[Space Rocks 3D (v7)](https://arcade.makecode.com/53937-93676-14776-54808)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Gameplay changes:

- Press the B button for a speed boost. Use with care.
- The playing area now wraps around, asteroids no longer bounce off invisible walls.
- When starting a new wave, make sure the asteroids aren’t too close to the player.
- Added a new accelerometer control scheme using tilt yaw/pitch and stick roll.

The game now starts at a settings screen that allows choosing the control scheme, cockpit on/off, and some graphics-related flags. You can also choose a starting wave for increased difficulty. The settings are stored persistently using the settings API, so they should remain set across restarts.

Behind the scenes, I restructured how it draws to the screen, cutting the memory consumption almost in half (from ~40kB to~ 25kB according to heap snapshots), and increasing performance a bit. Boring technical bits following, feel free to skip these 🙂

I had been modifying `scene.backgroundImage()` since I thought that this corresponded to the screen buffer, but that’s actually a separate in-memory image which needs about 10kB, and also needs to be copied to the screen every frame as an additional internal step.

Now I’m using `scene.createRenderable()` instead, this is far more efficient since it actually does draw to the screen buffer directly. It’s also integrated into the scene Z hierarchy, making it easy to structure UI layers without needing separate images. See the [Is it possible to write directly to screen (pixels) on the Arcade?](https://forum.makecode.com/t/is-it-possible-to-write-directly-to-screen-pixels-on-the-arcade/510) thread for more information on this.

This also made it possible to simplify the starfield background code a lot, and to add screen shake effects to the radar screen for consistency.

Enjoy!

---

<div class="post-metadata">

### Author: ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)
#### Post date: [March 1, 2021, 4:34pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/48 "2021-03-01T16:34:27Z")

</div>

I’m gonna keep on waiting for this to become it’s max version  
PS: This simulator sounds yum

---

<div class="post-metadata">

### Author: ![2ndClemens](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/2ndclemens/32/809_2.png) [@2ndClemens](https://forum.makecode.com/u/2ndClemens)
#### Post date: [March 1, 2021, 7:53pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/49 "2021-03-01T19:53:48Z")

</div>

On the MeowBit the game over screen now works in wave 1, 2 and 3.  
In wave 7 it throws the error on game over.  
The general performance is much better even in the higher levels.  
A “sound off” option would be nice for silently testing while others watch TV 😉

---

<div class="post-metadata">

### Author: ![ggiscool](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ggiscool/32/3431_2.png) [@ggiscool](https://forum.makecode.com/u/ggiscool)
#### Post date: [March 1, 2021, 10:12pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/50 "2021-03-01T22:12:04Z")

</div>

you can press menu and turn the volume down.

---

<div class="post-metadata">

### Author: ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)
#### Post date: [March 1, 2021, 10:12pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/51 "2021-03-01T22:12:14Z")

</div>

> [@2ndClemens](#):
>
> A “sound off” option would be nice

I think yes

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [March 1, 2021, 10:24pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/52 "2021-03-01T22:24:50Z")

</div>

> [@2ndClemens](#):
>
> A “sound off” option would be nice for silently testing while others watch TV 😉

The built-in menu already has volume control. Just press the Menu button, then A twice to mute the sounds.

> [@Primal\_Nexus](#):
>
> I’m gonna keep on waiting for this to become it’s max version

I guess it’s fitting that I need a bugfix release:

> **[Space Rocks 3D (v8)](https://arcade.makecode.com/97171-99289-49465-70009)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

- Bugfix: Tilt yaw was accidentally staying enabled for other control modes, making it unusable on a smartphone emulator.
- The world size (available space for asteroids) is now configurable, default is medium to increase the challenge a bit.
- Add a distance-dimming effect to avoid pop-in for asteroids that teleport at the boundary of the universe. (This is more extreme for smaller world sizes.)

I’ve also moved the game logic to a new AsteroidInstance class in the main.ts file to keep it separate from the more generic 3D renderer code in triangle.ts, this makes things a bit more self contained in case you want to make gameplay tweaks.

---

<div class="post-metadata">

### Author: ![centigradeclemensP](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/centigradeclemensp/32/754_2.png) [@centigradeclemensP](https://forum.makecode.com/u/centigradeclemensP)
#### Post date: [March 2, 2021, 4:37pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/53 "2021-03-02T16:37:08Z")

</div>

> [@kwx](#):
>
> The built-in menu already has volume control. Just press the Menu button, then A twice to mute the sounds.

True, but the setting doesn’t persist long. Once you lose all lives or turn the MeowBit off and on, volume is all the way up again.

But you’re right it would be better to fix this globally than per game 🙂  
Does it work better on the PyGamer?

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [March 3, 2021, 4:50pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/54 "2021-03-03T16:50:28Z")

</div>

> [@centigradeclemensP](#):
>
> True, but the setting doesn’t persist long. Once you lose all lives or turn the MeowBit off and on, volume is all the way up again.

I’ve added a volume setting, does this one work for you? I’m a bit confused since I thought the system volume was supposed to be saved to persistent storage, but my PyGamer also returns to a default volume when restarting the game. Maybe worth filing a bug?

> **[Space Rocks 3D (v10)](https://arcade.makecode.com/97643-86710-94038-72640)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

Changes:

- Slightly larger collision radius. (I had forgotten to add an offset for the ship’s own size.)
- Made the distance fade effect less dark. (Quadratic falloff instead of linear.)
- The menu button now opens/closes the setup screen while in-game. Most changes take effect immediately. For example, it’s possible to raise the wave number while playing, but lowering it doesn’t take effect until the game is reset.
- New menu options:
  - Volume control, including low-volume settings that are less loud than the system menu’s lowest setting
  - Change number of stars
  - Reset game (use this to start over, or in case the game is confused)
  - Open system menu

- The setting screen now scrolls (I guess I’m adding too many options?)

In case you’re wondering about all the menu related changes, I wasn’t aware that it’s possible to use the Menu button for game actions until I saw it used in the latest horticulture game. I think it’s a bit unfriendly to make the system menu inaccessible, so the “show system menu” entry calls `scene.systemMenu.showSystemMenu()`.

Out of curiosity, is there a way to use the PyGamer’s fourth button (bottom right of the screen) in an application? I think that this was intended to be a Select button, but it doesn’t seem to be hooked up for Arcade. (Of course, if other hardware doesn’t have such a button, it wouldn’t be a good idea to rely on it.)

My daughter asked me if it would be possible to add two-player support. I think this would be doable on the gameplay/rendering side (though I’d need to add a ship model), but last I checked the direct cable jacdac communication wasn’t ready for general use yet. Maybe in the future?

---

<div class="post-metadata">

### Author: ![2ndClemens](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/2ndclemens/32/809_2.png) [@2ndClemens](https://forum.makecode.com/u/2ndClemens)
#### Post date: [March 3, 2021, 10:48pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/55 "2021-03-03T22:48:21Z")

</div>

Thanks for adding volume control.

Everything runs great now on the MeowBit. I just lost my last live on level 8 and the game over screen appeared without a crash.  
That’s amazing considering that 80% of the games published on the forum and even a lot that are published on the arcade website don’t run on MeowBit.

---

<div class="post-metadata">

### Author: ![Primal\_Nexus](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/primal_nexus/32/3540_2.png) [@Primal\_Nexus](https://forum.makecode.com/u/Primal_Nexus)
#### Post date: [March 4, 2021, 3:20pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/56 "2021-03-04T15:20:22Z")

</div>

> [@2ndClemens](#):
>
> Everything runs great now on the MeowBit

> [@kwx](#):
>
> PyGamer

Wait @kwx, does that mean that the simulator is ok for the biggest game?

---

<div class="post-metadata">

### Author: ![gusiscute64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gusiscute64/32/3556_2.png) [@gusiscute64](https://forum.makecode.com/u/gusiscute64)
#### Post date: [March 9, 2021, 4:33pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/57 "2021-03-09T16:33:27Z")

</div>

what if you added different types of meteors/asteroids in the game, like a big asteroid that takes more hits to defeat, or a breaking asteroid, that turns into small asteroids once hit.

---

<div class="post-metadata">

### Author: ![kwx](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/kwx/32/1545_2.png) [@kwx](https://forum.makecode.com/u/kwx)
#### Post date: [March 9, 2021, 6:37pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/58 "2021-03-09T18:37:41Z")

</div>

I have been thinking about this, it would be similar to the old Asteroids arcade game where big rocks split into smaller rocks. I worry though that it might be annoying if small fast asteroids end up being too hard to hit. The accelerometer controls on hardware can be quite precise, but a digital joystick isn’t well suited for precise aiming.

No promises, but I am thinking about making a new version at some point with enemy spaceships that shoot back. I have updated the 3D renderer to draw more complex shapes with correct depth handling which is necessary for ships that aren’t just simple block shapes, but I haven’t started on the enemy movement and AI yet.

---

<div class="post-metadata">

### Author: ![gusiscute64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gusiscute64/32/3556_2.png) [@gusiscute64](https://forum.makecode.com/u/gusiscute64)
#### Post date: [March 9, 2021, 8:31pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/59 "2021-03-09T20:31:32Z")

</div>

okay. also the small rocks could be the normal speed of the asteroids.

---

<div class="post-metadata">

### Author: ![xavvvvvv](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/xavvvvvv/32/15324_2.png) [@xavvvvvv](https://forum.makecode.com/u/xavvvvvv)
#### Post date: [March 9, 2021, 10:10pm UTC](https://forum.makecode.com/t/space-rocks-3d/6334/60 "2021-03-09T22:10:10Z")

</div>

@gusiscute64 How are we supposed to say your username.

[Previous page](https://forum.makecode.com/t/space-rocks-3d/6334.md?page=2)

[Next page](https://forum.makecode.com/t/space-rocks-3d/6334.md?page=4)
