Module · Detail

Frogger: Autos datengetrieben erzeugen

This module introduces data-driven game structures where multiple enemies are automatically generated from a data list. This shows how modeling and implementation work together to systematically generate recurring game objects.

Time 35 minutes
Central concepts are list structures, tuples, loops, and consistent naming conventions. This makes it clear how an abstract model description – here the data structure for traffic lanes – can be directly converted into automated object generation. frameCraft
Language Python 3
Tasks 1
Preview image: Frogger: Autos datengetrieben erzeugen

Introduction (Original excerpt)

You no longer build car enemies by copying and pasting, but data-driven: A list describes the tracks (Y-position, speed, color) and with enumerate and a clear name schema, many entities are automatically generated.

Didactic classification

Subjective objective

This module introduces the principle of data-driven programming. Instead of manually creating individual objects, game objects are generated from structured data. Central concepts are list structures, tuples, loops, and consistent naming conventions. This makes it clear how an abstract model description - here the data structure for lanes - can be directly converted into automated object generation. In addition, the adaptation of existing movement logic is discussed, so that rules can systematically process multiple objects according to a name schema. This module thus illustrates the connection between data model, algorithmic structure and scalable implementation.

Competence development

Didactic added value in teaching

Flow of the lesson unit

1

Track list + Auto-generation + Movement rule

In this step, a data-driven model for enemy vehicles is built. First, a list of lane data is defined and then a function is implemented to automatically generate multiple cars. Finally, the movement rule is adjusted so that all vehicles can be processed iteratively based on a systematic naming scheme.

  • Data modeling and automated object generation
  • Typical challenge: consistent naming schemes and correct loop structure

Work assignment (excerpt)

1. Set a constant for the number of cars per lane. 2. Define a list of data for the lanes with Y-position, speed, and color. 3. Implement a function to automatically generate cars per lane. 4. Call this function in the scene setup using enumerate for each lane. 5. Adjust the movement rule so that all cars can be moved iteratively based on the naming scheme.

Example (excerpt)

The following fragment shows how a consistent naming scheme for automatically generated vehicles is formed.

1
2
3
4
5
6
7
car_spacing = window_width // NUM_AUTOS
for index in range(NUM_AUTOS):
    car_name = "auto_" + str(lane_index) + "_" + str(index)
    start_x = (index * car_spacing + lane_index * 28 + 20) % window_width
    OBJEKT(car_name, pos=(start_x, lane_y), tag="auto")
    RECHTECK(car_name, AUTO_WIDTH, AUTO_HEIGHT, ausloser=True)
    GESCHWINDIGKEIT(car_name, vel_x, 0)

The example illustrates how multiple game objects are systematically generated from a data structure.

Notes for classroom practice

This module shows how structured data models can be systematically translated into automated game objects and thus enable more complex game mechanics.

The clearly structured sequence of tasks supports a transparent organization of the lesson and facilitates the securing of the achieved results. Differenzierung can occur over additional data entries or extensions of the movement logic.

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