Code covered by the BSD License  

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

image thumbnail

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

by

 

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

stl_deleteFromGlobalEnemies.m
function stl_deleteFromGlobalEnemies(indexEnemiesToDelete)
%% STL_DELETEFROMGLOBALENEMIES - Delete several enemies from the global enemy
% queue (˴ȫֵ˶ɾ)
%
% 
%% USAGE ÷:
% ------
% stl_deleteFromGlobalEnemies(indexEnemiesToDelete)
% 
%% Input 
% ------
% indexEnemiesToDelete: the indices of the enemies to be deleted
%
%% Output :
% -------
% NONE
% 
%% Dependencies ϵ:
% -------
% -- Global Variables Created:
%       none
% -- Global Variables Used:
%       queueGlobalEnemies
%       emptyEnemyStruct
%       numAvailGlobalEnemies
%       availGlobalEnemies
% -- Global Variables Modifed:
%       queueGlobalEnemies
%       emptyEnemyStruct
%       numAvailGlobalEnemies
%       availGlobalEnemies
% -- Functions Used:
%       none
%
%% Created by Mingjing Zhang, Stellari Studio, 2011.

%% Update History
%
%  Date                     Updater                 Modifications Made
% --------------            -----------------       --------------------
%  Mar 15, 2011             M. Zhang                wrote it
% --------------            -----------------       --------------------

%% --------------------Code Starts Here -------------------------

%% Declare the Global Variables
global queueGlobalEnemies
global emptyEnemyStruct
global numAvailGlobalEnemies
global availGlobalEnemies
global usedGlobalEnemies

%% Main Code
% Get the number of the enemies to delete
% ȡҪɾԪصĸ
nEnemiesToDelete = numel(indexEnemiesToDelete);

if nEnemiesToDelete == 0
    return;
end
% Add the indices to the end of aGE
% ҪɾԪؼaGEβ
availGlobalEnemies(numAvailGlobalEnemies+1:...
    numAvailGlobalEnemies+nEnemiesToDelete) = indexEnemiesToDelete;

% Update the nAGE value
% nAGE
numAvailGlobalEnemies = numAvailGlobalEnemies + nEnemiesToDelete;

% Delete the data in the enemy queue
stl_deleteFromGlobalImageHandles([queueGlobalEnemies(indexEnemiesToDelete).ImageHandleIndex]);

try
queueGlobalEnemies(indexEnemiesToDelete) = emptyEnemyStruct;
catch
    a = 3;
end

usedGlobalEnemies(indexEnemiesToDelete) = false;


%% Note that the elements in queueGlobalEnemies ARE removed. 
% ע⣺ ȷʵɾqueueGlobalEnemiesеԪأЩԪرΪ
% á
%% --------------- Code Ends Here --------------------------------
return;

Contact us