Wildcats Tech Logo

Wildcats Tech

FPHS Computer Science

← Back to AP CSP
💡 Use custom blocks for repeated code
🎯 Test small pieces before combining
🔄 Save often and use descriptive names

🚀 Getting Started with Snap!

Snap! is a visual, block-based programming language perfect for learning computational thinking. It's like Scratch but more powerful, preparing you for text-based languages.

🎮 Motion & Sprites

+

Key Blocks:

move (10) steps
turn ↻ (15) degrees
go to x: (0) y: (0)
point in direction (90)

💡 Pro Tips:

  • Coordinate System: Center is (0,0). X goes left (-) to right (+), Y goes down (-) to up (+)
  • Degrees: 0° = up, 90° = right, 180° = down, 270° = left
  • Smooth Movement: Use smaller step values in forever loops for smoother motion
  • Boundaries: Use IF statements with x/y position to keep sprites on stage
🎯 Challenge: Create a sprite that moves in a square pattern using the move and turn blocks. How can you make it repeat forever?

🎨 Looks & Costumes

+

Key Blocks:

say [Hello!] for (2) secs
switch costume to [costume1]
change size by (10)
set [color] effect to (25)

💡 Pro Tips:

  • Animation: Switch costumes rapidly in a loop for smooth animation
  • Visual Feedback: Use "say" blocks to display variable values during debugging
  • Size Matters: Use set size vs change size depending on if you want absolute or relative sizing
  • Effects: Combine color, brightness, and ghost effects for cool visuals
🎯 Challenge: Create a sprite that changes costumes and grows when clicked, then shrinks back to normal size.

📊 Variables & Lists

+

Key Concepts:

set [score] to (0)
change [lives] by (-1)
add [player name] to [high scores]
item (1) of [inventory]

💡 Pro Tips:

  • Naming: Use descriptive names like "playerScore" not "x" or "temp"
  • Scope: Make variables "for all sprites" only when multiple sprites need them
  • Lists vs Variables: Use lists for collections (inventory, leaderboard), variables for single values
  • Initialize: Always set variables to starting values at the beginning of your program
  • List Length: Use "length of list" to avoid index errors when accessing items
🎯 Challenge: Create a simple clicker game with a score variable that increases each time you click the sprite.

🔄 Control Structures

+

Key Blocks:

if <condition> then
repeat (10)
forever
wait (1) secs

💡 Pro Tips:

  • Forever Loops: Great for constant checking (like game loops), but be careful of infinite loops that freeze
  • Repeat vs Forever: Use "repeat" when you know how many times, "forever" for continuous action
  • If vs If-Else: Use if-else when you have two specific outcomes, just if for one action
  • Wait Blocks: Add small waits in forever loops to prevent lag (0.01-0.1 seconds)
  • Nested Loops: You can put loops inside loops for complex patterns (like drawing grids)
🎯 Challenge: Make a sprite that asks "Guess a number 1-10" and keeps asking until you guess correctly, then says "You got it!"

🔢 Operators & Logic

+

Key Blocks:

( ) + ( )
( ) < ( )
( ) and ( )
not <condition>
pick random (1) to (10)

💡 Pro Tips:

  • Math Operations: Use +, -, *, / for arithmetic. Remember order of operations!
  • Comparisons: < less than, > greater than, = equals. Useful in if statements
  • AND/OR Logic: "AND" requires both true, "OR" needs just one true
  • Random Numbers: Great for games! Random (1) to (10) gives 1,2,3...10
  • Join Blocks: Combine text with "join" - useful for creating sentences with variables
🎯 Challenge: Create a "number guessing game" where the computer picks a random number 1-100 and tells you if your guess is too high or too low.

🛠️ Custom Blocks (Functions)

+

Why Use Custom Blocks?

Custom blocks let you create your own reusable commands - like functions in other languages!

💡 Pro Tips:

  • DRY Principle: "Don't Repeat Yourself" - if you use the same code twice, make a custom block!
  • Input Parameters: Add input slots to make blocks flexible (like "drawSquare (size)")
  • Naming: Use clear, action-based names like "drawHouse" or "checkCollision"
  • Organization: Group related custom blocks together (all drawing blocks, all game logic blocks, etc.)
  • Testing: Test custom blocks separately before using them in your main program

Example Custom Block Ideas:

  • drawPolygon (sides) (size): Draw any regular polygon
  • resetGame: Put all the game reset code in one block
  • checkWin: Check if player has won the game
  • enemyMove (speed): Control enemy behavior with parameters
🎯 Challenge: Create a custom "drawStar (size)" block that draws a 5-pointed star of any size.

🐛 Debugging Tips

+

Common Problems & Solutions:

Problem: Sprite moves too fast or too slow

Solution: Adjust step size or add wait blocks in forever loops

Problem: Variables not updating correctly

Solution: Check if variable is initialized, verify you're using "set" vs "change" correctly

Problem: Sprite not responding to events

Solution: Make sure the script starts with the correct "when" block (green flag, key pressed, sprite clicked)

Problem: Code runs once instead of continuously

Solution: Use "forever" loop for continuous checking, not just sequential blocks

💡 Debugging Strategies:

  • Use Say Blocks: Display variable values to see what's happening
  • Test in Steps: Build small pieces, test each one, then combine
  • Check Conditions: Make sure IF statements are checking the right things
  • Reset Between Tests: Click stop, then green flag to reset everything
  • Simplify: Comment out code or remove blocks to isolate the problem

🎮 Project Ideas for AP CSP

🎯 Beginner: Catch Game

Create a game where falling objects must be caught. Use variables for score, forever loops for falling motion, and collision detection.

Difficulty: ⭐⭐☆☆☆

🎨 Intermediate: Drawing App

Build a program that lets users draw by moving the mouse. Use pen blocks, mouse position, and keyboard controls for colors.

Difficulty: ⭐⭐⭐☆☆

🧮 Intermediate: Quiz Game

Create an interactive quiz with multiple questions. Use lists for questions/answers, variables for score, and custom blocks for asking questions.

Difficulty: ⭐⭐⭐☆☆

🚀 Advanced: Platformer Game

Build a side-scrolling platformer with gravity, jumping, and obstacles. Uses complex collision detection and game physics.

Difficulty: ⭐⭐⭐⭐☆

🤖 Advanced: AI Chatbot

Create a chatbot that responds to user input with different answers. Use lists for responses and string operations for pattern matching.

Difficulty: ⭐⭐⭐⭐⭐

📋 Quick Reference Cheat Sheet

Essential Shortcuts

  • Ctrl + Shift + Click: Edit block
  • Right-click block: Duplicate or delete
  • Shift + Click green flag: Turbo mode
  • Drag block to palette: Delete it

Best Practices

  • ✅ Name variables clearly
  • ✅ Use custom blocks for repeated code
  • ✅ Comment complex sections
  • ✅ Save frequently
  • ✅ Test often