xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Game development specific discussions.
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:07

This post is invalid, I will post the relevant information here:

viewtopic.php?f=8&t=29057



xywh Game Engine

    Completely open source, you can modify the source code and improve it with me. The engine is still being updated
    Very simple and easy to use, without sacrificing functionality
    Complete information, complete development documents (currently only in Chinese), dozens of examples with lots of comments
    Outstanding performance, I have done comparisons with many 2D renderers, the performance is better (thanks to FBGFX)
    Complete functions, do not require game developers to change the engine while making games
    True 2D engine, not using 3D to simulate 2D, so coordinate processing is more convenient
    Unicode support, the current support is very good, the next version will support it perfectly
    Free trial, code authorization scope belongs to public domain, you can use this engine commercially

    Graphics rendering: You can draw basic shapes such as points, lines, rectangles, circles, etc. on the screen
    Image rendering: You can output a complete image or a part of it on the screen (format: BMP, PNG, GIF, JPG, TAG, XGI...)
    Text rendering: XGE engine supports rendering and typesetting of truetype fonts and xrf bitmap fonts, which is very convenient to use
    You can even load unsupported file formats (pictures, fonts) through a custom loader
    GDI and GDIPlus image support: Although the efficiency is low, some functions are easier to implement with them
    Network: Easy to use event-based TCP Server, TCP Client, UDP network library, IOCP technology high-performance 100,000 connections.
    GUI: At present, it has a complete GUI mechanism and a layout system, but there are few controls and it is still under development.
    Scene: Scene let the difficulty of reducing the use of code development game, a scene piece of code
    Device input: support mouse, keyboard and joystick, dynamic detection or event driven
    Auxiliary library: coordinate system adjustment, view adjustment, screenshots, etc.
    Usability: Encapsulates file reading and writing, INI file access and some usability functions

xywh Game Engine is developed using FreeBasic, based on the FBGFX library, and the audio function is implemented using the BASS library. It is only 300KB before compression.



Author's words:

I am currently implementing the GUI system, but only released button controls, because my energy will be mainly on the implementation of TextBox.
In fact, the GUI system is quite complete, except that the messages of the IME part are not forwarded, the whole mechanism can probably be fixed.
My idea is to make one thing more refined, not a lot of things that are difficult to use. Therefore, only the elements of the button series were developed at the beginning, and then they will be added one by one. You can also merge the elements you developed.
A person's energy is limited. At first, I gave up SDL and a lot of 2D engines and decided to develop it myself. I set out a long development plan for myself. Now I have realized most of it.
Although 2D is lagging behind the times, obviously as an independent developer, it is very rare to be able to control 2D. 3D requires a lot of energy for mathematical calculations. I don't have that much energy, so I only do 2D.
The open source code hopes that this library can be passed on, and that some friends can maintain this library together with me. It still has many features to add, and my development plan has not come to an end.
And the experience of game development tells me that the engine can never keep up with the needs of the game, so I developed a lot of extension interfaces to make the engine as customizable as possible, but it still needs to be constantly updated.
Recently, my work is very leisurely, which also gives me time to iterate the version quickly. I hope everyone will enjoy it.

Chinese is my native language. If I want to read and write English, I need to rely on a translator. Therefore, I am not sure if anyone can understand the above words. I try to use English as much as possible for the comments and release folders(发布目录) in the game. However, it also increased my workload. Some things may require you to use a translator to translate them into English for reading.

If you have any questions, please email me: xywhsoft@qq.com



Source code: https://github.com/CN-xLeaves/XGE
Bin, resources and examples: https://github.com/CN-xLeaves/XGE/tree/master/release



The current version is not a stable version. The stable version will be released in the next few days and can be used for testing. Please be cautious in actual development and use.

In fact, the functions of this version have been tested and should be very stable, but the order of parameter transfer of drawing commands is not uniform. I want to make this part more standard and not change afterwards, so the SDK may be modified. The work will be completed soon (within 1-2 days).


I don’t know how to upload pictures and files. You need GitHub to download the source code. You can download it as a ZIP, and then find the part you need. If you want to demonstrate the picture, I hope to be able to upload some of it, but I am not familiar with the network outside of China. To ensure the access speed of the pictures, you may need your help to post some.



Update:

2020/12/28:
Fixed a serious bug that caused the loading of xgi format pictures and ttf font files to fail.
Added tank battle game code. This game is currently complete, and more functions will be developed in the future.
Added the xui.FreeChilds function, which can directly release the UI elements of the current scene.
Other BUG fixes and adjustments.

2020/12/27:
The scene system BUG is fixed, and the new scene switching logic is used.
The GUI system is bound to the scene. After the scene is switched, the GUI state will be saved, and different scenes have different root elements.
Added two scene-related examples.
Other BUG fixes and adjustments.
Last edited by xywhsoft on Dec 28, 2020 10:11, edited 4 times in total.
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:16

How do i start?

https://github.com/CN-xLeaves/XGE/tree/ ... /freebasic
There are dozens of examples here, and each example is equipped with complete notes and warnings. Some notes will help you avoid detours in the subsequent development process, so your first step should start with reading and modifying these examples.

https://github.com/CN-xLeaves/XGE/tree/ ... eBASIC/OOP
Then make a copy of this directory, which is a development template with an independent environment that has been built, write the code, compile and run, and start game development.



Is there any sample code for the complete game?

Yes, I am porting an earlier version of the tank fighting game, and it is estimated that it will be posted in the next few days.



How should I compile the source code?

I use FbEdit for development, you can download one, and then automatically compile after simple configuration. Manual compilation is also very easy. My habit is that each project has only one bas file, and the others are header files. You only need to compile this file.



What is the future development plan?

The first is TextBox, which is the most important and difficult part of the GUI system, but I implemented it through FBGFX a few years ago, and I need a few days to perfect it; the file package system, the same XGE0 a few years ago I have implemented one in version .6, but I did not do the function of automatically releasing resources by reference counting. I need to re-plan and improve it in this part.

In addition, the game example is also important. I need to develop a stand-alone version of FC Tank Battle, and then allow him to play online.
Last edited by xywhsoft on Dec 28, 2020 9:13, edited 2 times in total.
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:23

Hello World:

Code: Select all

' include XGE header file
#LibPath "..\..\..\library"
#Include "..\..\..\include\xge.bi"



' Init xywh Game Engine
xge.Init(800, 600, XGE_INIT_WINDOW Or XGE_INIT_ALPHA, XGE_INIT_ALL, "XGE - Hello World")

' load font
xge.Text.LoadFont("..\..\..\res\font\xrf\simsun_16px_ucs2.xrf", 0)
xge.Text.LoadFont("c:\windows\fonts\simsun.ttc", 0)

' change font size
xge.Text.SetFontSize(2, 32)

' draw text
xge.Text.DrawRectA(NULL, 0, 100, 800, 200, !"Hello World\n你好,世界\n\nxywh Game Engine\nUse freebasic to develop", &HFF00, 1, 0, XGE_ALIGN_CENTER Or XGE_ALIGN_MIDDLE, 1, 6)
xge.Text.DrawRectA(NULL, 0, 300, 800, 200, !"Hello World\n你好,世界\n\nxywh Game Engine\nUse freebasic to develop", &HFF00, 2, 0, XGE_ALIGN_CENTER Or XGE_ALIGN_MIDDLE, 1, 6)

' wait 5s
Sleep 5000

' release menory by XGE
xge.Unit()
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:24

Draw Image:

Code: Select all

' include XGE header file
#LibPath "..\..\..\library"
#Include "..\..\..\include\xge.bi"



' Init xywh Game Engine
xge.Init(640, 480, XGE_INIT_WINDOW Or XGE_INIT_ALPHA, XGE_INIT_ALL, "XGE - Draw Image")

' load image
' XGE supports loading common file formats
' PNG, JPG, GIF, BMP, TGA and XGI
' XGI format is a compressed image format dedicated to XGE
' It has extremely fast loading speed and reasonable compression ratio (LZ4 compression)
Dim img As xge.Surface Ptr = New xge.Surface("..\..\..\res\back.xgi", 0)

' draw image
img->Draw(0,0)

' free memory it's a good habit
Delete img

' wait 5s
Sleep 5000

' release menory by XGE
xge.Unit()
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:24

Play Sound:

Code: Select all

' include XGE header file
#LibPath "..\..\..\library"
#Include "..\..\..\include\xge.bi"



' Init xywh Game Engine
xge.Init(640, 480, XGE_INIT_WINDOW, XGE_INIT_ALL, "XGE - Play Sound")

' load font
xge.Text.LoadFont("..\..\..\res\font\xrf\simsun_16px_ucs2.xrf", 0)

' draw text
xge.Text.DrawRectA(NULL, 0, 0, 640, 480, "Press ESC to exit", &HFF00)

' load music
Dim bgm As xge.Sound Ptr = New xge.Sound(XGE_SOUND_STREAM, 0, "..\..\..\res\bgm.mp3")

' play music
bgm->Play()

' Wait, press ESC to exit
Do
   Sleep(15)
Loop Until xge.xInput.KeyStatus(SC_ESCAPE)

' free memory it's a good habit
Delete bgm

' release menory by XGE
xge.Unit()
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:25

Scene:

Code: Select all

' include XGE header file
#LibPath "..\..\..\library"
#Include "..\..\..\include\xge.bi"



' Scene is an important function of XGE
' With it, you can deal with different scenes in the game more easily
' You don't have to write all the code together or deal with them extra
' The following function is the standard scene processing template
' It only does one thing, that is, it exits the game when the close button in the window is pressed
' So you'll see a black window, but you don't have to exit regularly, or write code and press the key to exit



' Scene function
Function MainScene(msg As Integer, param As Integer, eve As XGE_EVENT Ptr) As Integer
   Select Case msg
      Case XGE_MSG_FRAME            ' frame Logic processing
         
      Case XGE_MSG_DRAW            ' draw
         
      Case XGE_MSG_MOUSE_MOVE         ' mouse move
         
      Case XGE_MSG_MOUSE_DOWN         ' mouse down
         
      Case XGE_MSG_MOUSE_UP         ' mouse up
         
      Case XGE_MSG_MOUSE_CLICK      ' mouse click
         
      Case XGE_MSG_MOUSE_DCLICK      ' mouse double click
         
      Case XGE_MSG_MOUSE_WHELL      ' mouse whell
         
      Case XGE_MSG_KEY_DOWN         ' keyboard down
         
      Case XGE_MSG_KEY_UP            ' keyboard up
         
      Case XGE_MSG_KEY_REPEAT         ' keyboard hold
         
      Case XGE_MSG_GOTFOCUS         ' got focus
         
      Case XGE_MSG_LOSTFOCUS         ' lost focus
         
      Case XGE_MSG_MOUSE_ENTER      ' mouse enter
         
      Case XGE_MSG_MOUSE_EXIT         ' mouse leave
         
      Case XGE_MSG_LOADRES         ' load resources
         
      Case XGE_MSG_FREERES         ' unload resources
         
      Case XGE_MSG_CLOSE            ' window closing
         Return -1
   End Select
End Function



' Init xywh Game Engine
xge.Init(800, 600, XGE_INIT_WINDOW Or XGE_INIT_ALPHA, XGE_INIT_ALL, "XGE - Scene")

' Start a scene (40fps)
xge.Scene.Start(@MainScene, 40)

' release menory by XGE
xge.Unit()
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:27

XUI Layout:

Code: Select all

' include XGE header file
#LibPath "..\..\..\library"
#Include "..\..\..\include\xge.bi"



' Scene function
Function MainScene(msg As Integer, param As Integer, eve As XGE_EVENT Ptr) As Integer
   Static As xui.Element Ptr ui
   Static As xui.Element Ptr LeftLayout, CenterLayout, RightLayout
   Static As xui.Element Ptr TopLayout, MiddleLayout, BottomLayout
   Static As xui.Button Ptr Btn1, Btn2, Btn3
   Static As xge.Surface Ptr backimg
   Select Case msg
      Case XGE_MSG_FRAME            ' frame Logic processing
         
      Case XGE_MSG_DRAW            ' draw
         xge.Clear()
         backimg->Draw(0,0)
         ui->Draw(NULL)
      Case XGE_MSG_MOUSE_MOVE         ' mouse move
         
      Case XGE_MSG_MOUSE_DOWN         ' mouse down
         
      Case XGE_MSG_MOUSE_UP         ' mouse up
         
      Case XGE_MSG_MOUSE_CLICK      ' mouse click
         
      Case XGE_MSG_MOUSE_DCLICK      ' mouse double click
         
      Case XGE_MSG_MOUSE_WHELL      ' mouse whell
         
      Case XGE_MSG_KEY_DOWN         ' keyboard down
         
      Case XGE_MSG_KEY_UP            ' keyboard up
         
      Case XGE_MSG_KEY_REPEAT         ' keyboard hold
         
      Case XGE_MSG_GOTFOCUS         ' got focus
         
      Case XGE_MSG_LOSTFOCUS         ' lost focus
         
      Case XGE_MSG_MOUSE_ENTER      ' mouse enter
         
      Case XGE_MSG_MOUSE_EXIT         ' mouse leave
         
      Case XGE_MSG_LOADRES         ' load resources
         xge.Text.LoadFont("..\..\..\res\font\xrf\simsun_16px_ucs2.xrf", 0)
         
         ' through the study of the first two examples, we know that it is easy to make a layout by using horizontal and vertical matching
         ui = xui.GetRootElement()
         ui->LayoutMode = XUI_LAYOUT_L2R
         LeftLayout = xui.CreateElement(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 1, XUI_LAYOUT_COORD, "LeftLayout")
         CenterLayout = xui.CreateElement(XUI_LAYOUT_RULER_PIXEL, 0, 0, 160, 480, XUI_LAYOUT_T2B, "CenterLayout")
         RightLayout = xui.CreateElement(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 1, XUI_LAYOUT_COORD, "RightLayout")
         TopLayout = xui.CreateElement(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 7, XUI_LAYOUT_COORD, "TopLayout")
         MiddleLayout = xui.CreateElement(XUI_LAYOUT_RULER_PIXEL, 0, 0, 160, 160, XUI_LAYOUT_T2B, "MiddleLayout")
         BottomLayout = xui.CreateElement(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 2, XUI_LAYOUT_COORD, "BottomLayout")
         ui->Childs.AddElement(LeftLayout)
         ui->Childs.AddElement(CenterLayout)
         ui->Childs.AddElement(RightLayout)
         CenterLayout->Childs.AddElement(TopLayout)
         CenterLayout->Childs.AddElement(MiddleLayout)
         CenterLayout->Childs.AddElement(BottomLayout)
         
         ' fill other elements into these layouts, and we can form our user interface
         Btn1   = xui.CreateButton(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 1, !"开始游戏\n(New Game)")
         Btn2   = xui.CreateButton(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 1, !"载入存档\n(Load)")
         Btn3   = xui.CreateButton(XUI_LAYOUT_RULER_RATIO, 0, 0, 1, 1, !"退出游戏\n(Exit)")
         
         ' add some spaceing to the buttons
         Btn2->Layout.RectBox.TopOffset = 20
         Btn3->Layout.RectBox.TopOffset = 20
         
         ' add three buttons to the middle layout
         MiddleLayout->Childs.AddElement(Btn1)
         MiddleLayout->Childs.AddElement(Btn2)
         MiddleLayout->Childs.AddElement(Btn3)
         
         ' apply layout
         xui.LayoutApply()
         
         ' we can also load a background image to make the image less empty
         backimg = New xge.Surface("..\..\..\res\back.bmp", 0)
         
      Case XGE_MSG_FREERES         ' unload resources
         xge.Text.RemoveFont(1)
      Case XGE_MSG_CLOSE            ' window closing
         Return -1
   End Select
