Final Project

Code

number = 5;

imshow('index.PNG');

[Fx,Fs] = audioread('ready.mp3');

sound(Fx,Fs);

while number>0

way = unidrnd(3);

clear m;

m = mobiledev;

switch way

case 1

imshow('mainstraight.PNG');

[Fx,Fs] = audioread('ready.mp3');

sound(Fx,Fs);

pause(1);

case 2

imshow('mainleft.PNG');

[Fx,Fs] = audioread('ready.mp3');

sound(Fx,Fs);

pause(1);

case 3

imshow('mainright.PNG');

[Fx,Fs] = audioread('ready.mp3');

sound(Fx,Fs);

pause(1);

end

m.Logging = 1;

pause(2);

m.Logging = 0;

test=m.Orientation(3);

assignin('base','t',max(test));

load_system('game');

sim('game');

result=max(simout);

if(result==1)

switch way

case 1

imshow('shakey.PNG');

pause(0.5);

m.Logging = 1;

pause(1);

m.Logging = 0;

ay=m.Acceleration(2);

assignin('base','py',max(ay));

load_system('ygame');

sim('ygame');

yresult=max(ysimout);

[Fx,Fs] = audioread('hit.mp3');

sound(Fx,Fs);

imshow('middle1.jpg');

pause(0.5);

imshow('middle2.jpg');

pause(1.5);

if(yresult==2)

number=number-1;

end

if (yresult==1)

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

end

case 2

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

case 3

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

end

elseif(result==2)

switch way

case 1

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(5);

break;

case 2

imshow('shakex.PNG');

pause(0.5);

m.Logging = 1;

pause(1);

m.Logging = 0;

az=m.Acceleration(3);

assignin('base','pz',max(az));

load_system('zgame');

sim('zgame');

zresult=max(zsimout);

[Fx,Fs] = audioread('hit.mp3');

sound(Fx,Fs);

imshow('left1.jpg');

pause(0.5);

imshow('left2.jpg');

pause(1.5);

if(zresult==2)

number=number-1;

end

if (zresult==1)

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

end

case 3

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

end

elseif(result==3)

switch way

case 1

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

case 2

imshow('lose.jpg');

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

case 3

imshow('shakex.PNG');

pause(0.5);

m.Logging = 1;

pause(1);

m.Logging = 0;

az=m.Acceleration(3);

assignin('base','pz',max(az));

load_system('zgame');

sim('zgame');

zresult=max(zsimout);

[Fx,Fs] = audioread('hit.mp3');

sound(Fx,Fs);

imshow('right1.jpg');

pause(0.5);

imshow('right2.jpg');

pause(1.5);

if(zresult==2)

number=number-1;

end

if (zresult==1)

[Fx,Fs] = audioread('lose.mp3');

sound(Fx,Fs);

imshow('lose.jpg');

pause(2);

break;

end

end

end

end

if(number==0)

imshow('win.jpg');

[Fx,Fs] = audioread('win.mp3');

sound(Fx,Fs);

pause(5);

end

Direction

Acceleration(y)

Acceleration(z)

免費建立您的網站!