File Exchange

image thumbnail

Matlab Space Invaders VideoGame

version (879 KB) by Héctor Corte
A tribute to Space Invaders coded in Matlab. Just take fun and get ideas for more games.


Updated 06 Dec 2012

View License

Version 0.1 (beta, so please, give feedback).

This is a game and also an example of how to read/use keypress
functionality from figures.

This is a tribute to Space invaders[1], without any lucrative pourpouse.

The game opens a figure with the spaceship that must land on the square
avoiding hitting the land.

Use the arrows to move the spaceship and the spacebar to fire laser against the enemies.

[1] Space Invaders, Game,

This function was written by :
Héctor Corte
B.Sc. in physics 2010
M.Sc. in Complex physics systems 2012
NPL (National Physical Laboratory), London,United kingdom.

Cite As

Héctor Corte (2020). Matlab Space Invaders VideoGame (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

Very cool game with an authentic retro feel. However I do have two complaints about it:

1. it may be a better idea not to write the code for keyboard handling in KeypressFcn. Because that way you would experience a delay (~0.5 s) after the first keypress. Instead, set a variable to true in KeypressFcn and false in KeyreleaseFcn, and check the status of this variable in the main loop to determine whether this key is pressed or not;

2. The bullets travel too fast. They usually go right through an enemy without hitting it. Possible solutions are 1) slowing down the bullets (less distance per frame, slower apparent speed), or 2) not slowing down the bullets, but increasing the frame rate(less distance per frame, same apparent speed), or 3) using better collision detection algorithm (same distance per frame, same apparent speed).

Anyway, I do like this game. Please keep writing more stuffs like this!

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