FINAL PROJECT

The Idea of the Game

When I knew the topic and the method of this project, the first idea coming out of my mind was the thing about the basketball. It is the "basketball machine". I am a die-hard basketball fan, and I put the basketball machine and the 2k sports basketball series together. Players can use the smartphone as the wii remote to shoot the ball.

The Full Code

replay = 1;

while replay == 1

clear all;

connector on

pic = imread('C:\Users\Johnny\Pictures\2K18.jpg');

image(pic);

[y, fs] = audioread('C:\Users\Johnny\Music\NBA on ESPN Playoff Theme.mp3');

sound(y, fs);

m = mobiledev;

score = 0;

ra = round(3*rand(1,10))+1;

pause(7);

clear sound;

for i = 1:4

pic = imread('C:\Users\Johnny\Pictures\Kobe Bryant.jpg');

image(pic);

pause(2);

[y, fs] = audioread('C:\Users\Johnny\Music\Oracle Arena Sounds.mp3');

sound(y, fs);

if ra(i) == 1

pic = imread('C:\Users\Johnny\Pictures\basket.jpg');

elseif ra(i) == 2

pic = imread('C:\Users\Johnny\Pictures\basket right.jpg');

elseif ra(i) == 3

pic = imread('C:\Users\Johnny\Pictures\basket left.jpg');

elseif ra(i) == 4

pic = imread('C:\Users\Johnny\Pictures\basket.jpg');

end

image(pic);

pause(2);

m.logging = 1;

pause(3);

m.logging = 0;

[o,t] = orientlog(m);

roll = o(:,3);

s = size(roll,1);

c = roll(s,:)

load_system('fieldgoal');

sim('fieldgoal');

co = min(result);

if co==1&& ra(i)==3

pic = imread('C:\Users\Johnny\Pictures\get it.jpg');

score = score+3;

elseif co==2&& ra(i)==1

pic = imread('C:\Users\Johnny\Pictures\get it.jpg');

score = score+2;

elseif co==2&& ra(i)==4

pic = imread('C:\Users\Johnny\Pictures\get it.jpg');

score = score+2;

elseif co==3&& ra(i)==2

pic = imread('C:\Users\Johnny\Pictures\get it.jpg');

score = score+3;

else

pic = imread('C:\Users\Johnny\Pictures\nick-young-3-point-miss.jpg');

end

image(pic);

pause(4);

clear sound;

end

if score > 8

pic = imread('C:\Users\Johnny\Pictures\MVP Mode.jpg');

else

pic = imread('C:\Users\Johnny\Pictures\lock room go home.jpg');

end

image(pic);

pause(2);


pic = imread('C:\Users\Johnny\Pictures\pause menu quit.jpg');

image(pic);

pause(2);


m.logging = 1;

pause(3);

m.logging = 0;


[o,t] = orientlog(m);

roll = o(:,3);

s = size(roll,1);

c = roll(s,:)

load_system('fieldgoal');

sim('fieldgoal');

co1 = min(result);


if co1==1

replay = 1;

else

replay = 0;

end

end


Store and Display the Image and Decide the Time of Showing an Image

pic = imread('C:\Users\Johnny\Pictures\2K18.jpg');

image(pic);

pause(7);

Store, Sound and Stop the Song

[y, fs] = audioread('C:\Users\Johnny\Music\NBA on ESPN Playoff Theme.mp3');

sound(y, fs);

clear sound;

Connect the Matlab Mobile

connector on

m = mobiledev;

Choose the Random Number from One to Four in a (1, 10) Matrix

ra = round(3*rand(1,10))+1;

Start or Stop Getting the Signal from the Smartphone

m.logging = 1;

m.logging = 0;

Get the Data of the Orient from the smartphone and Choose the Z-axes Data

[o,t] = orientlog(m);

roll = o(:,3); %o(:,1) -> X axes, o(:,2) -> Y axes, o(:,3) -> Z axes

s = size(roll,1);

c = roll(s,:)

Load the Simulink System, Get the Data from it and Change the Signal to a Value

load_system('fieldgoal'); &The fieldgoal is the name of the simulink

sim('fieldgoal');

co = min(result); %The signal of the result is data versus time, so we choose the minimum

The Position You Shoot the Basketball

(1. Shoot right 2. Shoot middle 3. Shoot left)

Whether You Get the Shot or Not

(1. Get the shot 2. Miss the shot)

If Reach the Standard Score

(1. Reach the score and win the trophy 2. Don't reach the score. Go home and practice)

Quit the Game or Replay the Game

My Simulink and the Stateflow

(Get the Constant c from the Matlab. Determine the Angle and Give Them value.)

Demo Video