File Exchange

image thumbnail

Stellaria (Tech Demo) - The best MATLAB shooting game ever

version (1.4 MB) by Mingjing Zhang
If you think you have played the best MATLAB game before. Think again after you try this one.


Updated 25 Sep 2012

View Version History

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week


Stellaria: A Figure-Based Space Shooting Game


Stellari Studio, 2011.

Designed and Programmed by Mingjing Zhang


Vision and Media Lab @ Simon Fraser University

* Please note that this is a tech demo and is far from a completed game. *
* All I want to do is to demonstrate what MATLAB is capable of. *
* Stellaria features arcade-style graphics and MIDI music.*

About the Code

I wrote all code myself except for the midi synthesizer.

I apologize for the for-loop overwhelmed, global variable laden, poorly commented, ill-organized and therefore highly inefficient code.

However this is the best I can do for now.


Put the folder StellariaTechDemo anywhere you like,
then Add StellariaTechDemo and all its subfolders in the search path list.

!Run stl_StellariaMain to play!


Stellaria is just like the arcade shoot-em-up you have played before, except for the sad music.

Stellaria supports two players.

Each player has 30 lives and 3 bombs.

There are no power-ups, no boss, no score.

There is only 1 stage.

No text information will be displayed on the screen

The game can be slow when there are over 50 objects on the screen (For my i7 2.8GHz + 6 GB RAM +GTX480 computer,
this number could reach over a 100 without any significant frame dropping). Anyway, you need a better-than-average computer to play this game.


Player 1: WSAD - Movement, U - Fire, I - Bomb;
Player 2: DirKeys - Movement, Insert - Fire, Delete - Bomb;
You may skip the opening scene and credits screen by pressing 1 or 2
. They stands for 1 player and 2 players, respectively.


Most graphical contents used in this game are the creation of Hamukorosama.
You can find his works at this site:


The background music used in this game are composed by Shi Jin (Chinese: 石进)
His Weblog:


The capability of playing midi music is granted by the MIDI synthesizer written by Kenneth Adams, Jr. at GaTech
This synthesizer is available for download at

The synthesizer comes as a part of Stellaria. You DO NOT need to download it separately.

The synthesizer has been slightly modified by the author of this game.


The keyboard processing technique used in the Mario Sim v 0.1
by Ryan Kinnett

The double-plot star scroll technique employed by Dave's shooter game
by David Buckingham,


This game is not intended for commerical purposes and is free for everyone. However, if you decide to use the code

or any graphical or audio materials in your own project, please kindly make sure the original authors (Mingjing Zhang,

Hamukorosama, Shi Jin and Kenneth Adams) are properly accredited.

Contact Info:
If you have any questions, suggestions, comments or complaints
Please do not hesitate to send me an email:

I'll write back as soon as possible.



Update Log:

Sep 24, 2012 (V 1.3):
* An App installer is added
* Now the user can gracefully quit the game simply by closing the figure window without causing any error

Cite As

Mingjing Zhang (2021). Stellaria (Tech Demo) - The best MATLAB shooting game ever (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (45)

miao zhang

I am sorry to bother you. But I think there may be a missing file, or something that I haven't downloaded. When I run the program, it shows:
未定义函数或变量 'wavread'。
出错 readmidi2/addSample (line 315) = wavread([sndDir num2str(z.idx + 1) '.wav']);
出错 readmidi2 (line 197)
addSample(trackTime, msgParams(1));
出错 stl_STAGE_TitleScreen (line 117)
[song freq] = readmidi2([GAME_PATH.MUSIC_RES 'MOTN11.mid']);
出错 stl_StellariaMain (line 129)
bkgMusicPlayer = eval(stage_table{currentStage+1});

Thank you for your answer. The version I'm using is R2020b.

Zijie Lu

Behnam Azizi

DangDang Lang

Excellent work. wonderful.敬佩牛人。

zhang bing

so great




Sir! you rock!

Lu chao



Ashan Peiris

This is really cool.. :)



Irfan Turk

Thank you for the game. It is really nice...
As a Matlab Fun, Congradulations....

Bharath Lohray

Amazing !!!

Kang Qin Pung

I am stunned!!!

Mingjing Zhang

@Zheng 随便写着玩的,见笑了



Ryan G

Ham Sadeh

jacky chen

cool ,man , so classical

Davide Ferraro

Suraj Kamya

Awesome buddy !
Nice fun

Mingjing Zhang

Thank you for bringing this problem to my attention. I'll add the said feature as soon as possible.

Kozlov Sacha

It works only for QWERTY keyboards. Think about poor frechies with AZERTY, add customise keys option, please :-)

Kozlov Sacha

It works only for QWERTY keyboards. Think about poor frechies with AZERTY, add customise keys option, please :-)

Mingjing Zhang


opengl software

before you run the game. If that solves the problem, then the most possible explanation of the upside-down text is that your OpenGL driver does not work properly with MATLAB. You must either upgrade your driver/card, or stick to the software renderer.

Alternatively, you can run

