What is a Scratch Module An overview of

  • Slides: 13
Download presentation
What is a Scratch Module An overview of Scratch modular programming specifications John, john@build-it-yourself.

What is a Scratch Module An overview of Scratch modular programming specifications John, john@build-it-yourself. com Yuan, yuandong 84@yahoo. com

Scratch Module Overview Modular coding enables you to: • Create complex projects faster. •

Scratch Module Overview Modular coding enables you to: • Create complex projects faster. • Change code easily. • Make your code more reliable. Module 1 Module 2 Module 4 Stage Module 3 www. Build-It-Yourself. com

Scratch Module Specs 1) 2) 3) 4) 5) 6) Use common splash screen. Use

Scratch Module Specs 1) 2) 3) 4) 5) 6) Use common splash screen. Use common input/output format. (API, Hooks) Write short blocks of code. Add comments. Organize code layout logically. File naming convention for templates • “m-descriptive name” (module) • “s-descriptive name” (story line) • “g-descriptive name” (game) 7) Use original art work. 8) Use a stop script for every block of code. 9) Messages and variables should be unique and descriptive www. Build-It-Yourself. com

Scratch Module Test Procedure Target audience: 8 -13 years intermediate Scratchers 1) Can it

Scratch Module Test Procedure Target audience: 8 -13 years intermediate Scratchers 1) Can it be edited in 5 minutes after opening the code. 2) Will it run without conflict in ‘module-test’ project. - Do all modules start when called? - Do all scripts stop when not needed? 3) Are messages and variables unique? - forbidden list: = time -> time-rocket-ctrl = start -> start-rocket-ctrl = go = end -> end-rocket-ctrl = stop 4) Are all blocks of code stopped when the module stops? www. Build-It-Yourself. com

Name: m-grow-title Function: Make a title frame grow across the screen Inputs: Receive broadcast

Name: m-grow-title Function: Make a title frame grow across the screen Inputs: Receive broadcast "start-grow" Outputs: Broadcast "stop-grow“ Variables: scene = grow-title (module running) scene = 0 (module stopped) Yuan Dong - Nov 2010 yuandong 84@yahoo. com

Module input / output Broadcast message, ‘start-module-name’ to start module main code. Keyboard, mouse

Module input / output Broadcast message, ‘start-module-name’ to start module main code. Keyboard, mouse and other sensor inputs (optional) Scratch Module Global scene variable that enables and disables module execution. www. Build-It-Yourself. com Broadcast message, ‘stop-module name’ when module stops executing. Variables (optional)

Module Stage The Module Stage starts and stops module execution. The ‘scene’ variable must

Module Stage The Module Stage starts and stops module execution. The ‘scene’ variable must be set in the stage before the “start” signal of a module is broadcasted. Broadcast message, ‘stop-last module name. ’ Module Stage Broadcast message, ‘start-next module name. ’ Global scene variable that monitors module execution. www. Build-It-Yourself. com

Scene Variable and Start / Stop Broadcast Messages The scene variable enables you to

Scene Variable and Start / Stop Broadcast Messages The scene variable enables you to stop and start a module in the middle of execution. The scene variable should be set in the module stage so that when you import modules into the bigger project, all the scene variables will be changed in the same place. The scene variable should be the text name of the module. Set the scene variable to module name when you start the module. Set the scene variable to 0 when you stop the module. Make sure you set the scene variable before you broadcast a message to start the next module. How to set them up in a single module Stage of each module Set scene = next-scene Set scene = mod-1 Set scene = last-scene Broadcast start-mod-1 Broadcast stop-mod-1 Time www. Build-It-Yourself. com

Scene Variable and Start / Stop Broadcast Messages How it looks in a bigger

Scene Variable and Start / Stop Broadcast Messages How it looks in a bigger project Stage of the bigger project (with 10 modules) Set scene = mod-2 Set scene = mod-1 Broadcast start-mod-1 start Set scene = mod-3 Broadcast start-mod-2 Broadcast stop-mod-1 Broadcast start-mod-2 Broadcast stop-mod-2 Time Set scene = mod-10 Broadcast stop-mod-9 Set scene = end Broadcast start-mod-10 Broadcast stop-mod-10 Time end

Module Stage Example code in the module stage www. Build-It-Yourself. com

Module Stage Example code in the module stage www. Build-It-Yourself. com

Module Stage Example code in the stage of the bigger project www. Build-It-Yourself. com

Module Stage Example code in the stage of the bigger project www. Build-It-Yourself. com

Module Sprite Code Example code in the module sprite www. Build-It-Yourself. com

Module Sprite Code Example code in the module sprite www. Build-It-Yourself. com

Modules and Mini Games to Make Modules: Mini games 3 D Title Grow Asteroids

Modules and Mini Games to Make Modules: Mini games 3 D Title Grow Asteroids Landscape Outline Walker Pong Rocket Control and Crash in a Typing Game Scrolling Background Skill Measuring Game Turn / Forward Rocket Control in 2 -D Racing Game a Static Background 3 -D Racing Game Up / Dwn / Rt / Lt Rocket Capture Game Control in a Static Background Trivia Game (with answers and Game Timer score in a list) Alarm Clock Dance Game Animated flying bird Mario Game Avatar creator Voice recognition Under development of interns: Mouse follower Travis Ankit Yuan Connor Ayla Benjamin Jumping object Thank you very much for reading this overview. Have a question or suggestion? Please contact yuandong 84@yahoo. com or john@build-it-yourself. com. For more about the project, http: //build-it-yourself. com/biy-projects/projscratch-templates/index-scratch-templates. html.