๐Ÿธ FROGGER in Python

The same road โ€” but every car is moved by Python

โ† Back to Fun Time
๐Ÿ Starting Pythonโ€ฆ
Score
0
Lives
3
Crossings
0
Best
0

โŒจ๏ธ Controls

  • โ†‘ โ†“ โ† โ†’ or W A S D hop one square
  • Tapping the board hops towards where you tapped
  • P or SPACE pause
  • R start a new game
  • ๐ŸŽฎ Xbox controller? Just plug it in or pair it โ€” the stick and D-pad are the arrow keys, A is SPACE, Menu pauses and View starts again

๐ŸŽฏ How to play

  • Hop from the bottom bank to the top without being run over.
  • The striped rows are safe โ€” the one in the middle is a place to stop and think.
  • You get three frogs. Every crossing makes the traffic faster.
  • Odd rows drive right, even rows drive left. Watch both ways!

๐Ÿ† Scoring

  • 10 points for every row you reach for the first time.
  • 100 points for a whole crossing.
  • Hopping back and forth pays nothing โ€” a row only counts once.
  • Tip: wait on the safe island until a gap opens all the way up.

๐Ÿง‘โ€๐Ÿ’ป This whole game is Python

There is almost no JavaScript on this page. The browser downloaded Pyodide โ€” a complete Python interpreter compiled to WebAssembly โ€” and then ran the .py files in funtime/pylib/. Python does the rules, the maths and the drawing.

File What it does Good functions to try re-writing
pylib/frogger_rules.py The rules: the lanes, the traffic, the hops lane_speed, wrap_car, move_frog, is_squashed
pylib/frogger_draw.py Painting the road โ€” Python calling the canvas draw_car, draw_frog, render_game
pylib/frogger_web.py The glue: the keyboard, the taps, the loop do_action, on_board_click, frame

๐Ÿ” Compare the two versions. Open lib/frogger-rules.js and pylib/frogger_rules.py side by side โ€” same ideas, two languages.

๐Ÿ› ๏ธ Build it yourself: Build Frogger in Python walks you through the functions one at a time.

โš ๏ธ If the game never starts: the page has to read its .py files, which a browser will not do for a page opened straight off your disk. Use the live site, or run python3 -m http.server in the project folder.