opengl hardware
f = figure(1); title('Rightside up'); set(f,'Renderer','OpenGL');

and see if the problem could be reproduced.

The following link may help

Anyway, I do believe that a submission should be judged based on its overall quality instead of minor bugs that are not even caused by the program itself. So I would never rate until I truly understand what the program does, how to use the program and what causes the problems (if any). If you do find a bug in the program, a more constructive idea would be to report the bug with details so that the author could correct it, rather than leaving a bad remark that doesn't give much info.

Then again, I was just speaking from a developer's point of view; not even trying to change your style of criticism. do what you believe is correct.


Ok, I see the readme.txt now. But the rating was for thew upside down text. I am using windows 7 with Matlab 2012a. I changed the rating to 3 stars.

Mingjing Zhang

I'm really sorry for the inconvenience but there IS a file named README.txt in the package, in which I explicitly stated
"!Run stl_StellariaMain to play!"

And may I ask you, please, read the manual before recklessly giving a low rating.

As for the upside-down text, I have never produced the same problem on all (10+) computers with different versions of MATLAB. I won't put too much hope on you but if you are still interested, please provide more details (your MATLAB/Win version, which text is upside-down, and so on) so I can fix the bug.


text is upside down. No read me file, no idea which file to run.


Maxim Vedenyov

use addpath to add all this subfolders

Mingjing Zhang

Sorry for bringing you down, man. I didn't mean it intentionally; it is just the way I felt.

Yu Ang Tan

Wow, I'm overwhelmed by your depressed comments. I'm feeling suicidal now.

David Buckingham

yeah. i'm not that familiar with tic/toc. its behavior wasn't intuitive to me when i tried modifying the argument to toc. the only thing i can think of, like you said, is to store the accumulated paused time and then do something like: currentTime=toc(stageStartTime)-pausedTime

Mingjing Zhang

Okay, I know exactly what you are talking about. I designed the game in such a way that the game runs in the same speed on any machine. If an occasional lag happens, the game would try to skip some frames so that it could 'catch up'. If you pause the game and the internal clock is still ticking, the game would think it has encountered a super-long lag and after you resume playing, it would run 5 times as fast as normal until it catches up to where it should be.

The timing of the game relies solely on on tic/toc pair:
stageStartTime = tic;
currentTime = toc(stageStartTime);

Unfortunately, stageStartTime is just a number, not an object you can 'pause'. The only workaround I came up with is to record how much time the game has been paused, then after the game is unpaused, add the duration of the paused time to stageStartTime so that toc would behave as if the pausing has never happened.

I did have this problem at the early stage of development. I thought I have already solved it...Anyway, I'll check it out agian

David Buckingham

Yeah, what happens is that if I pause for any length of time, the game goes super fast for a while. This hyperspeed seems to last longer if the pause break is longer. It's as if the game is trying to 'catch up' to where it would be if I hadn't paused. I'm using MATLAB 7.11.0 (R2010b). I made a recording of my playing and having the pause bug, I'll try to email it to you.

Mingjing Zhang

Hi Daniel,

Are you running an earlier version of MATLAB?
As far as I know, MATLAB doesn't support 'plus' for 'int64' until R2010b.

As a workaround, you may change Line 221 to:

stageStartTime = uint64(double(stageStartTime) + pauseElapsedTime.*timer2sec);


??? Undefined function or method 'plus' for input arguments of type 'uint64'.

Error in ==> stl_StellariaMain at 221
stageStartTime = stageStartTime + pauseElapsedTime.*timer2sec;

Win7 64bit :(

Mingjing Zhang

Thanks for the comment Dave, but I failed to reproduce the same bug on my machine. Does it happen every time you pause the game?

David Buckingham

this is great! i must agree with Mingjing that Ryan is over-generous. this is not very polished. one bug i found is that when you pause some stuff seems to keep running because when you unpause some stuff (eg enemy bullets) has moved. judging it on what it claims to be, a demonstration of the potential for sprite-based games, this is quite successful. furthermore, a little bit more working polishing this up would produce a very nice, game.

David Buckingham

the game is great!


This game is really fun. You should definitely make more. You may have a future in game design!

Mingjing Zhang

Thanks Ryan. I have not thoroughly tested the game so it has to be buggy. Have you tried it? Is it running sluggishly on your computer?

BTW, I created this game to prove a point: It is possible to make a sprite-based arcade-style game with MATLAB. You know what my next goal is: Super Mario Bros.


Well done! Clean, robust, stylish, and smooth. Ignore the author's own humble words regarding coding quality!

Mingjing Zhang

Hi Dave,

I am afraid you have to add all the 'subfolders' (at least these three: Math, Stages, Util\midi) into your search path list.

Sorry for the inconvenience.


David Buckingham

When I run the program it displays the starfield and crashes with:

??? Error using ==> eval
Undefined function or variable 'stl_STAGE_TitleScreen'.

Error in ==> stl_StellariaMain at 118
bkgMusicPlayer = eval(stage_table{currentStage+1});

MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired by: Mario Sim v0.1, Dave's MATLAB Shooter

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!