About a space shooter

Hi, I’m back. I was making a space shooter in 2D and I have some questions.

  1. How do I put sprites into 3de code editor, I wanted to put in a spaceship?
  2. How do I make the meteorites move toward the spaceship?
  3. How do I make it so that the player(spaceship) can only move in three directions(up, middle and down)?

These were all my questions.

Martin :slight_smile: :slightly_smiling_face:

There are already some sprites in 3DE:

Some of the snowflake images might serve as asteroids – especially to start.

The asteroids (or anything) can move toward the screen by increasing the z position of the sprites over time. That is, inside the animate() function, increase the z of each sprite each time the animate() function is called.

It might be easiest to move the player by not using the FlyControls. Instead, make your own key event listeners for up and down arrow, increasing or decreasing the y value.

Can you tell me how to generate the meteorites using a function.

And I wanted to ask how do I make it so that when the player moves out of the screen
the player goes to his previous position so it’s kind of a boundary.

I did the movement so:

document.addEventListener(“keydown”, sendKeyDown);
function sendKeyDown(event) {
var code = event.code;

if (code == 'ArrowUp') up();
if (code == 'ArrowDown') down();
if (code == 'KeyR') reset();


function up() {
avatar.position.y = avatar.position.y + 250;

function down() {
avatar.position.y = avatar.position.y - 250;

function gameStep() {
setTimeout(gameStep, 1000/30);

Let’s hope that the forum didn’t delete it.