Advertisement

[TH] Godot: C# Script Ep.1

          เกมเอนจิน Godot มี 2 ระบบ คือ ระบบที่ใช้งาน GDScript ที่มีหลักภาษาคล้ายกับภาษาไพธอนเป็นภาษาสำหรับควบคุมการทำงาน กับระบบที่ใช้ภาษา C# ในการทำงาน โดยขั้นตอนพื้นฐานในการใช้งานจะเป็นดังนี้

                    1. สร้างโครงงานใหม่ด้วยการคลิกเลือก New Project

                    2. กำหนดที่เก้บโครงงาน และตั้งชื่อโครงงาน หลังจากนั้นคลิกที่ Create Folder แล้วคลิกที่ปุ่ม Create&Edit เพื่อเข้าสู่โหมดการแก้ไขโครงงาน

                    3. เลือกการสร้าง Scene เป็น Node2D และบันทึกไฟล์ฉาก (Scene) เอาไว้

                    4. ใน Tab ชื่อ Inspector ให้เลือกสร้างสคริปต์ด้วยการคลิกที่ Script และเลือก New Script

                    5. เลือกภาษาเป็น C# และคลิก Create เพื่อสร้างไฟล์ที่มีนามสกุลเป็น .cs

                    6. โครงสร้างของไฟล์เป็นดังโปรแกรม 1-10 จะพบรายการทรัพยากรดังในภาพที่ 1-4 อันประกอบไปด้วยภาพไอคอนของโปรแกรม ไฟล์ฉากที่สร้างขึ้น (ในภาพตั้งชื่อเป็น MainScene.tscn) และไฟล์ภาษา C# (ชื่อ MainScene.cs)

Read More
Advertisement

[TH] พื้นฐาน C#

บทความมนี้กล่าวถึงพื้นฐานการเขียนโปรแกรมภาษา C# ที่นำไปใช้ในการเรียนการสอนในรายวิชา การพัฒนาเกม และคณิตร์ศาสตร์คอมพิวเตอร์ โดยเริ่มจากเรื่องของจำนวน การดำเนินการกับจำนวน เงื่อนไข การทำซ้ำ โปรแกรมย่อย อันนำไปสู่การประยุกต์ใช้คณิตศาสตร์เข้ากับเกมหรือนำไปใช้กับการเขียนโปรแกรมด้วย Unity ต่อไป ด้วยเครื่องมือการเขียนโปรแกรมอย่าง Visual Studio, Unity หรือ Godot mono เป็นต้น

Read More
Advertisement

[TH] PyTk

บทความนี้กล่าวถึง pytk อันเป็นไลบรารีเชื่อมประสานกับผู้ใช้แบบกราฟิกส์ หรือ GUI (Graphics User Interface) ของภาษาไพธอนที่เรียกใช้ tkinter (TK Interface) ทำให้สามารถเขียนโปรแกรม GUI ที่ทำงานได้ทั้งระบบปฏิบัติการ Windows, Linux และ macOS โดยการทำงานของ tkinter ของไพธอนเป็นการเชื่อมประสานกับไลบรารี Tcl/Tk อีกชั้นหนึ่ง และบทความนี้ใช้ Thonny เป็น IDE ในการเขียนโปรแกรมตัวอย่าและติดตั้งไลบรารี (อ่านบทความการใช้ Thonny)

การใช้งานจะต้องมีไลบรารี pytk ซึ่งสามารถเขียนโค้ดเพื่อทดสอบการติดตั้งไลบรารีด้วยโค้ดโปรแกรมภาษาไพธอนดังต่อไปนี้

try:
    import tkinter as tk
except ImportError:
    import sys
    print("ไม่พบไลบรารี tkinter!!!")
    sys.exit(0)
print("พร้อมสำหรับ tkinter")
Read More
Advertisement

[TH] Thonny 4

Thonny เป็นเครื่องมือประเภทสภาพแวดล้อมแบบบูรณาการ หรือ IDE (Integrated development environment) ที่พัฒนาโดยชาวอสโตเนียชื่อ Aivar Annamaa ในปี ค.ศ. 2015 ภายใต้สิทธิ์การใช้งานแบบเปิดเผยรหัสโปรแกรม (Open Source) แบบ MIT และคุณสมบัติของโปรแกรมนั้นครอบคลุมการเขียนโค้ด ตรวจสอบโค้ด บริหารจัดการไลบรารีของภาษาไพธอน และรันโปรแกรมภาษาไพธอนที่เขียนขึ้นทำให้เป็นซอฟต์แวร์ที่ทำงานในส่วนของการเขียนและทดสอบการทำงานที่ใช้งานง่ายเหมาะสมกับผู้เริ่มต้น

          การติดตั้ง Thonny ทำได้โดยดาวน์โหลดไฟล์ชื่อ thonny-xxl-4.1.1.exe จากเว็บไซต์ thonny.org ดังภาพที่ ก-1

ภาพที่ ก-1 หน้าจอเว็บไซต์ thonny.org

Read More
Advertisement

[EN] Binary Search Tree

This article is about programming C/C++ language with Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C] and ET-BASE AVR EASY32U4 (Figure 1) or other boards and platforms using C language for learning to code another type of data structure management program that has different storage and management methods, called BST or Binary Search Tree, as in Figure 2, which is a structure that can be applied to collecting data with attributes in which the data on the left node is less than current node and the right node is greater than current node or the opposite, the left node is greater and the right noe is less. Thus, searching for data in the event that the tree is balanced both left and right on the BST structure saves time or number of searches per round by half of available data, for example, there are 100 data sets in the first round, if the current node is not what you’re looking for it, the choice left is to find from the left or right node. This selection causes the data of the other side to be ignored or cut it in half approximately but if the Binary Search Tree is unbalanced, the search speed will not be much different from the Sequential Search.

ET-BASE AVR EASY32U4
Figure 1 ET-BASE AVR EASY32U4
Read More
Advertisement

[EN] Doubly Linked-List

This article is about programming C/C++ language with Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C], ET-BASE AVR EASY32U4 or other boards and platforms that use C language to store temperature/humidity data from the DHT11 sensor (Figure 1) with a dual linked list data structure. The basics of memory reservation, access, memory deallocation can be read in the previous article (Singly Linked List).

Figure 1 Arduino Uno and DHT11
Read More
Advertisement

[TH] Binary Search Tree

บทความนี้เป็นการเขียนโปรแกรมภาษา C/C++ กับบอร์ด Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C] และ ET-BASE AVR EASY32U4 (ภาพที่ 1) หรือบอร์ดอื่น ๆ และแพล็ตฟอร์มอื่น ๆ ที่ใช้ภาษา C เพื่อเรียนรู้การเขียนโปรแกรมจัดการโครงสร้างข้อมูล (Data Structure) อีกประเภทหนึ่งซึ่งมีวิธีการจัดเก็บและจัดการที่แตกต่างกันไปอันมีชื่อว่าต้นไม้แบบ BST หรือ Binary Search Tree ดังในภาพที่ 2 ซึ่งเป็นโครงสร้างที่สามารถนำไปประยุกต์เกี่ยวกับการเก็บข้อมูลที่มีคุณลักษณะที่ข้อมูลทางกิ่งด้านซ้ายมีค่าที่น้อยกว่าตัวเอง และกิ่งด้านขวามีค่ามากกว่าต้นเอง หรือทำตรงกันข้ามคือกิ่งซ้ายมีค่ามากกว่า และกิ่งด้านขวามีค่าน้อยกว่า ทำให้การค้นหาข้อมูลในกรณีที่ต้นไม้มีความสมดุลย์ทั้งทางซ้ายและทางขวาบนโครงสร้าง BST ประหยัดเวลาหรือจำนวนครั้งในการค้นหาลงรอบละครึ่งหนึ่งของข้อมูลที่มี เช่น มีข้อมูล 100 ชุด ในรอบแรกถ้าตัวเองยังไม่ใช่ข้อมูลที่กำลังค้นหา จะเหลือทางเลือกให้หาจากกิ่งทางซ้ายหรือขวา ซึ่งการเลือกทำให้ข้อมูลของอีกฝั่งนั้นไม่ถูกพิจารณา หรือตัดทิ้งไปครึ่งหนึ่งโดยประมาณ แต่ถ้าเป็นกรณีที่ Binary Search Tree นั้นขาดความสมดุลย์จะส่งผลให้การค้นหามีความเร็วไม่แตกต่างกับการค้นหาแบบลำดับ (Sequential Search) เท่าใดนัก

ET-BASE AVR EASY32U4
ภาพที่ 1 บอร์ด ET-BASE AVR EASY32U4
Read More
Advertisement

[TH] Doubly Linked-List

บทความนี้เป็นการเขียนโปรแกรมภาษา C/C++ กับบอร์ด กับบอร์ด Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C] และ ET-BASE AVR EASY32U4 หรือบอร์ดอื่น ๆ และแพล็ตฟอร์มอื่น ๆ ที่ใช้ภาษา C เพื่อจัดเก็บข้อมูลอุณหภูมิ/ความชื้นจากเซ็นเซอร์ DHT11 (ดังภาพที่ 1) ด้วยโครงสร้างข้อมูลแบบลิงค์ลิสต์คู่ โดยพื้นฐานของการจองหน่วยความจำ การเข้าถึง การยกเลิกการจองหน่วยความจำสามารถอ่านได้จากบทความก่อนหน้านี้ (Singly Linked List)

ภาพที่ 1 บอร์ด Arduino Uno และเซ็นเซอร์ DHT11
Read More
Advertisement

[EN] Ender 3 V2

This article talks about the Ender 3 V2 3D printer, which is an improvement from Creality’s most popular models, Ender 3, Ender 3 Pro, with improvements in ease of assembly, usability, part quality, etc. This 3D printer is almost ideal for beginners who are just getting started with 3D printing.

Appearance

Figure 1 Ender 3 V2
Read More
Advertisement

[TH] การตั้งค่า Slicer เบื้องต้นสำหรับการพิมพ์ 3 มิติ

บทความนี้เรามาดูกันเกี่ยวกับการตั้งค่า Slicer เพื่อปรับแต่งค่าตัวแปรต่างๆ ที่จำเป็นต่อการพิมพ์สามมิติให้เหมาะสม โดยใช้ PrusaSlicer ซึ่งค่าทั้งหมดถูกแบ่งเป็น 3 ส่วน ค่าที่ถูกใช้ในบทความนี้เป็นเพียงตัวอย่างบางส่วนเท่านั้น

สิ่งที่ต้องเตรียม

  1. PrusaSlicer ดาวโหลดได้ที่นี่

เริ่มต้นให้เราทำการดาวโหลดโปรแกรม PrusaSlicer และติดตั้งให้เรียบร้อย

เมื่อเปิดโปรแกรมขึ้นมาจะเป็นดังภาพที่ 1

ภาพที่ 1 PrusaSlicer
Read More