Creating Tetris Game with Windsurf

Creating Tetris Game with Windsurf

Previously, I wrote an article about generating code using Deepseek, which was quite popular. Some people suggested using Windsurf instead, claiming it’s even more powerful than cursor. Others mentioned generating more complex code—like Tetris—to showcase the AI’s capabilities.

So, let’s give Windsurf a try. This is an IDE released by Codeium last month, and you can download it from: https://codeium.com/download. It is actually based on VSCode, so you can also use the cline plugin and configure the Deepseek API.

Creating Tetris Game with Windsurf

You need to register for Windsurf first. I logged in directly with my Google account. It’s quite simple and not expensive. Once logged in, the interface looks just like VSCode.

Creating Tetris Game with Windsurf

Windsurf offers both free and paid versions, with the difference being the number of API calls. The free version has very limited premium API calls. It directly connects to GPT-4 and Claude 3.5 without requiring you to input a key. The Cascade Base has unlimited calls but generates slightly inferior code compared to premium.

Creating Tetris Game with Windsurf
Below are the three modes:
Creating Tetris Game with Windsurf

Let’s try generating Tetris with Claude 3.5.

The chat window of Windsurf is on the right. I typed “Create a Tetris game.” The AI quickly generated the code and also explained its thought process in Chinese, which is a nice touch.

Creating Tetris Game with Windsurf

We can see that a tetris_game.py file has been generated, and Windsurf suggests running it with “python tetris_game.py”. Clicking the Accept all button will start the execution.

Creating Tetris Game with Windsurf

No need to write a single line of code; the AI-generated code can run directly, which shows that Claude 3.5 is quite powerful.

It defined a Tetris class and some methods like reset_game, new_piece, etc., totaling 194 lines.

Creating Tetris Game with Windsurf
Creating Tetris Game with Windsurf

This Tetris implementation considers boundaries and has scoring, making it quite complete.

However, I noticed that the blocks descend a bit slowly, and pressing the down arrow key does not accelerate the fall.

So I continued giving instructions, “Pressing the down key can speed up the block’s descent.”

Creating Tetris Game with Windsurf

Then the code was updated, and when the down key is pressed, it adjusts the current speed to fast_fall_speed. Here, I used the Base mode to save on premium points, which is unlimited and free. This small requirement can still be met.

Creating Tetris Game with Windsurf

It still felt slow, so I got lazy with the AI and directly found the speed parameter to change the initial values to 1 and 0.1, which made the speed normal.

Creating Tetris Game with Windsurf

So after testing, using Claude 3.5 to generate the initial code and making some small adjustments in Base mode can indeed create a complete Tetris game.

Actually, I also generated a Snake game, which is also fully runnable.

Creating Tetris Game with Windsurf

Since Windsurf is based on VSCode, you can also install the cline plugin and configure DeepSeek.

Here, you can also use cline to modify the code, which is on the left side of the window. It reads the code and modifies it, but I’m not sure if it’s due to the high number of API calls, but the response speed is a bit slow.

If you’re really going to use AI to write code, I still recommend using Windsurf directly. If you have the budget, go for the premium version; if not, start with the free Base mode. I tried generating Tetris with the Base mode, and the functionality was still lacking; there was no scoreboard, and the blocks could pass through walls, requiring some adjustments to add features.

In the next article, I will try to use Windsurf to write web code and see how to improve productivity.

I’m Yuan Fang, a former architect at Alipay. As a consultant with a technical background, I have served hundreds of companies including Bosideng, Zhangyu, Leng Suan Ling, and Yuan Zu. I share insights on private domains and have recently focused on AI. WeChat: pesome, let’s grow together.

Leave a Comment