============
== pin tu ==
============
language:delphi
version: 0.02
author: tony (
[email protected])
date: 2002.01.13
introduction
============
Most of the jigsaw puzzles I've seen before have square tiles, and many of them can only be moved by exchanging the positions of two tiles. It feels so different from real jigsaw puzzles that it's very uncomfortable.
Not long ago, I saw a jigsaw puzzle included in "The Legend of Zhao Yun of the Three Kingdoms". Its tiles have irregular edges (with concave and convex edges), and you can drag any tile in the window. This made me think... I came up with the idea of making a similar software myself. (Then I saw a foreign jigsaw puzzle called bjig32. It was very good. If I had seen it before I started developing this program, maybe I wouldn’t have thought about developing it myself, because in my opinion There is no way to develop a puzzle game as good as it.)
how i implement it
==================
The entire system of the game includes two classes designed by myself, TTuObj and TTuMng.
TTuObj - refers to a tile, which is a small piece of picture after being cut. It has irregular boundaries and can move in the container in which it is located in response to mouse drag events. I designed this class to inherit from TObject, and then generate a TPanel and a TImage respectively in the constructor (the reason why it is not inherited from TControl or directly inherited from TPanel is because I am not very familiar with using vcl to write controls. If If you can, rewrite it), TPanel is used to generate irregular edge shapes, because TImage does not have a Handle and cannot change its shape (I think so), and TImage is used to display images and Provides mouse events. In addition, each TTuObj also records the pointers of the TTuObj around it and whether a connection has been established. This provides the ability to determine whether the two tiles are connected when they are close to each other, and to move any tile after the tiles are connected. It can move the tiles it is connected to.
TTuMng - is the manager of the jigsaw puzzle game. It is responsible for dividing a complete picture into individual tiles, managing them centrally, and determining whether all the tiles are connected (that is, the game is over).
known bugs
==========
The efficiency of the entire system is still very low, especially when moving a tile, the flickering is very severe. After preliminary judgment, I think it is because when a tile is moved, the PAINT event of the tile itself will first be triggered, and then the PAINT event of the tile itself will be triggered. PAINT event of the container where the tile is located, which means that all tiles will be redrawn once. The redrawing of irregular edge controls is inherently inefficient, so it will flicker like this. I tried to handle the WM_PAINT message processing function of AImage in TTuObj myself (that is, redrawing is not allowed when the tile is being dragged), but I found that after moving the tile, it left an afterimage wherever it passed. The puzzle game in "Three Kingdoms Zhao Yun" was written in DirectX, and there was no flicker at all. Maybe I will try to write it in DirectX in the future.
hope u can join and improve it!!!!!!