song1
clear all;
connector on;
clear m;
m = mobiledev;
fever = 0;
pausetime = 2;
[m1,Fs1]=audioread('1.mp3');
v = VideoReader('1.avi');
h = implay('1.avi');
figure(1);
image(0);
set(gcf, 'Position', [1300, 300, 400, 300]);
figure(2);
image(0);
set(gcf, 'Position', [200, 300, 400, 300]);
h.Parent.Position = [600 550 700 400];
a = v.Duration;
sound(m1/10, Fs1);
play(h.DataSource.Controls);
pause(3);
t = timer('TimerFcn', 'stat=false',...
'StartDelay',a-5);
start(t)
stat=true;
while(stat==true)
test=randi(4);
if fever >= 16
pausetime = 1;
figure(3);
p3 = imread('fever.jpg');
image(p3);
set(gcf, 'Position', [600, 50, 700, 400]);
end
figure(1);
switch test
case 1
p1 = imread('up.jpg');
image(p1);
set(gcf, 'Position', [1300, 300, 400, 300]);
case 2
p1 = imread('right.jpg');
image(p1);
set(gcf, 'Position', [1300, 300, 400, 300]);
case 3
p1 = imread('down.jpg');
image(p1);
set(gcf, 'Position', [1300, 300, 400, 300]);
case 4
p1 = imread('left.jpg');
image(p1);
set(gcf, 'Position', [1300, 300, 400, 300]);
end
clear m;
m = mobiledev;
m.Logging=1;
pause(pausetime);
m.Logging=0;
condition = 0;
output = 0;
figure(1);
image(0);
[or, tor]= orientlog(m);
yOR= or(:,2);
zOR= or(:,3);
ymax=max(yOR);
ymin=min(yOR);
zmax=max(zOR);
zmin=min(zOR);
if ymax<=30 && ymin>=-30 && zmax<=30 && zmin>=-30
condition=0;
elseif ymax>=30
condition=1;
elseif zmax>=30
condition=2;
elseif ymin<=-30
condition=3;
elseif zmin<=-30
condition=4;
end
if condition == test
output = 1;
else
output = 0;
end
load_system('Game_sim');
sim('Game_sim');
if output==1
figure(2);
pic=imread('per.jpg');
set(gcf, 'Position', [200, 300, 400, 300]);
image(pic);
pause(1);
image(0);
else
figure(2);
pic=imread('miss.png');
set(gcf, 'Position', [200, 300, 400, 300]);
image(pic);
pause(1);
image(0);
end
fever = fever + 1;
end
clear sound;
figure(1);
close;
figure(2);
close;
close(h);
delete(t);
figure(3);
pic=imread('end.jpg');
set(gcf, 'Position', [600 550 700 400]);
image(pic);
pause(3);
close;
Game;