Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.15 KB | None | 0 0
  1. classdef Juego < matlab.apps.AppBase
  2.  
  3. % Properties that correspond to app components
  4. properties (Access = public)
  5. UIFigure matlab.ui.Figure
  6. Image matlab.ui.control.Image
  7. EligeatuPokebichoDropDownLabel matlab.ui.control.Label
  8. EligeatuPokebichoDropDown matlab.ui.control.DropDown
  9. EligeatuPokebichoDropDown_2Label matlab.ui.control.Label
  10. EligeatuPokebichoDropDown_2 matlab.ui.control.DropDown
  11. Image2 matlab.ui.control.Image
  12. Image2_2 matlab.ui.control.Image
  13. Image3 matlab.ui.control.Image
  14. Image3_2 matlab.ui.control.Image
  15. Fisico2 matlab.ui.control.Button
  16. Especial2 matlab.ui.control.Button
  17. Lejano2 matlab.ui.control.Button
  18. Fisico1 matlab.ui.control.Button
  19. Especial1 matlab.ui.control.Button
  20. Lejano1 matlab.ui.control.Button
  21. HPEditFieldLabel matlab.ui.control.Label
  22. Damage1 matlab.ui.control.EditField
  23. HPEditField_2Label matlab.ui.control.Label
  24. HPEditField_2 matlab.ui.control.EditField
  25. Image4 matlab.ui.control.Image
  26. Button matlab.ui.control.Button
  27. Image5 matlab.ui.control.Image
  28. end
  29.  
  30.  
  31. properties (Access = private)
  32. Personaje1 % El Bicho
  33. Personaje2 % Sonic
  34. Personaje3 % Shrek Humano
  35. Personaje4 % Shrek
  36. Personaje5 % Raúl Selección
  37. end
  38.  
  39.  
  40. % Callbacks that handle component events
  41. methods (Access = private)
  42.  
  43. % Code that executes after component creation
  44. function startupFcn(app)
  45. app.Fisico2.Enable = 'off';
  46. end
  47.  
  48. % Value changed function: EligeatuPokebichoDropDown
  49. function EligeatuPokebichoDropDownValueChanged(app, event)
  50. value = app.EligeatuPokebichoDropDown.Value;
  51. if strcmp(value, "Pikacho")
  52. app.Image3.ImageSource = 'El_Bicho.png';
  53. app.Personaje1 = 1;
  54. app.Personaje1.vida = 100;
  55. % app.HPEditField_2.Value = app.Personaje1.vida;
  56.  
  57. end
  58. end
  59.  
  60. % Button pushed function: Fisico1
  61. function Fisico1ButtonPushed(app, event)
  62. if app.Personaje1 == 1
  63. ataque = randi([1 100]);
  64. defensa = randi([20 50]);
  65. app.Personaje2.Vida = Vida - (defensa - ataque);
  66. end
  67.  
  68. % if app.Personaje1.Vida == 0
  69.  
  70.  
  71. end
  72. end
  73. end
  74.  
  75. % Component initialization
  76. methods (Access = private)
  77.  
  78. % Create UIFigure and components
  79. function createComponents(app)
  80.  
  81. % Create UIFigure and hide until all components are created
  82. app.UIFigure = uifigure('Visible', 'off');
  83. app.UIFigure.Color = [1 1 1];
  84. app.UIFigure.Position = [100 100 674 425];
  85. app.UIFigure.Name = 'UI Figure';
  86.  
  87. % Create Image
  88. app.Image = uiimage(app.UIFigure);
  89. app.Image.Position = [1 -7 674 441];
  90. app.Image.ImageSource = 'Fondito.png';
  91.  
  92. % Create EligeatuPokebichoDropDownLabel
  93. app.EligeatuPokebichoDropDownLabel = uilabel(app.UIFigure);
  94. app.EligeatuPokebichoDropDownLabel.BackgroundColor = [0.7176 0.2745 1];
  95. app.EligeatuPokebichoDropDownLabel.HorizontalAlignment = 'right';
  96. app.EligeatuPokebichoDropDownLabel.FontName = 'Consolas';
  97. app.EligeatuPokebichoDropDownLabel.FontSize = 15;
  98. app.EligeatuPokebichoDropDownLabel.FontWeight = 'bold';
  99. app.EligeatuPokebichoDropDownLabel.FontColor = [1 1 1];
  100. app.EligeatuPokebichoDropDownLabel.Position = [16 25 170 22];
  101. app.EligeatuPokebichoDropDownLabel.Text = 'Elige a tu Pokebicho';
  102.  
  103. % Create EligeatuPokebichoDropDown
  104. app.EligeatuPokebichoDropDown = uidropdown(app.UIFigure);
  105. app.EligeatuPokebichoDropDown.Items = {'El Bicho', 'Sonic', 'Shrek Humano', 'Shrek', 'Raúl Selección'};
  106. app.EligeatuPokebichoDropDown.ValueChangedFcn = createCallbackFcn(app, @EligeatuPokebichoDropDownValueChanged, true);
  107. app.EligeatuPokebichoDropDown.FontName = 'Consolas';
  108. app.EligeatuPokebichoDropDown.FontSize = 15;
  109. app.EligeatuPokebichoDropDown.FontWeight = 'bold';
  110. app.EligeatuPokebichoDropDown.FontColor = [1 1 1];
  111. app.EligeatuPokebichoDropDown.BackgroundColor = [0.7176 0.2745 1];
  112. app.EligeatuPokebichoDropDown.Position = [201 25 122 22];
  113. app.EligeatuPokebichoDropDown.Value = 'El Bicho';
  114.  
  115. % Create EligeatuPokebichoDropDown_2Label
  116. app.EligeatuPokebichoDropDown_2Label = uilabel(app.UIFigure);
  117. app.EligeatuPokebichoDropDown_2Label.BackgroundColor = [0.9294 0.5804 0.4275];
  118. app.EligeatuPokebichoDropDown_2Label.HorizontalAlignment = 'right';
  119. app.EligeatuPokebichoDropDown_2Label.FontName = 'Consolas';
  120. app.EligeatuPokebichoDropDown_2Label.FontSize = 15;
  121. app.EligeatuPokebichoDropDown_2Label.FontWeight = 'bold';
  122. app.EligeatuPokebichoDropDown_2Label.FontColor = [1 1 1];
  123. app.EligeatuPokebichoDropDown_2Label.Position = [347 335 170 22];
  124. app.EligeatuPokebichoDropDown_2Label.Text = 'Elige a tu Pokebicho';
  125.  
  126. % Create EligeatuPokebichoDropDown_2
  127. app.EligeatuPokebichoDropDown_2 = uidropdown(app.UIFigure);
  128. app.EligeatuPokebichoDropDown_2.FontName = 'Consolas';
  129. app.EligeatuPokebichoDropDown_2.FontSize = 15;
  130. app.EligeatuPokebichoDropDown_2.FontWeight = 'bold';
  131. app.EligeatuPokebichoDropDown_2.FontColor = [1 1 1];
  132. app.EligeatuPokebichoDropDown_2.BackgroundColor = [0.9294 0.5804 0.4275];
  133. app.EligeatuPokebichoDropDown_2.Position = [532 335 126 22];
  134.  
  135. % Create Image2
  136. app.Image2 = uiimage(app.UIFigure);
  137. app.Image2.Position = [16 59 307 49];
  138. app.Image2.ImageSource = 'player1.png';
  139.  
  140. % Create Image2_2
  141. app.Image2_2 = uiimage(app.UIFigure);
  142. app.Image2_2.Position = [349 366 307 49];
  143. app.Image2_2.ImageSource = 'player2.png';
  144.  
  145. % Create Image3
  146. app.Image3 = uiimage(app.UIFigure);
  147. app.Image3.Position = [164 147 138 132];
  148.  
  149. % Create Image3_2
  150. app.Image3_2 = uiimage(app.UIFigure);
  151. app.Image3_2.Position = [379 147 138 132];
  152.  
  153. % Create Fisico2
  154. app.Fisico2 = uibutton(app.UIFigure, 'push');
  155. app.Fisico2.BackgroundColor = [0.9686 0.6549 0.3961];
  156. app.Fisico2.FontColor = [1 1 1];
  157. app.Fisico2.Position = [532 212 129 22];
  158. app.Fisico2.Text = 'Fisico';
  159.  
  160. % Create Especial2
  161. app.Especial2 = uibutton(app.UIFigure, 'push');
  162. app.Especial2.BackgroundColor = [0.9686 0.6549 0.3961];
  163. app.Especial2.FontColor = [1 1 1];
  164. app.Especial2.Position = [532 181 129 22];
  165. app.Especial2.Text = 'Especial';
  166.  
  167. % Create Lejano2
  168. app.Lejano2 = uibutton(app.UIFigure, 'push');
  169. app.Lejano2.BackgroundColor = [0.9686 0.6549 0.3961];
  170. app.Lejano2.FontColor = [1 1 1];
  171. app.Lejano2.Position = [532 147 129 22];
  172. app.Lejano2.Text = 'Lejano';
  173.  
  174. % Create Fisico1
  175. app.Fisico1 = uibutton(app.UIFigure, 'push');
  176. app.Fisico1.ButtonPushedFcn = createCallbackFcn(app, @Fisico1ButtonPushed, true);
  177. app.Fisico1.BackgroundColor = [0.8392 0.6314 0.9686];
  178. app.Fisico1.FontColor = [1 1 1];
  179. app.Fisico1.Position = [16 212 129 22];
  180. app.Fisico1.Text = '4';
  181.  
  182. % Create Especial1
  183. app.Especial1 = uibutton(app.UIFigure, 'push');
  184. app.Especial1.BackgroundColor = [0.8314 0.5882 0.9804];
  185. app.Especial1.FontColor = [1 1 1];
  186. app.Especial1.Position = [16 181 129 22];
  187. app.Especial1.Text = 'Especial';
  188.  
  189. % Create Lejano1
  190. app.Lejano1 = uibutton(app.UIFigure, 'push');
  191. app.Lejano1.BackgroundColor = [0.8 0.5608 0.949];
  192. app.Lejano1.FontColor = [1 1 1];
  193. app.Lejano1.Position = [16 147 129 22];
  194. app.Lejano1.Text = 'Lejano';
  195.  
  196. % Create HPEditFieldLabel
  197. app.HPEditFieldLabel = uilabel(app.UIFigure);
  198. app.HPEditFieldLabel.BackgroundColor = [0.7529 0.9412 0.7529];
  199. app.HPEditFieldLabel.HorizontalAlignment = 'right';
  200. app.HPEditFieldLabel.FontName = 'Arial Black';
  201. app.HPEditFieldLabel.FontSize = 18;
  202. app.HPEditFieldLabel.FontColor = [0.051 0.8588 0.3765];
  203. app.HPEditFieldLabel.Position = [16 251 33 28];
  204. app.HPEditFieldLabel.Text = 'HP';
  205.  
  206. % Create Damage1
  207. app.Damage1 = uieditfield(app.UIFigure, 'text');
  208. app.Damage1.HorizontalAlignment = 'center';
  209. app.Damage1.FontName = 'Arial Black';
  210. app.Damage1.FontSize = 18;
  211. app.Damage1.FontColor = [0.051 0.8588 0.3765];
  212. app.Damage1.BackgroundColor = [0.7529 0.9412 0.7529];
  213. app.Damage1.Position = [64 248 81 31];
  214.  
  215. % Create HPEditField_2Label
  216. app.HPEditField_2Label = uilabel(app.UIFigure);
  217. app.HPEditField_2Label.BackgroundColor = [0.7529 0.9412 0.7529];
  218. app.HPEditField_2Label.HorizontalAlignment = 'right';
  219. app.HPEditField_2Label.FontName = 'Arial Black';
  220. app.HPEditField_2Label.FontSize = 18;
  221. app.HPEditField_2Label.FontColor = [0.051 0.8588 0.3765];
  222. app.HPEditField_2Label.Position = [532 254 33 28];
  223. app.HPEditField_2Label.Text = 'HP';
  224.  
  225. % Create HPEditField_2
  226. app.HPEditField_2 = uieditfield(app.UIFigure, 'text');
  227. app.HPEditField_2.HorizontalAlignment = 'center';
  228. app.HPEditField_2.FontName = 'Arial Black';
  229. app.HPEditField_2.FontSize = 18;
  230. app.HPEditField_2.FontColor = [0.051 0.8588 0.3765];
  231. app.HPEditField_2.BackgroundColor = [0.7529 0.9412 0.7529];
  232. app.HPEditField_2.Position = [580 251 81 31];
  233.  
  234. % Create Image4
  235. app.Image4 = uiimage(app.UIFigure);
  236. app.Image4.Position = [317 191 54 43];
  237. app.Image4.ImageSource = 'vs.png';
  238.  
  239. % Create Button
  240. app.Button = uibutton(app.UIFigure, 'push');
  241. app.Button.Icon = 'play.png';
  242. app.Button.BackgroundColor = [0.3608 0.0118 0.4];
  243. app.Button.Position = [377.5 25 285 74];
  244. app.Button.Text = '';
  245.  
  246. % Create Image5
  247. app.Image5 = uiimage(app.UIFigure);
  248. app.Image5.Position = [16 312 307 103];
  249. app.Image5.ImageSource = 'logo definitivo.png';
  250.  
  251. % Show the figure after all components are created
  252. app.UIFigure.Visible = 'on';
  253. end
  254. end
  255.  
  256. % App creation and deletion
  257. methods (Access = public)
  258.  
  259. % Construct app
  260. function app = Juego
  261.  
  262. % Create UIFigure and components
  263. createComponents(app)
  264.  
  265. % Register the app with App Designer
  266. registerApp(app, app.UIFigure)
  267.  
  268. % Execute the startup function
  269. runStartupFcn(app, @startupFcn)
  270.  
  271. if nargout == 0
  272. clear app
  273. end
  274. end
  275.  
  276. % Code that executes before app deletion
  277. function delete(app)
  278.  
  279. % Delete UIFigure when app is deleted
  280. delete(app.UIFigure)
  281. end
  282. end
  283. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement