[EN] Simple MineSweeper

This article is an experiment to create a Simple MineSweeper as shown in Figure 1, using an ESP32 microcontroller board with a 1.8″ REDTAB st7735 display. The display resolution is 128×160, the same hardware as Simple Tetris [Part 1, Part 2 and part 3] mentioned earlier, still using MicroPython as the main. The explanation starts step by step from screen generation, randomization, counting, motion control, scrolling the options frame turn off visibility, establishing a relationship between identifying where the bomb is likely to be, picking open and counting points at the end of the game.

Simple MineSweeper is one of the first games we’ve been imitating to study ideas and develop programming techniques since the DOS era and the GUI-based Windows operating system DOS, which was written and worked on the DOS operating system at the time, change the mode to graphics mode to contact with mouse and draw pixels by yourself (It’s the same thing as writing on the ESP32 microcontroller board, but it doesn’t have an operating system to use) So let’s get started.

Figure 1 simple mineSweeper
Read More

[EN] Simple Tetris Ep.3

The final article on making a Simple Tetris game using MicroPython and an esp32 microcontroller, as written in parts 1 and 2 of the first two articles, is described in the article below. Readers learn to design data structures, drawing the seven types of falling objects and controlling them to move left, right, and rotate. The second article has the object fall from above and keep the object’s position state. And in this article, the falling objects can be stacked along with moving left, right, and rotating the object will check for collisions with previous objects that have fallen before. Also, check if the object falls to the bottom if there are any rows without spaces. If any rows with no spaces are found, they will be deleted. And finally added a section to check the end of the game in case there is no place for objects to fall and move again as in Figure 1, ending our simple game making process.

Figure 1 Our game in this article
Read More

[EN] Simple Tetris Ep.2

From the previous chapter, we have drawn the background, random objects, object drawing, left and right moving and rotating. In Part 2 of the article, which is the preceding final chapter of the Tetris series, the topic is about creating a backdrop as a grid data structure. If an object falls to the bottom, it converts that object to a table of data as shown in Figure 1, and improves the way the object falls and controls/renders the new object by using a timer without checking for collisions from moving left / right, checking if the falling object overlaps the previous object, rotation and row cutting, which will be discussed in the last article or Simple Tetris Ep.3

Figure 1 The game in this article
Read More

[EN] Simple Tetris Ep.1

This article introduces how to write a simple Tetris game by displaying it in a grid of 10 widths and a height of 16 as shown in Figure 1. Using esp32 microcontroller board connected to ST7735 display and 8 switches for controlling. Importantly it is written in Python via MicroPython compiled using the st7735_mpy library. In this article, we talk about storing 7 types of objects that fall, to support the display and rotation of objects with moving objects left and right. The controls and logic of the Tetris game will be discussed in the next article.

Figure 1 Sample game in this article
Read More

[TH] Simple MineSweeper

บทความนี้เป็นการทดลองสร้างเกม Simple MineSweeper ดังภาพที่ 1 ซึ่งใช้บอร์ดไมโครคอนโทรลเลอร์ ESP32 กับจอแสดงผล st7735 แบบ REDTAB ขนาด 1.8″ ความละเอียดของการแสดงผลเป็น 128×160 อันเป็นฮาร์ดแวร์เดียวกับเกม Simple Tetris [ตอนที่ 1, ตอนที่ 2 และตอนที่ 3] ที่ได้กล่าวไปก่อนหน้านี้ โดยยังคงใช้ MicroPython เป็นหลักเช่นเดิม และการอธิบายจะเริ่มเป็นขั้นตอน ๆ ไป จากสร้างหน้าจอ สุ่มค่า การนับค่า การควบคุมการเคลื่อนที่ การเลื่อนกรอบตัวเลือก การปิดไม่ให้เห็นข้อมูล การสร้างความสัมพันธ์ระหว่างการระบุว่าตำแหน่งใดน่าจะเป็นระเบิด การเลือกเปิด และการนับคะแนนเมื่อจบเกม

ตัวเกม Simple MineSweeper เป็นเกมแรก ๆ ที่พวกเราทำเลียนแบบเพื่อศึกษาวิธีคิดและพัฒนาเทคนิคการเขียนโปรแกรมมาตั้งแต่ยุคระบบปฏิบัติการ DOS และ Windows ที่เป็น GUI ของ DOS ซึ่งตอนนั้นเขียนและทำงานบนระบบปฏิบัติการ DOS พร้อมทั้งต้องเปลี่ยนโหมดเป็นกราฟิกส์โหมด ติดต่อกับเมาส์ และสั่งวาดพิกเซลเอง (จะว่าไปแล้วก็เหมือนกันกับการเขียนบนบอร์ดไมโครคอนโทรลเลอร์ ESP32 แหละครับ แต่ไม่มีระบบปฏิบัติการให้ใช้) … ว่าแล้วมาทดลองสร้างกันดีกว่าครับ ดูจะรำลึกอดีตกันเนิ่นนานเลยทีเดียว

