- clear all;
- t=0;
- while t==0
- clear all;
- connector on
- clear m;
- m = mobiledev;
- one = 0;
- while one==0 %Player1 抽卡.
- photo=imshow('C:\Users\steven\Pictures\新抽卡機.JPG');
- m.Logging = 1;
- pause(3);
- m.Logging = 0;
- [ac, ~] = accellog(m); %take acceleration.
- x = ac(:,1); %take X-axe.
- C=0;
- throw1 = max(x);
- if throw1>=10 % if acceleration is larger than 10.
- number=(4*rand(1,1));%rand(1,1)0-1之間小數
- load_system('project'); %Enter Simulink.
- sim('project'); %Return the 'C' value.
- A = max(C);
- one=one+1;
-
- if (A==1)
- photo=imshow('C:\Users\steven\Pictures\黑金卡.jpg');
- pause(1.5);
- photo=imshow('C:\Users\steven\Pictures\秦始皇.jpg');
- end
- if (A==2)
- photo=imshow('C:\Users\steven\Pictures\白金卡.jpg');
- pause(1.5);
- photo=imshow('C:\Users\steven\Pictures\夏娃.jpg');
- end
- if (A==3)
- photo=imshow('C:\Users\steven\Pictures\金卡.jpg');
- pause(1.5);
- photo=imshow('C:\Users\steven\Pictures\異界龍.jpg');
- end
- if (A==4)
- photo=imshow('C:\Users\steven\Pictures\銀卡.jpg');
- pause(1.5);
- photo=imshow('C:\Users\steven\Pictures\茉莉.jpg');
- end
- end
- if throw1<10
- photo=imshow('C:\Users\steven\Pictures\新抽卡機.JPG');
- pause(1.5);
- end
- end
- pause(2);
- photo=imshow('C:\Users\steven\Pictures\again.jpg'); %Photo to show if you want to play ?
- clear m;
- m = mobiledev;
- m.Logging = 1;
- pause(5);
- m.Logging = 0;
- [oc, tac] = orientlog(m);
- x = oc(:,3);
- throw3 = max(x);
- if throw3>=40 %If you turn right your phone → Play Again.
- t=0;
- elseif throw3<40 %If you turn left your phone → Stop the game.
- t=1;
- photo=imshow('C:\Users\steven\Pictures\over.jpg');
- pause(5);
- end
- end