Space Rocks 3D!

same here

It’s actually amazing how far this sim has gone

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
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 :slight_smile:

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

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.
6 Likes

This is insane…howwww lol.

2 Likes

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 :slight_smile:

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? 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!

6 Likes

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

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 :wink:

2 Likes

you can press menu and turn the volume down.

I think yes

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

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

  • 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.

5 Likes

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 :slight_smile:
Does it work better on the PyGamer?

3 Likes

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?

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?

7 Likes

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.

2 Likes

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

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.

1 Like

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.

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

@gusiscute64 How are we supposed to say your username.

Here’s a sneak peek showing the upgraded 3D rendering:

ship-d

It can now handle overlapping surfaces by using a BSP tree to draw them in the correct order. On hardware, it’s getting about 25fps which still seems tolerable.

12 Likes