View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

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

4.8 | 24 ratings Rate this file 47 Downloads (last 30 days) File Size: 1.4 MB File ID: #31449 Version: 1.5
image thumbnail

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


Mingjing Zhang (view profile)


14 May 2011 (Updated )

If you think you have played the best MATLAB game before. Think again after you try this one.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information


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


Mario Sim V0.1 and Dave's Matlab Shooter inspired this file.

MATLAB release MATLAB 7.11 (R2010b)
Other requirements None
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (42)
08 Aug 2016 DangDang Lang

Excellent work. wonderful.敬佩牛人。

11 Apr 2016 zhang bing

so great

29 Apr 2015 mikeferrari


10 Apr 2015 sheetansh

Sir! you rock!

31 Jan 2015 Lu chao


21 May 2014 Leaf

Leaf (view profile)

11 May 2014 Ashan Peiris

This is really cool.. :)

29 Jan 2014 Brian

Brian (view profile)


16 Nov 2013 Irfan Turk

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

08 May 2013 Bharath Lohray

Amazing !!!

03 May 2013 Kang Qin Pung

I am stunned!!!

Comment only
10 Jan 2013 Mingjing Zhang

Mingjing Zhang (view profile)

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

Comment only
09 Jan 2013 Zheng

Zheng (view profile)


02 Nov 2012 Ryan G

Ryan G (view profile)

25 Oct 2012 Ham Sadeh

19 Oct 2012 jacky chen

cool ,man , so classical

18 Oct 2012 Davide Ferraro

16 Oct 2012 Suraj Kamya

Suraj Kamya (view profile)

Awesome buddy !
Nice fun

16 Oct 2012 Mingjing Zhang

Mingjing Zhang (view profile)

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

Comment only
15 Oct 2012 Kozlov Sacha

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

Comment only
15 Oct 2012 Kozlov Sacha

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

Comment only
29 Sep 2012 Mingjing Zhang

Mingjing Zhang (view profile)


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.

Comment only
29 Sep 2012 steve

steve (view profile)

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.

29 Sep 2012 Mingjing Zhang

Mingjing Zhang (view profile)

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.

Comment only
28 Sep 2012 steve

steve (view profile)

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

09 Aug 2012 Dmitry

Dmitry (view profile)

07 Dec 2011 Maxim Vedenyov

Maxim Vedenyov (view profile)

use addpath to add all this subfolders

30 Jun 2011 Mingjing Zhang

Mingjing Zhang (view profile)

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

Comment only
22 Jun 2011 Yu Ang Tan

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

19 May 2011 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

Comment only
18 May 2011 Mingjing Zhang

Mingjing Zhang (view profile)

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

Comment only
18 May 2011 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.

Comment only
17 May 2011 Mingjing Zhang

Mingjing Zhang (view profile)

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);

Comment only
17 May 2011 Daniel

Daniel (view profile)

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

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

Win7 64bit :(

Comment only
17 May 2011 Mingjing Zhang

Mingjing Zhang (view profile)

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?

Comment only
17 May 2011 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.

Comment only
16 May 2011 David Buckingham

the game is great!

16 May 2011 Dawn

Dawn (view profile)

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

16 May 2011 Mingjing Zhang

Mingjing Zhang (view profile)

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.

Comment only
16 May 2011 Ryan

Ryan (view profile)

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

16 May 2011 Mingjing Zhang

Mingjing Zhang (view profile)

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.


Comment only
16 May 2011 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});

Comment only
04 Nov 2011 1.1

* Removed the unpleasantly depressing messages
* Fixed a minor bug about tic/toc that may cause error before release 2010a

24 Sep 2012 1.3

An App installer is added
Now user is allowed to close the window to quit the game without causing any error.

25 Sep 2012 1.5

Drastically reduced the size of the program by removing redundant music files

Contact us