Jrp33

Matlab help

Nov 11th, 2025 (edited)
110
0
6 days
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 3.29 KB | Gaming | 0 0
  1. % ENGR 1181 SDP Graphics Preview - Math Jumper
  2.  
  3. %% Initialization: Setup the Scene and Sprites
  4. spriteSize = 16;
  5. zoomFactor = 6;
  6. bgColor = [180 220 255]; % Very Light Sky Blue background
  7.  
  8. % Load the simpleGameEngine
  9. gameScene = simpleGameEngine('Tiles.png', spriteSize, spriteSize, zoomFactor, bgColor);
  10.  
  11. % Define Sprite Indices (AESTHETICS FIX: Using brighter/plain tiles)
  12. IDX_BACKGROUND = 65;    % FIX: Lightest plain tile available (near the water)
  13. IDX_GROUND = 3;         % Busy ground tile for the very bottom layer
  14. IDX_PLATFORM = 26;      % The wooden plank bridge/platform
  15. IDX_CHARACTER = 85;     % The small mushroom/red object (Jumper)
  16. IDX_START_BTN = 79;     % The small chest/crate (Button)
  17. IDX_QUESTION_BOX = 77;  % The large, dark wooden chest (Question Frame)
  18.  
  19. % Define the Scene Size
  20. ROWS = 10;
  21. COLS = 15;
  22.  
  23. ---
  24.  
  25. %% Scene 1: Start Screen/Instructions (drawScene #1)
  26. scene1_matrix = IDX_BACKGROUND * ones(ROWS, COLS);
  27. scene1_matrix(ROWS, :) = IDX_GROUND; % Only the bottom row is the busy ground
  28.  
  29. scene1_matrix(ROWS-1, 7) = IDX_CHARACTER;
  30. scene1_matrix(ROWS-3, 7) = IDX_START_BTN;
  31.  
  32. drawScene(gameScene, scene1_matrix);
  33.  
  34. % Add Annotation Notes
  35. title('Scene 1: Main Menu - Press Start to Begin Math Jumper!');
  36. text(1, 1, 'Note: Features the Start Button (small chest) and the Player (red mushroom).', 'FontSize', 12, 'Color', 'k');
  37.  
  38. % FIX: Turn off annotations after screenshot (to "get rid of the note")
  39. pause(0.5);
  40. set(gca, 'Visible', 'off');
  41.  
  42. % Use Keyboard Input for Transition 1
  43. fprintf('*** Scene 1 Displayed. Press ANY KEY to view Scene 2. ***\n');
  44. getKeyboardInput(gameScene);
  45.  
  46.  
  47. ---
  48.  
  49. %% Scene 2: Gameplay - Active Jump Sequence (drawScene #2)
  50. set(gca, 'Visible', 'on'); % Re-enable axis for new annotations
  51. scene2_matrix = IDX_BACKGROUND * ones(ROWS, COLS);
  52. scene2_matrix(ROWS, :) = IDX_GROUND;
  53.  
  54. % Place platforms
  55. scene2_matrix(ROWS-2, 3:6) = IDX_PLATFORM;
  56. scene2_matrix(ROWS-4, 8:11) = IDX_PLATFORM;
  57. scene2_matrix(ROWS-6, 1:4) = IDX_PLATFORM;
  58.  
  59. % Place the character
  60. scene2_matrix(ROWS-5, 9) = IDX_CHARACTER;
  61.  
  62. drawScene(gameScene, scene2_matrix);
  63.  
  64. % Add Annotation Notes
  65. title('Scene 2: Active Jump Sequence - Score: 3 Jumps');
  66. text(2, 1, 'Note: Player is mid-jump progression, showing dynamic platforms.', 'FontSize', 12, 'Color', 'k');
  67. text(8, 1, 'Score and Lives are tracked (implied text overlay).', 'FontSize', 12, 'Color', 'k');
  68.  
  69. % FIX: Turn off annotations after screenshot
  70. pause(0.5);
  71. set(gca, 'Visible', 'off');
  72.  
  73. % Use Keyboard Input for Transition 2
  74. fprintf('*** Scene 2 Displayed. Press ANY KEY to view Scene 3. ***\n');
  75. getKeyboardInput(gameScene);
  76.  
  77.  
  78. ---
  79.  
  80. %% Scene 3: Gameplay - Math Problem Pop-up (drawScene #3)
  81. set(gca, 'Visible', 'on');
  82. scene3_matrix = scene2_matrix;
  83. scene3_matrix(3:7, 5:10) = IDX_QUESTION_BOX;
  84.  
  85. drawScene(gameScene, scene3_matrix);
  86.  
  87. % Add Annotation Notes
  88. title('Scene 3: Math Problem Pop-up - Solve to Continue!');
  89. text(1, 1, 'Note: Large central chest/box frames the math question (9 + 4 = ?).', 'FontSize', 12, 'Color', 'k');
  90. text(7, 12, 'A countdown timer (implied text) pressures the player to answer quickly.', 'FontSize', 12, 'Color', 'k');
  91. xlabel('Press any key to close the program.');
  92.  
  93. % Final Cleanup
  94. pause(0.5);
  95. set(gca, 'Visible', 'off');
  96. getKeyboardInput(gameScene);
  97. close(gameScene.my_figure);
Tags: Matlab help
Advertisement
Comments
Add Comment
Please, Sign In to add comment