Module · Detail

Frogger: Screen Control and Screen Boundaries

This module introduces the implementation of inputs as controlling actions within a game rule. At the same time, it shows how movement logic is modeled and limited to screen boundaries in fixed raster steps.

Time 20 minutes
Format frameCraft
Language Python 3
Tasks 1
Preview image: Frogger: Screen Control and Screen Boundaries

Introduction (Original excerpt)

You turn the step from input to movement: keyboard actions are bound, and a rule moves the frog in a 32px raster. Then you limit the position so that the figure never runs out of the window.

Didactic classification

Subjective objective

This module deals with the implementation of inputs as controlling actions within a game. Initially, an abstract input model with actions is introduced, which maps multiple keys to a common game action. Then a rule is implemented that evaluates these actions and moves the game figure in fixed raster steps. At the same time, the connection between input, rule, and state change is made clear through the use of structured decision logic. Another focus lies on limiting coordinates within the visible game field. This makes it clear how mathematical boundary conditions and gameplay mechanics are connected with each other. The module thus illustrates the interplay between input model, game rule, and position logic.

Competence development

Didactic added value in teaching

Lesson flow

1

Grid movement via keyboard + limitation

In this step, an action model for the game figure is defined by binding multiple key inputs to common movement actions. Subsequently, a game rule is implemented that evaluates these actions and moves the figure in fixed grid steps. Finally, a limiting logic is added to ensure that the figure cannot leave the playing field.

  • Input processing and grid movement
  • Typical challenge: correct decision structure and limitation of coordinates

Work assignment (excerpt)

1. Bind the actions "up", "down", "left", and "right" to arrow keys and WASD. 2. Implement a movement rule with grid steps of 32 pixels. 3. Limit the position of the game figure using the window size to the visible screen area.

Example (excerpt)

The following fragment shows the central structure of the movement logic with grid-based control.

1
2
3
4
5
6
7
8
9
move_step = 32
if ctx.pressed("hoch"):
    e.y -= move_step
elif ctx.pressed("runter"):
    e.y += move_step
elif ctx.pressed("links"):
    e.x -= move_step
elif ctx.pressed("rechts"):
    e.x += move_step

The structure illustrates how inputs are converted into distinct movement actions.

Notes for teaching practice

This module shows how inputs are systematically translated into game rules and from there controlled motion logic is created.

The clearly structured task sequence supports a transparent lesson organization and facilitates the securing of results. Differentiation can be done through additional control logics or extension tasks.

Request a demo access and test the module in your own course context.