How to use Matlab to make gold miner Mini Game
In this article, the editor introduces in detail "how to use Matlab to make gold miner Mini Game". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use Matlab to make gold miner Mini Game" can help you solve your doubts.
Effect.
Step by step picture preparation
The pictures used in this article are here.
Background to construct function goldMinerMainfig=figure ('units','pixels','position', [50 100 750 500], 'Numbertitle','off','menubar','none','resize','off',... 'name','goldMiner'); axes (' parent',Mainfig,'position', [0 011],... 'XLim', [0750],... 'YLim', [0500],... 'NextPlot','add',... 'layer','bottom',... 'Visible','on',... 'YDir','reverse',... 'XTick', [],... 'YTick', []); bkgPic=imread ('.\ pic\ bkg.png'); image ([0750], [0500], bkgPic) [manPic,~,manAlp] = imread ('.\ pic\ man.png'); image ([400-60400: 60], [49.5-45, 49.5: 45], manPic,'AlphaData',manAlp)
Draw claws
Because the claw needs to constantly adjust the angle, so it is drawn in surface format, we need to adjust the range of the claw image matrix to [0Power1] and change the transparent value to nan.
[clawPic,~,clawAlp] = imread ('.\ Pic\ claw.png'); clawPic=double (clawPic). / 255; clawPicG=clawPic (:,: 1); clawPicG=clawPic (:,:, 2); clawPicB=clawPic (:,:, 3); clawPicR (clawAlp