image thumbnail

Snake3D

by

 

01 May 2012 (Updated )

3-dimensional version of the classic Snake. playsnake starts the game!!! Takes some practice.

snake3dending.m
while lif>0
    Snake3d
end
load snakescore
gameovr=audioplayer(gmov,Fs);
play(gameovr)
save('snakevars');
delete(fh)
if apples>highscore
    name=inputdlg('Name?');
    highscore= apples;
    highscoren=name;
    save('snakescore', 'highscore', 'highscoren','-append')
end
callstr = 'set(gcbf,''Userdata'',double(get(gcbf,''Currentcharacter''))) ; uiresume ' ;
fh = figure('keypressfcn',callstr, ...
    'windowstyle','modal',...
    'position',[.25*sw .25*sh .5*sw .5*sh],...
    'Name','SpaceSnake', ...
    'userdata','timeout');
set(gcf,'Color',[0,0,0])
uicontrol('Style','Text', ...
    'String','GAME OVER',...
    'Position',[.16*sw .33*sh .18*sw .09*sh], ...
    'ForegroundColor','y', ...
    'BackgroundColor','k', ...
    'FontWeight','bold', ...
    'FontSize', 30);
uicontrol('Style','Text', ...
    'String',{'Score:' num2str(apples)},...
    'Position',[.19*sw .2*sh .12*sw .12*sh], ...
    'ForegroundColor','y', ...
    'BackgroundColor','k', ...
    'FontWeight','bold', ...
    'FontSize', 25);
uicontrol('Style','Text', ...
    'String','Press any key to continue', ...
    'Position',[.22*sw .1*sh .06*sw .06*sh], ...
    'ForegroundColor','w', ...
    'BackgroundColor','k');
uiwait
delete(fh)
clear
playsnake

Contact us