End Function



xge.Init(640, 480, XGE_INIT_WINDOW Or XGE_INIT_ALPHA, XGE_INIT_ALL, "XGE - XUI Layout")
xge.Scene.Start(@MainScene, 40)
xge.Unit()
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 8:57

Export function table (you can understand what functions XGE has):


Code: Select all

Extern XGE_EXTERNCLASS
   /' -------------------------- 栈结构类[结构体] -------------------------- '/
   Type xStack
      ' 构造/析构
      Declare Constructor(max As UInteger, unitsize As UInteger)
      Declare Destructor()
      
      ' 初始化/卸载
      Declare Function Init(max As UInteger, unitsize As UInteger) As Integer
      Declare Sub Unit()
      
      ' 压栈
      Declare Function Push(dat As Any Ptr) As Integer
      
      ' 出栈
      Declare Function Pop(c As UInteger) As Any Ptr
      
      ' 栈顶
      Declare Function Top() As Any Ptr
      
      ' 压栈数量
      Declare Function Count() As UInteger
      
      Private:
         Dim pMaxCount As UInteger
         Dim pUnitSize As UInteger
         Dim pStackMem As UByte Ptr
         Dim pStackTop As UInteger
   End Type
   
   
   /' -------------------------- 栈结构类[Int] -------------------------- '/
   Type xStack_Int
      ' 构造/析构
      Declare Constructor(max As UInteger)
      Declare Destructor()
      
      ' 初始化/卸载
      Declare Function Init(max As UInteger) As Integer
      Declare Sub Unit()
      
      ' 压栈
      Declare Function Push(dat As Integer) As Integer
      
      ' 出栈
      Declare Function Pop() As Integer
      Declare Function Pop(c As UInteger) As Integer Ptr
      
      ' 栈顶
      Declare Function Top() As Integer
      
      ' 压栈数量
      Declare Function Count() As UInteger
      
      Private:
         Dim pMaxCount As UInteger
         Dim pStackMem As Integer Ptr
         Dim pStackTop As UInteger
   End Type
   
   
   /' -------------------------- 结构化内存管理器 -------------------------- '/
   Type xBsmm
      ' 管理器内存指针
      StructMemory As Any Ptr
      
      ' 成员占用内存长度
      StructLenght As UInteger
      
      ' 管理器中存在多少成员
      StructCount As UInteger
      
      ' 已经申请的结构数量
      AllocCount As UInteger
      
      ' 预分配内存步长
      AllocStep As UInteger
      
      ' 构造函数
      Declare Constructor()
      Declare Constructor(iItemLenght As UInteger, PreassignStep As UInteger = 32, PreassignLenght As UInteger = 0)
      
      ' 析构函数
      Declare Destructor()
      
      ' 添加成员
      Declare Function InsertStruct(iPos As UInteger, iCount As UInteger = 1) As UInteger
      Declare Function AppendStruct(iCount As UInteger = 1) As UInteger
      
      ' 删除成员
      Declare Function DeleteStruct(iPos As UInteger, iCount As UInteger = 1) As Integer
      
      ' 移动成员
      Declare Function SwapStruct(iPosA As UInteger, iPosB As UInteger) As Integer
      
      ' 获取成员指针
      Declare Function GetPtrStruct(iPos As UInteger) As Any Ptr
      
      ' 分配内存
      Declare Function CallocMemory(iCount As UInteger) As Integer
      
      ' 重置(释放资源)
      Declare Sub ReInitManage()
   End Type
End Extern



Extern XGE_EXTERNMODULE
   Namespace xge
   /' -------------------------- 核心库 -------------------------- '/
      Declare Function Init(w As UInteger, h As UInteger, init_gfx As Integer = XGE_INIT_WINDOW, init_mod As Integer = XGE_INIT_ALL, title As ZString Ptr = NULL) As Integer
      Declare Sub Unit()
      Declare Function SetScreen(w As UInteger, h As UInteger, init_gfx As Integer = XGE_INIT_WINDOW) As Integer
      Declare Function hWnd() As HANDLE
      Declare Sub Clear()
      Declare Sub Lock()
      Declare Sub UnLock()
      Declare Sub Sync()
      Declare Function Width() As UInteger
      Declare Function Height() As UInteger
      Declare Function PixAddr() As Any Ptr
      Declare Function PixSize() As UInteger
      Declare Function Pitch() As UInteger
      Declare Function Driver() As ZString Ptr
      Declare Sub SetSoundVol(tpe As Integer, vol As Integer)
      Declare Function GetSoundVol(tpe As Integer) As Integer
      Declare Function Ver(tpe As Integer = 0) As Integer
      
      
      /' -------------------------- 场景库 -------------------------- '/
      Namespace Scene
         Declare Function Start(proc As XGE_SCENE_PROC, lfps As UInteger = 0, sync As Integer = FALSE, param As Integer = 0) As Integer
         Declare Function Cut(proc As XGE_SCENE_PROC, lfps As UInteger = 0, sync As Integer = FALSE, param As Integer = 0) As Integer
         Declare Sub Stop(sc As Integer = 0)
         Declare Sub StopAll(sc As Integer = 0)
         Declare Sub Pause(flag As Integer = XGE_PAUSE_DRAW Or XGE_PAUSE_FRAME)
         Declare Function State() As Integer
         Declare Sub Resume()
         Declare Function FPS() As UInteger
         Declare Function Stack() As xStack Ptr
      End Namespace
      
      
      /' -------------------------- 挂钩库 -------------------------- '/
      Namespace Hook
         Declare Sub SetDelayProc(proc As XGE_DELAY_PROC)
         Declare Sub SetEventProc(proc As XGE_EVENT_PROC)
         Declare Sub SetSceneProc(proc As XGE_SCENE_PROC)
         Declare Sub SetImageLoadProc(proc As XGE_BLOAD_PROC)
         Declare Sub SetFontLoadProc(proc As XGE_FLOAD_PROC)
      End Namespace
      
      
      /' -------------------------- 输入库 -------------------------- '/
      Namespace xInput
         Declare Function KeyStatus(k As Integer) As Integer
         Declare Sub MouseStatus(x As Integer Ptr, y As Integer Ptr, w As Integer Ptr, b As Integer Ptr)
         Declare Function JoyStatus(id As Integer, btn As Integer Ptr, a1 As Single Ptr, a2 As Single Ptr, a3 As Single Ptr, a4 As Single Ptr, a5 As Single Ptr, a6 As Single Ptr, a7 As Single Ptr, a8 As Single Ptr) As Integer
         Declare Function GetMousePos() As Integer
         Declare Function SetMousePos(x As Integer, y As Integer) As Integer
         Declare Function GetMouseX() As Integer
         Declare Function GetMouseY() As Integer
         Declare Function GetMouseBtn() As Integer
         Declare Function GetMouseBtnL() As Integer
         Declare Function GetMouseBtnR() As Integer
         Declare Function GetMouseBtnM() As Integer
         Declare Function GetMouseWhell() As Integer
      End Namespace
   End Namespace
   
   
   /' -------------------------- 文件操作库 -------------------------- '/
   Namespace xFile
      Declare Function Create(FilePath As ZString Ptr) As Integer
      Declare Function Open(FilePath As ZString Ptr, OnlyRead As Integer = 0) As HANDLE
      Declare Function Close(FileHdr As HANDLE) As Integer
      Declare Function Exists(FilePath As ZString Ptr) As Integer
      Declare Function hWrite(FileHdr As HANDLE, Buffer As Any Ptr, Addr As UInteger, Length As UInteger) As UInteger
      Declare Function Write(FilePath As ZString Ptr, Buffer As Any Ptr, Addr As UInteger, Length As UInteger) As UInteger
      Declare Function hRead(FileHdr As HANDLE, Buffer As Any Ptr, Addr As UInteger, Length As UInteger) As UInteger
      Declare Function Read(FilePath As ZString Ptr, Buffer As Any Ptr, Addr As UInteger, Length As UInteger) As UInteger
      Declare Function eRead(FilePath As ZString Ptr, Buffer As Any Ptr Ptr) As UInteger
      Declare Function hSize(FileHdr As HANDLE) As UInteger
      Declare Function Size(FilePath As ZString Ptr) As UInteger
      Declare Function hCut(FileHdr As HANDLE, FileSize As UInteger) As Integer
      Declare Function Cut(FilePath As ZString Ptr, FileSize As UInteger) As Integer
      Declare Function Scan(RootDir As ZString Ptr, Filter As ZString Ptr, Attrib As Integer, AttribEx As Integer, Recursive As Integer, CallBack As Function(Path As ZString Ptr, FindData As WIN32_FIND_DATA Ptr, param As Integer) As Integer, param As Integer = 0) As Integer
   End Namespace
   
   Namespace xIni
      Declare Function GetStr(IniFile As ZString Ptr, IniSec As ZString Ptr, IniKey As ZString Ptr) As ZString Ptr
      Declare Function GetInt(IniFile As ZString Ptr, IniSec As ZString Ptr, IniKey As ZString Ptr) As Integer
      Declare Function SetStr(IniFile As ZString Ptr, IniSec As ZString Ptr, IniKey As ZString Ptr, kValue As ZString Ptr) As Integer
      Declare Function EnumSec(IniFile As ZString Ptr, OutArr As ZString Ptr Ptr Ptr) As Integer
      Declare Function EnumKey(IniFile As ZString Ptr, IniSec As ZString Ptr, OutArr As ZString Ptr Ptr Ptr) As Integer
   End Namespace
End Extern



