PHP GUI fun implementation of a greedy snake

藏色散人
Release: 2023-04-10 21:30:02
forward
4548 people have browsed it

This article will introduce to you how to make a snake with PHP GUI. I hope it will be helpful to you if you need it!

Graphical User Interface (GUI) extension

Read the PHP manual today At that time, I saw that PHP7 has an extension to the ui graphics library, so we rushed to use it

Install the extension

The installation steps in the official manual are for Linux:

Requirements:
    PHP 7
    libui (use current master)
    Windows/MacOSX/Linux (GTK-3)

Install re2c:
    sudo apt install re2c

Install libui:

    git clone https://github.com/andlabs/libui.git
    cd libui
    sudo cp *.h /usr/local/include/
    cmake .
    cd out
    sudo cp * /usr/lib/

Install ui:

    Method one: use pecl:
        sudo pecl install channel://pecl.php.net/ui-2.0.0

    Method two:build source code:
        git clone https://github.com/krakjoe/ui.git
        cd ui
        phpize
        make
        sudo make install

Enable ui.so:
    sudo echo 'extension=ui.so' > /etc/php/7.0/mods-available/ui.ini
    sudo ln -s /etc/php/7.0/mods-available/ui.ini 20-ui.ini

Test:
    php -m
    git clone https://github.com/krakjoe/ui.git
    cd ui/examples/
    php snake.php
Copy after login

Requirements (documentation says)

  • PHP 7
  • libui (use current master)
  • Windows/MacOSX/Linux (GTK-3)

Download the windows dll from PECL. I am using php7 nts 64-bit, so I used this:

PHP GUI fun implementation of a greedy snake

Downloaded file directory structure:

PHP GUI fun implementation of a greedy snake

Next:

  • php_ui.dll is placed in the ext directory of php, and then php.ini is added to extension =php_ui.dll

  • ##pthreadVC2.dll and libui.dll are placed in the php directory, which is the same level as the php.exe file

  • Run the php -m command in cmd to check whether the module is loaded correctly

PHP GUI fun implementation of a greedy snake

PHP GUI fun implementation of a greedy snake##Test a glutton Snake

There is a snake.php file (Snake game) in the folder where the ui extension is downloaded. Go to this directory and run:

php snake.php
Copy after login

PHP GUI fun implementation of a greedy snakeIn addition There is also a particle effect file (starfield.php):

PHP GUI fun implementation of a greedy snake

Recommended learning: "
PHP Video Tutorial

"

The above is the detailed content of PHP GUI fun implementation of a greedy snake. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!