ภาพที่ 1 เกม simple mineSweeper
Read More

[TH] Simple Tetris Ep.3

บทความตอนสุดท้ายของการทำเกมเตตริสแบบง่าย (Simple Tetris) ที่ใช้ MicroPython กับไมโครคอนโทรลเลอร์ esp32 ตามที่ได้เขียนถึงในตอนที่ 1 และ 2 จาก 2 บทความแรกนั้น ผู้อ่านได้เรียนรู้การออกแบบโครงสร้างข้อมูล การวาดวัตถุที่ตกลงมาทั้ง 7 ชนิด และการควบคุมวัตถุให้เคลื่อนที่ไปทางซ้าย ขวา และการหมุน ส่วนในบทความที่ 2 ได้ให้วัตถุตกลงมาจากด้านบนและเก็บสถานะตำแหน่งของวัตถุเอาไว้ และในบทความนี้เป็นการทำให้วัตถุที่ตกลงมานั้นซ้อนกันได้ พร้อมทั้งการเลื่อนซ้าย ขวา และการหมุนวัตถุจะตรวจสอบการชนกับวัตถุเก่าที่เคยตกลงมาก่อน พร้อมทั้งตรวจสอบว่าเมื่อวัตถุตกลงมาจนถึงด้านล่างแล้วนั้นมีแถวใดบ้างที่ไม่มีช่องว่าง ถ้าพบแถวที่ไม่มีช่องว่างจะทำการลบแถวนั้นออกไป และสุดท้ายได้เพิ่มส่วนของการตรวจสอบการสิ้นสุดเกมในกรณีที่ไม่มีที่จะให้วัตถุตกลงมาและเคลื่อนที่ได้อีกดังภาพที่ 1 เป็นอันสิ้นสุดกระบวนการสร้างเกมแบบง่าย ๆ ของเรา

ภาพที่ 1 ตัวอย่างเกมของบทความนี้
Read More

[TH] Simple Tetris Ep.2

จากตอนที่แล้วเราได้วาดฉากหลัง การสุ่มวัตถุ การวาดวัตถุ การเลื่อนซ้ายขวา และการหมุนไปแล้ว ในบทความตอนที่ 2 ซึ่งเป็นตอนก่อนตอนสุดท้ายของชุดการทำเกม Tetris โดยเนื้อหาเป็นเรื่องของการสร้างฉากหลังเป็นโครงสร้างข้อมูลตาราง ถ้าวัตถุตกลงมาจนถึงล่างสุดจะแปลงวัตถุนั้นให้เป็นข้อมูลหนึ่งของตาราง ดังภาพที่ 1และปรับปรุงเรื่องวิธีการตกลงมาของวัตถุและการควบคุม/แสดงผลวัตถุใหม่ด้วยการใช้ตัวตั้งเวลา โดยยังไม่ตรวจสอบการชนจากการเลื่อนซ้าย/ขวา การตรวจสอบว่าวัตถุตกลงมาซ้อนกับวัตถุก่อนหน้านี้หรือไม่การหมุน และการตัดแถวซึ่งจะกล่าวถึงในบทความตอนสุดท้ายหรือ Simple Tetris Ep.3

ภาพที่ 1 ตัวอย่างเกมของบทความนี้
Read More

[TH] Simple Tetris Ep.1

บทความนี้แนะนำการเขียนเกมเตตริส (Tetris) แบบง่าย โดยแสดงผลในตารางขนาด กว้าง 10 ช่อง และสูง 16 ช่อง ตามภาพที่ 1 โดยใช้บอร์ดไมโครคอนโทรลเลอร์ esp32 ที่ต่อกับจอแสดงผลแบบ ST7735 และสวิตช์สำหรับควบคุมอีก 8 ตัว ที่สำคัญคือ เขียนด้วยภาษาไพธอนผ่าน MicroPython ที่คอมไพล์ให้ใช้ชุดไลบรารี st7735_mpy ซึ่งในบทความนี้กล่าวถึงการจัดเก็บวัตถุทั้ง 7 แบบที่เป็นสิ่งของหรือวัตถุที่ตกลงมาให้รองรับการแสดงผลและการหมุนวัตถุ กับการเลื่อนวัตถุไปทางซ้ายและขวา ส่วนการควบคุมและตรรกะของเกม Tetris จะกล่าวในบทความถัดไป

ภาพที่ 1 ตัวอย่างเกมของบทความนี้
Read More