Extern XGE_EXTERNCLASS
   Namespace xge
      /' -------------------------- 图像类 -------------------------- '/
      Type Surface
         img As IMAGE Ptr
         
         ' 构造 [空]
         Declare Constructor()
         
         ' 构造 [创建]
         Declare Constructor(w As UInteger, h As UInteger)
         
         ' 构造 [加载]
         Declare Constructor(addr As ZString Ptr, size As UInteger = 0)
         
         ' 析构
         Declare Destructor()
         
         ' 创建图像
         Declare Function Create(w As UInteger, h As UInteger) As Integer
         
         ' 载入图像
         Declare Function Load(addr As ZString Ptr, size As UInteger = 0) As Integer
         
         ' 保存图像
         Declare Function Save(addr As ZString Ptr, tpe As UInteger = 0, flag As Integer = 0) As Integer
         
         ' 释放图像
         Declare Sub Free()
         
         ' 清除图像
         Declare Sub Clear()
         
         ' 获取图像属性
         Declare Function Width() As UInteger
         Declare Function Height() As UInteger
         Declare Function PixAddr() As Any Ptr
         Declare Function PixSize() As UInteger
         Declare Function Pitch() As UInteger
         
         ' 创建图像副本
         Declare Function Copy(x As Integer, y As Integer, w As Integer, h As Integer) As xge.Surface Ptr
         
         ' 绘制
         Declare Sub Draw(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Add(x As Integer, y As Integer, mul As Integer = 255, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Add(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, mul As Integer = 255, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Alpha(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Alpha(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Alpha2(x As Integer, y As Integer, a As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Alpha2(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, a As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Trans(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Trans(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_And(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_And(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Or(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Or(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_PSet(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_PSet(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Xor(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Xor(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Gray(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Gray(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Mirr(x As Integer, y As Integer, flag As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Mirr(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, flag As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Shade(x As Integer, y As Integer, mask As UByte, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Shade(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, mask As UByte, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Custom(x As Integer, y As Integer, bk As XGE_DRAW_CUSTOM, param As Any Ptr = NULL, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Custom(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, bk As XGE_DRAW_CUSTOM, param As Any Ptr = NULL, sf As xge.Surface Ptr = NULL)
         Declare Sub Draw_Blend(x As Integer, y As Integer, bk As Any Ptr, param As Integer = 0, sf As xge.Surface Ptr = NULL)
         Declare Sub DrawEx_Blend(x As Integer, y As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, bk As Any Ptr, param As Integer = 0, sf As xge.Surface Ptr = NULL)
      End Type
      
      
      /' -------------------------- Gdi图像类 -------------------------- '/
      Type GdiSurface Extends Surface
         hDC As HANDLE
         hBitmap As HANDLE
         BitmapAddr As Any Ptr
         gfx As GdiPlus.GpGraphics Ptr
         
         ' 构造 [空]
         Declare Constructor()
         
         ' 构造 [创建]
         Declare Constructor(w As UInteger, h As UInteger)
         
         ' 构造 [加载]
         Declare Constructor(addr As ZString Ptr, size As UInteger = 0)
         
         ' 析构
         Declare Destructor()
         
         ' 创建图像
         Declare Function Create(w As UInteger, h As UInteger) As Integer
         
         ' 载入图像
         Declare Function Load(addr As ZString Ptr, size As UInteger = 0) As Integer
         
         ' 释放图像
         Declare Sub Free()
         
         ' GDI 绘图
         Declare Sub PrintLine(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As UInteger)
         Declare Sub PrintRect(x As Integer, y As Integer, w As Integer, h As Integer, c As UInteger)
         Declare Sub PrintRectFull(x As Integer, y As Integer, w As Integer, h As Integer, c As UInteger)
         Declare Sub PrintCirc(x As Integer, y As Integer, w As Integer, h As Integer, c As UInteger)
         Declare Sub PrintCircFull(x As Integer, y As Integer, w As Integer, h As Integer, c As UInteger)
         Declare Sub PrintText(x As Integer, y As Integer, w As Integer, h As Integer, f As ZString Ptr, px As Integer, flag As Integer, c As UInteger, txt As ZString Ptr)
         Declare Sub PrintText(x As Integer, y As Integer, w As Integer, h As Integer, f As ZString Ptr, px As Integer, flag As Integer, c As UInteger, weight As Integer, txt As ZString Ptr)
         Declare Sub PrintText(x As Integer, y As Integer, w As Integer, h As Integer, f As ZString Ptr, px As Integer, flag As Integer, c1 As UInteger, c2 As UInteger, weight As Integer, txt As ZString Ptr)
         Declare Sub PrintText(x As Integer, y As Integer, w As Integer, h As Integer, f As ZString Ptr, px As Integer, flag As Integer, addr As ZString Ptr, size As Integer, txt As ZString Ptr)
         Declare Sub PrintImage(x As Integer, y As Integer, addr As ZString Ptr, size As Integer = 0)
         Declare Sub PrintImageDpi(x As Integer, y As Integer, addr As ZString Ptr, size As Integer = 0)
         Declare Sub PrintImageZoom(x As Integer, y As Integer, w As Integer, h As Integer, addr As ZString Ptr, size As Integer = 0)
         Declare Sub PrintImageEx(x As Integer, y As Integer, w As Integer, h As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer, addr As ZString Ptr, size As Integer = 0)
         Declare Sub PrintImageFull(x As Integer, y As Integer, w As Integer, h As Integer, addr As ZString Ptr, size As Integer = 0)
      End Type
      
      
      /' -------------------------- 声音类 -------------------------- '/
      Type Sound
         SoundObj As UInteger
         
         ' 构造 [空]
         Declare Constructor()
         
         ' 构造 [加载]
         Declare Constructor(tpe As Integer, flag As Integer, addr As ZString Ptr, size As UInteger = 0, max As Integer = 65535)
         
         ' 析构
         Declare Destructor()
         
         ' 载入声音
         Declare Function Load(tpe As Integer, flag As Integer, addr As ZString Ptr, size As UInteger = 0, max As Integer = 65535) As Integer
         
         ' 释放声音
         Declare Sub Free()
         
         ' 声音类型
         Declare Function GetType() As Integer
         
         ' 声音控制
         Declare Sub Play()
         Declare Sub Stop()
         Declare Sub Pause()
         Declare Sub Resume()
         
         Protected:
            pTpe As Integer
      End Type
   End Namespace
   
   
   /' -------------------------- 界面库 -------------------------- '/
   Namespace xui
      
      ' 点数据结构
      Type Coord
         x As Integer
         y As Integer
      End Type
      
      ' 矩形数据结构
      Type Rect
         Union
            x As Integer
            LeftOffset As Integer
         End Union
         Union
            y As Integer
            TopOffset As Integer
         End Union
         Union
            w As Integer
            RightOffset As Integer
         End Union
         Union
            h As Integer
            BottomOffset As Integer
         End Union
      End Type
      
      
      ' 布局数据结构
      Type Layout
         Ruler As Integer         ' 布局尺度 [ 参考定义前缀 : XUI_LAYOUT_RULER ]
         RectBox As xui.Rect         ' 外框大小 [ 单位是像素,浮动布局时这个数据无效 ]
         Rect As xui.Rect         ' 最终坐标 [ 这个数据会在运行时产生 ]
         ScreenCoord As xui.Coord   ' 在屏幕上的最终坐标 [ 以游戏左上角为起点,这个数据会在运行时产生 ]
         w As Integer            ' 布局宽度
         h As Integer            ' 布局高度
      End Type
      
      
      ' 背景结构
      Type BackImage
         Image As xge.Surface Ptr = NULL
         BorderColor As Integer
         FillColor As Integer
         TextColor As Integer
      End Type
      
      
      ' 元素事件 [部分事件处理过程占用时间,因此仅在注册后才会处理这些事件]
      ' 元素事件返回 -1 代表中断事件链处理,其他符合条件的控件将无法再收到事件
      Type ElementEvent
         ' 鼠标移动 [被激活的控件可以优先处理这个事件,如果他放弃处理的话,则这个事件进入正常的消息链]
         OnMouseMove As Function(ele As Any Ptr, x As Integer, y As Integer) As Integer = NULL
         ' 鼠标按下
         OnMouseDown As Function(ele As Any Ptr, x As Integer, y As Integer, btn As Integer) As Integer = NULL
         ' 鼠标弹起 [被激活的控件可以优先处理这个事件,如果他放弃处理的话,则这个事件进入正常的消息链]
         OnMouseUp As Function(ele As Any Ptr, x As Integer, y As Integer, btn As Integer) As Integer = NULL
         ' 鼠标单击
         OnMouseClick As Function(ele As Any Ptr, x As Integer, y As Integer, btn As Integer) As Integer = NULL
         ' 鼠标双击
         OnMouseDoubleClick As Function(ele As Any Ptr, x As Integer, y As Integer, btn As Integer) As Integer = NULL
         ' 鼠标进入元素范围
         OnMouseEnter As Sub(ele As Any Ptr) = NULL
         ' 鼠标离开元素
         OnMouseLeave As Sub(ele As Any Ptr) = NULL
         ' 鼠标滚轮拨动 [鼠标指针所在位置最顶层的元素能够收到这个事件,如果他不处理的话,则事件会被转发给被激活的元素]
         OnMouseWhell As Function(ele As Any Ptr, x As Integer, y As Integer, z As Integer, nz As Integer) As Integer = NULL
         ' 键盘按键按下 [只有被激活的元素能收到这个事件]
         OnKeyDown As Function(ele As Any Ptr, k As Integer, c As Integer) As Integer = NULL
         ' 键盘按键弹起 [只有被激活的元素能收到这个事件]
         OnKeyUp As Function(ele As Any Ptr, k As Integer, c As Integer) As Integer = NULL
         ' 键盘按键点击 [只有被激活的元素能收到这个事件]
         OnKeyRepeat As Function(ele As Any Ptr, k As Integer, c As Integer) As Integer = NULL
         ' 元素被激活
         OnGotfocus As Sub(ele As Any Ptr) = NULL
         ' 元素丢失激活状态
         OnLostFocus As Sub(ele As Any Ptr) = NULL
         ' 绘制事件,在元素需要画出的时候调用
         OnDraw As Sub(ele As Any Ptr) = NULL
         ' 自绘事件,在 OnDraw 之后调用,可以进行补充绘制 [这个事件系统一般不会占用]
         OnUserDraw As Sub(ele As Any Ptr) = NULL
      End Type
      
      
      ' 按钮的事件结构
      Type ButtonEvent
         OnClick As Sub(ele As Any Ptr, btn As Integer)
         OnCheck As Sub(ele As Any Ptr)
      End Type
      
      
      ' 子元素列表类
      Type ElementList Extends xBsmm
         Parent As Any Ptr      ' 父元素指针 [添加子元素的时候需要]
         Declare Function AddElement(elePtr As Any Ptr) As Integer
         Declare Function InsElement(elePtr As Any Ptr, iPos As Integer) As Integer
         Declare Function GetElement(iPos As Integer) As Any Ptr
         Declare Function DelElement(iPos As Integer) As Integer
         Declare Function Count() As UInteger
      End Type
      
      
      ' 元素基类
      Type Element
         ClassID As Integer               ' 类识别编号,仅用于识别,没有其他意义 0x10000 以内的编号为引擎预留 [0=Element]
         LayoutMode As Integer            ' 布局模式 [ 参考定义前缀 : XUI_LAYOUT ]
         Layout As xui.Layout            ' 布局数据
         ClassEvent As ElementEvent         ' 事件
         Childs As ElementList            ' 子元素数据
         Parent As Element Ptr = NULL      ' 父元素指针
         Visible As Integer = -1            ' 是否显示 [参与布局和绘制的开关] [使用布局的话修改后必须重新应用布局]
         Image As xge.Surface Ptr         ' 元素画板
         NeedRedraw As Integer = -1         ' 需要重绘标记
         Identifier As ZString * 32         ' 元素ID [相当于引擎附加数据,用户可以将ID映射到脚本语言中处理事件]
         DrawRange As Integer = 0         ' 绘制元素范围
         Tag As Any Ptr                  ' 附加数据
         
         ' 构造函数
         Declare Constructor()
         Declare Constructor(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, iLayoutMode As Integer = XUI_LAYOUT_COORD, sIdentifier As ZString Ptr = NULL)
         
         ' 析构函数
         Declare Destructor()
         
         Declare Sub LayoutApply()
         Declare Sub Draw(sf As xge.Surface Ptr, px As Integer = 0, py As Integer = 0)
         Declare Function EventLink(msg As Integer,param As Integer,eve As xge_event Ptr) As Integer
         
         ' 画参考线
         Declare Sub DrawDebug()
      End Type
      
      
      ' 按钮类
      Type Button Extends Element
         Caption As ZString Ptr                     ' 按钮的标题
         CaptionOffset As xui.Coord                  ' 按钮标题坐标偏移
         CaptionFont As UInteger                     ' 按钮标题的字体
         
         Mode As Integer                           ' 工作模式 [1=复选框、2=单选框、其他=无状态按钮]
         Checked As Integer                        ' 按钮是否被选中
         
         ' 背景图
         NormalBack As BackImage                     ' 正常状态的背景
         HotBack As BackImage                     ' 按钮被激活 (鼠标进入)
         PressBack As BackImage                     ' 按钮被按下
         CheckBack As BackImage                     ' 选中时的背景
         
         ' 声音
         EnterSound As xge.Sound Ptr                  ' 鼠标进入的声音
         LeaveSound As xge.Sound Ptr                  ' 鼠标离开的声音
         DownSound As xge.Sound Ptr                  ' 鼠标按下的声音
         ClickSound As xge.Sound Ptr                  ' 按钮被点击的声音 [鼠标按下并松开时播放]
         
         'Declare Sub ApplyStyle(StyleID As Integer = 0)   ' 应用样式
         
         Event As ButtonEvent                     ' 按钮的事件
         
         ' 不公开的属性 [但我没有隐藏这些细节,方便你二次开发]
         private_Status As Integer                  ' 按钮的状态 [0=常规、1=热点、2=按下]
         private_AllowClick As Integer               ' 允许触发点击事件 [当鼠标是在按钮上按下的时候设置为TRUE]
      End Type
      
      
      ' 获取根元素 (Desktop元素)
      Declare Function GetRootElement() As xui.Element Ptr
      
      ' 获取被激活的元素
      Declare Function GetActiveElement() As xui.Element Ptr
      
      ' 激活元素 [传递NULL则取消当前激活的元素]
      Declare Sub ActiveElement(ele As xui.Element Ptr)
      
      ' 获取鼠标指针下的热点元素
      Declare Function GetHotElement() As xui.Element Ptr
      
      ' 应用布局
      Declare Sub LayoutApply()
      
      ' 创建一个空白的元素
      Declare Function CreateElement(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, iLayoutMode As Integer = XUI_LAYOUT_COORD, sIdentifier As ZString Ptr = NULL) As xui.Element Ptr
      
      ' 创建按钮
      Declare Function CreateButton(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, sCaption As ZString Ptr, sIdentifier As ZString Ptr = NULL) As xui.Button Ptr
      
      ' 创建选择按钮
      Declare Function CreateCheckButton(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, sCaption As ZString Ptr, sIdentifier As ZString Ptr = NULL) As xui.Button Ptr
      Declare Function CreateRadioButton(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, sCaption As ZString Ptr, sIdentifier As ZString Ptr = NULL) As xui.Button Ptr
      
      ' 创建复选框
      Declare Function CreateCheckBox(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, sCaption As ZString Ptr, sIdentifier As ZString Ptr = NULL) As xui.Button Ptr
      
      ' 创建单选框
      Declare Function CreateRadioBox(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, sCaption As ZString Ptr, sIdentifier As ZString Ptr = NULL) As xui.Button Ptr
      
      ' 创建超链接
      Declare Function CreateHyperLink(iLayoutRuler As Integer = XUI_LAYOUT_RULER_PIXEL, x As Integer = 0, y As Integer = 0, w As Integer = 80, h As Integer = 24, sCaption As ZString Ptr, sIdentifier As ZString Ptr = NULL) As xui.Button Ptr
      
   End Namespace
   
   
   
   /' -------------------------- 网络库 -------------------------- '/
   Namespace xSock
      
      Type ServerEvent
         recv As Sub(client As HANDLE, pack As Any Ptr, size As UInteger)
         send As Sub(client As HANDLE, code As Integer)
         Accept As Sub(client As HANDLE)
         Disconn As Sub(client As HANDLE)
      End Type
      
      Type ClientEvent
         recv As Sub(pack As Any Ptr, size As UInteger)
         send As Sub(code As Integer)
         Disconn As Sub()
      End Type
      
      Type xServer
         Section As CRITICAL_SECTION
         
         ' 事件
         Event As ServerEvent
         
         ' 析构
         Declare Destructor()
         
         ' 创建
         Declare Function Create(ip As ZString Ptr, port As UShort, max As UInteger = 1000, ThreadCountt As UInteger = 1) As Integer
         
         ' 销毁
         Declare Sub Destroy()
         
         ' 状态
         Declare Function Status() As Integer
         
         ' 发送
         Declare Function Send(Client As HANDLE, pack As Any Ptr, size As UInteger, sync As Integer = TRUE) As Integer
         
         ' 遍历客户端
         Declare Function EnumClient(first As HANDLE) As HANDLE
         
         ' 获取客户端信息
         Declare Function GetClientInfo(client As HANDLE, ip As ZString Ptr Ptr, port As UInteger Ptr) As Integer
         
         ' 内部事件函数
         #Ifdef XGE_SOURCE_BUILD
            Declare Sub AcceptProc(client As HANDLE)
            Declare Sub DisconnProc(client As HANDLE)
         #EndIf
         
         Private:
            h_Socket As HANDLE
            c_Max As UInteger
            c_Conn As UInteger
            c_Enter As UInteger
            c_Leave As UInteger
            c_List As HANDLE Ptr
            c_FindCursor As UInteger
            c_AddIndex As UInteger
            
            ' 添加到客户端列表
            Declare Function AddClientList(client As HANDLE) As Integer
            
            ' 从客户端列表删除
            Declare Function DelClientList(client As HANDLE) As Integer
      End Type

      Type xClient
         Section As CRITICAL_SECTION
         
         ' 事件
         Event As ClientEvent
         
         ' 析构
         Declare Destructor()
         
         ' 连接
         Declare Function Connect(ip As ZString Ptr, port As UShort) As Integer
         
         ' 断开
         Declare Sub Close()
         
         ' 状态
         Declare Function Status() As Integer
         
         ' 发送
         Declare Function Send(pack As Any Ptr, size As UInteger, sync As Integer = TRUE) As Integer
         
         Private:
            h_Client As HANDLE
      End Type
      
      Type xUDP
         ' 事件函数
         RecvEvent As Sub(pack As Any Ptr, size As UInteger, ip As ZString Ptr, port As Integer)
         SendEvent As Sub(code As Integer)
         
         ' 析构
         Declare Destructor()
         
         ' 创建
         Declare Function Create(ip As ZString Ptr, port As UShort, ThreadCountt As UInteger = 1) As Integer
         
         ' 销毁
         Declare Sub Destroy()
         
         ' 状态 [已创建=TRUE]
         Declare Function Status() As Integer
         
         ' 发送
         Declare Function Send(pack As Any Ptr, size As UInteger, ip As ZString Ptr, port As UShort, sync As Integer = TRUE) As Integer
         
         Private:
            h_Socket As HANDLE
      End Type
      
   End Namespace
   
End Extern



Namespace xge
   
   Namespace Text
      
      /' -------------------------- 字体驱动结构体 -------------------------- '/
      Type FontDriver
         
         Font As Any Ptr
         
         FontSizeInt As Integer
         WidthInt As Integer
         HeightInt As Integer
         
         FontSizeFloat As Single
         WidthFloat As Single
         HeightFloat As Single
         
         Tag As Integer
         TagFloat As Single
         
         ' 必要的接口
         DrawWord As Sub(fd As FontDriver Ptr, sf As xge.Surface Ptr, px As Integer, py As Integer, w As Integer, h As Integer, iCode As UInteger, iColor As Integer, Style As Integer)
         DrawWordA As Sub(fd As FontDriver Ptr, sf As xge.Surface Ptr, px As Integer, py As Integer, w As Integer, h As Integer, iCode As UInteger, iColor As Integer, Style As Integer)
         WordInfo As Sub(fd As FontDriver Ptr, iCode As Integer, Style As Integer, w As Integer Ptr, h As Integer Ptr)
         WordInfoA As Sub(fd As FontDriver Ptr, iCode As Integer, Style As Integer, w As Integer Ptr, h As Integer Ptr)
         
         ' 清理字库(删除字库的时候用,比如释放内存之类的)
         FreeFont As Sub(fd As FontDriver Ptr)
         
         ' 输出一行文字
         DrawLine_Fast As Sub(fd As FontDriver Ptr, sf As xge.Surface Ptr, x As Integer, y As Integer, txt As WString Ptr, iColor As Integer, Style As Integer, wd As Integer)
         DrawLineA_Fast As Sub(fd As FontDriver Ptr, sf As xge.Surface Ptr, x As Integer, y As Integer, txt As ZString Ptr, iColor As Integer, Style As Integer, wd As Integer)
         
         ' 输出一些文字到一个矩形范围内 [ align:对其方式、wd:字间距、ld:行间距 ] [暂未实现自动换行功能]
         DrawRect_Fast As Sub(fd As FontDriver Ptr, sf As xge.Surface Ptr, x As Integer, y As Integer, w As Integer, h As Integer, txt As WString Ptr, iColor As Integer, Style As Integer, align As Integer, wd As Integer, ld As Integer)
         DrawRectA_Fast As Sub(fd As FontDriver Ptr, sf As xge.Surface Ptr, x As Integer, y As Integer, w As Integer, h As Integer, txt As ZString Ptr, iColor As Integer, Style As Integer, align As Integer, wd As Integer, ld As Integer)
         
      End Type
      
   End Namespace
   
End Namespace



Extern XGE_EXTERNMODULE
   
   Namespace xge
      
      /' -------------------------- 文字渲染库 -------------------------- '/
      Namespace Text
         
         ' 加载字体 [ 目前支持 xrf字体 和 truetype字体 ] [ ttc字体包加载时通过param参数指定加载的字体ID ]
         Declare Function LoadFont(Addr As ZString Ptr, iSize As UInteger, param As Any Ptr = NULL) As UInteger
         
         ' 移除字体 [移除字体后字体编号会变动,慎用]
         Declare Function RemoveFont(idx As UInteger) As Integer
         
         ' 取得已加载的字体数量
         Declare Function FontCount() As Integer
         
         ' 设置字体大小 [针对ttf字体]
         Declare Sub SetFontSize(idx As UInteger, size As UInteger)
         
         ' 写字
         Declare Sub Draw(sf As xge.Surface Ptr, px As Integer, py As Integer, txt As WString Ptr, iColor As UInteger, fontid As Integer = 1, Style As Integer = 0, wd As Integer = 0)
         Declare Sub DrawA(sf As xge.Surface Ptr, px As Integer, py As Integer, txt As ZString Ptr, iColor As UInteger, fontid As Integer = 1, Style As Integer = 0, wd As Integer = 0)
         
         ' 矩形格式化写字 [ align:对其方式、wd:字间距、ld:行间距 ]
         Declare Sub DrawRect(sf As xge.Surface Ptr, px As Integer, py As Integer, pw As Integer, ph As Integer, txt As WString Ptr, iColor As UInteger, fontid As Integer = 1, Style As Integer = 0, align As Integer = XGE_ALIGN_CENTER Or XGE_ALIGN_MIDDLE, wd As Integer = 0, ld As Integer = 0)
         Declare Sub DrawRectA(sf As xge.Surface Ptr, px As Integer, py As Integer, pw As Integer, ph As Integer, txt As ZString Ptr, iColor As UInteger, fontid As Integer = 1, Style As Integer = 0, align As Integer = XGE_ALIGN_CENTER Or XGE_ALIGN_MIDDLE, wd As Integer = 0, ld As Integer = 0)
         
      End Namespace
      
      
      /' -------------------------- 辅助库 -------------------------- '/
      Namespace Aux
         Declare Function ScreenShot() As xge.Surface Ptr
         Declare Function GetPixel(x As Integer, y As Integer, sf As xge.Surface Ptr = NULL) As UInteger
         Declare Function RGB2BGR(c As UInteger) As UInteger
         Declare Sub SetTitle(title As ZString Ptr)
         Declare Sub SetView(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer, f As Integer)
         Declare Sub ReSetView()
         Declare Sub SetCoodr(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer = 0)
         Declare Sub ReSetCoodr()
         Declare Function MapCoodr(coodr As Integer, tpe As Integer) As Integer
         Declare Function LockMouse() As Integer
         Declare Function UnLockMouse() As Integer
         Declare Function HideCursor() As Integer
         Declare Function ShowCursor() As Integer
      End Namespace
      
      
      /' -------------------------- 图形库 -------------------------- '/
      Namespace Shape
         Declare Sub Pixel(x As Integer, y As Integer, c As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Lines(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub LinesEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer, s As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Rect(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub RectEx(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer, s As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub RectFull(x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, c As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub Circ(x As Integer, y As Integer, r As Integer, c As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub CircFull(x As Integer, y As Integer, r As Integer, c As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub CircEx(x As Integer, y As Integer, r As Integer, c As Integer, a As Single, sf As xge.Surface Ptr = NULL)
         Declare Sub CircFullEx(x As Integer, y As Integer, r As Integer, c As Integer, a As Single, sf As xge.Surface Ptr = NULL)
         Declare Sub CircArc(x As Integer, y As Integer, r As Integer, c As Integer, s As Integer, e As Integer, a As Single, sf As xge.Surface Ptr = NULL)
         Declare Sub Full(x As Integer, y As Integer, c As Integer, f As Integer, sf As xge.Surface Ptr = NULL)
         Declare Sub FullEx(x As Integer, y As Integer, p As ZString Ptr, f As Integer, sf As xge.Surface Ptr = NULL)
      End Namespace
      
      
   End Namespace
End Extern



Extern XGE_EXTERNSTDEXT
   /' -------------------------- 混合渲染库 -------------------------- '/
   Declare Function Blend_Custom(src As xge.Surface Ptr, px As Integer, py As Integer, cx As Integer, cy As Integer, cw As Integer, ch As Integer,dst As xge.Surface Ptr, bk As XGE_DRAW_BLEND, param As Integer) As Integer
   Declare Sub Blend_Gray(SrcAddr As Any Ptr, SrcPitch As Integer, SrcLineS As Integer, DstAddr As Any Ptr, DstPitch As Integer, DstLineS As Integer, w As Integer, h As Integer, param As Integer)
   Declare Sub Blend_Mirr(SrcAddr As Any Ptr, SrcPitch As Integer, SrcLineS As Integer, DstAddr As Any Ptr, DstPitch As Integer, DstLineS As Integer, w As Integer, h As Integer, param As Integer)
   Declare Sub Blend_Shade(SrcAddr As Any Ptr, SrcPitch As Integer, SrcLineS As Integer, DstAddr As Any Ptr, DstPitch As Integer, DstLineS As Integer, w As Integer, h As Integer, param As Integer)
   Declare Sub SetShadeData(w As Integer, h As Integer, d As Any Ptr)
   Declare Sub MakeShadeData(sf As xge.Surface Ptr, sd As UByte Ptr)
   
   
   /' -------------------------- 字符集转换库 -------------------------- '/
   Declare Function AsciToUnicode(ZStrPtr As ZString Ptr, ZStrLen As UInteger) As Any Ptr
   Declare Function UnicodeToAsci(WStrPtr As WString Ptr, WStrLen As UInteger) As Any Ptr
   Declare Function UnicodeToUTF8(WStrPtr As WString Ptr, WStrLen As UInteger) As Any Ptr
   Declare Function UTF8ToUnicode(UTF8Ptr As ZString Ptr, UTF8Len As UInteger) As Any Ptr
   Declare Function A2W(AStr As ZString Ptr, ALen As UInteger = 0) As WString Ptr
   Declare Function W2A(UStr As WString Ptr, ULen As UInteger = 0) As ZString Ptr
   Declare Function W2U(UStr As WString Ptr, ULen As UInteger = 0) As ZString Ptr
   Declare Function U2W(UStr As ZString Ptr, ULen As UInteger = 0) As ZString Ptr
   Declare Function A2U(ZStr As ZString Ptr, ZLen As UInteger = 0) As ZString Ptr
   Declare Function U2A(UStr As ZString Ptr, ULen As UInteger = 0) As ZString Ptr
   
   
   /' -------------------------- 其他易用性函数库 -------------------------- '/
   Declare Function Split(sText As ZString Ptr, sSep As ZString Ptr) As ZString Ptr Ptr
End Extern
jj2007
Posts: 2144
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby jj2007 » Dec 26, 2020 12:00

xywhsoft wrote:This is a game development framework that I developed before
...
Bin, resources and examples: https://github.com/CN-xLeaves/XGE/tree/ ... E%E5%BD%95
I would like to test it, but this link does not point to binaries.
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 26, 2020 12:20

https://github.com/CN-xLeaves/XGE/archive/master.zip

If you don't use git client, you can download it like this, then go to the 发布目录 directory, and all the binary files have been compiled

If this link can't be downloaded, go to the source code link, find the button that appears as green, click it, and a download zip link will appear, which can be downloaded. They are all provided by github, but it is more convenient to use the client.
jj2007
Posts: 2144
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby jj2007 » Dec 26, 2020 23:24

Thanks, I could download it. Unfortunately, either my batch file or fbc.exe seem not to work with Chinese folder names:
fbc.exe -t 2000 -s console "\FreeBasic\xywhsoft\发布目录\tmp\TmpFb.bas" ------------
\FreeBasic\xywhsoft\????\tmp\TmpFb.bas() error 23: File not found, \FreeBasic\xywhsoft\????\tmp\TmpFb.bas
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 27, 2020 9:55

jj2007 wrote:Thanks, I could download it. Unfortunately, either my batch file or fbc.exe seem not to work with Chinese folder names:
fbc.exe -t 2000 -s console "\FreeBasic\xywhsoft\发布目录\tmp\TmpFb.bas" ------------
\FreeBasic\xywhsoft\????\tmp\TmpFb.bas() error 23: File not found, \FreeBasic\xywhsoft\????\tmp\TmpFb.bas


In today’s updated version, I have changed all Chinese directories to English names, hoping that this will solve your problem.

At the same time, two cases related to scene switching have been added (of course, there are fewer comments than other cases, and I am still testing and improving this part of the function), and the BUG repair of the scene system.
jj2007
Posts: 2144
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby jj2007 » Dec 28, 2020 9:02

xywhsoft wrote:Bin, resources and examples: https://github.com/CN-xLeaves/XGE/tree/ ... E%E5%BD%95
That's a 404, unfortunately.
xywhsoft
Posts: 74
Joined: Aug 28, 2009 6:28
Contact:

Re: xywh Game Engine (Image rendering, Text rendering, Sound, network, GUI)

Postby xywhsoft » Dec 28, 2020 9:24

jj2007 wrote:
xywhsoft wrote:Bin, resources and examples: https://github.com/CN-xLeaves/XGE/tree/ ... E%E5%BD%95
That's a 404, unfortunately.


Because the path has changed to English, the link has also changed. I modified the link and added a complete game code.

You can try the download experience again.

Return to “Game Dev”

Who is online

Users browsing this forum: No registered users and 4 guests