

The world is digital, but life is analog..


There is a moment in every programming class that I look forward to most — the moment a student’s code stops being text on a screen and becomes something alive. This week, in Steps 2 and 3 of our Snake Game Python tutorial, that moment arrived. Step 2: The Game Loop — Where It All … Continue reading “Week 2 – DRE2213 / BTE1522 – Step 2 (Loops), Step 3 (Movements)”
There is a moment in every programming class that I look forward to most — the moment a student’s code stops being text on a screen and becomes something alive. This week, in Steps 2 and 3 of our Snake Game Python tutorial, that moment arrived.
Step 2: The Game Loop — Where It All Begins
We started from the loop. Before this session, students had a window and a grid — static, silent, waiting. Step 2 introduced the while loop that makes the game breathe: the game loop. Every frame, the loop reads events from the keyboard, updates the game state, and redraws the screen.

What made the difference this week was the live animated demo built into the tutorial page. Students could see the AI-controlled snake running in real time before writing a single line of code. As we walked through the structure — while running: → for event in pygame.event.get(): → clock.tick(FPS) — students could map each line directly onto the snake’s behaviour they had just watched. When I explained that removing clock.tick() would make the snake blur across the screen too fast to see, one student immediately asked: “So the clock is like breathing — it controls the pace?” Exactly right.

The animation was not decoration. It was the bridge between code and concept. Students arrived already holding a mental model of what the loop does; we just needed to show them the Python that describes it.
Step 3: Direction & Movement — The Syarat for Movement
Step 3 is where computational thinking deepened. The snake needed to move in response to arrow keys — but not just any key press. The snake cannot reverse direction: pressing LEFT when moving RIGHT must be ignored.

This is where we introduced syarat — conditions. The if / elif chain that maps key events to direction changes became the centrepiece of the lesson. Students had to think through the logic before writing it:
“If the UP key is pressed — but only if we are not already moving DOWN — change direction.”
That one sentence is a boolean condition. Many students initially wrote code that let the snake reverse into itself. Watching the game crash the moment they pressed the wrong key was, genuinely, the best teaching moment of the session. The animation made the bug visible: the snake folded back on itself and the game ended. No abstract error message — just immediate, observable consequence.

We then walked through the guard condition: if new_direction != opposite(current_direction). The word syarat resonated well — it is exactly a precondition, a rule the movement must satisfy before it is allowed. Students began to see conditionals not as syntax but as rules of a system.
What We Observed
By the end of the session, students were no longer reading code line by line — they were reading it as behaviour. “This part checks the event. This part updates direction. This part moves the head.” The animated snake on screen gave them a reference point for every function. Several students stayed back to try making the snake move faster by adjusting FPS, which is precisely the kind of experimental curiosity the module is designed to encourage.
The Computational Thinking activities — the decomposition cards and the algorithm sequencer on the home page — also helped ground abstract ideas before students touched the code. Naming the game loop’s steps in order (“Read keys → Calculate new head → Check collision → Draw”) before implementing them gave students a plan, not just a task.

Coming Up: Step 4
Step 4 — Snake Body — is where cognitive demand rises sharply. Lists, insert(), pop(), and collision detection with the body itself. Based on this week’s engagement, students are well-positioned. They understand the loop, they understand conditions, and they have seen the game reward correct logic in real time.
That, for now, is the best foundation we could ask for.
BTE1522


















DRE2213

























Welcoming Batch 2 Online Bootcamp =)
Welcoming Batch 2 Online Bootcamp =)


















