A rendering method, device, equipment and medium for converting characters into dot matrix patterns
Through the rendering method of character-to-dot pattern, the display screen is divided into dot-matrix screens and the graphics are defined in characters, which solves the problem of complex operation of drawing tools, improves the efficiency of game scenes or character building, and enhances students' programming interest and innovation ability.
Patent Information
- Application Number
- CN202310140040.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-20
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2043-02-20
AI Technical Summary
In existing game programming, drawing tools are used to draw game scenes or characters, and the operation is complicated and inefficient, which is not conducive to improving students' programming interest and thinking innovation ability.
Using the rendering method of character-to-dot matrix pattern, the dot matrix screen is formed by initializing the display screen by dividing the basic pixel units into a dot matrix screen, reading model data and mapping it into cells, and disassemblying the model element values into specific graphics according to the preset shape definition specifications and drawing them on the dot matrix screen.
It reduces the complexity of game scenes or character construction, improves construction efficiency, and improves students' programming interest and thinking innovation ability.
Smart Images

Figure CN116048494B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technologies, and particularly relates to a rendering method, device, equipment, and medium for converting characters into dot matrix patterns. Background Art
[0002] Game programming refers to using computer programming languages, such as C programming language, C++, Java, Python, etc., to write games on computers, mobile phones, or game consoles; among them, the Python language has become one of the most popular programming languages due to its simplicity, readability, and scalability.
[0003] In order to cultivate students' (such as junior high school students, senior high school students, etc.) computational thinking and innovation problem-solving abilities, many schools or training institutions use Python to teach programming courses. Currently, when students learn game programming using the Python language, the game scenes or characters used in the game need to be designed and drawn using drawing tools, and then the drawn game scenes or characters are imported. For students learning game programming, this way of using drawing tools to draw game scenes or characters is not only complex and cumbersome to operate, time-consuming, and inefficient, but also not conducive to enhancing students' programming interest and thinking innovation ability. In view of the above problems, the inventor of this case conducted in-depth research on this problem, and thus this case was born. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to provide a rendering method, device, equipment, and medium for converting characters into dot matrix patterns, so as to solve the problems that existing game programming is inefficient and not conducive to enhancing students' programming interest and thinking innovation ability due to using drawing tools to draw game scenes or characters.
[0005] In a first aspect, the present invention provides a rendering method for converting characters into dot matrix patterns. The rendering method is used for a game logic server, and the rendering method includes the following steps:
[0006] Initialize the display screen, and divide the display screen with basic pixel units to form a dot matrix screen;
[0007] Read the input model data, where the model data includes shape data and starting position data of the starting cell that needs to be displayed in the dot matrix screen;
[0008] According to the starting position data of the starting cell, parse the shape data into a model two-dimensional array and map it to the cells of the dot matrix screen;
[0009] According to the preset shape definition specification, extract the model element values in the two-dimensional model array, disassemble the model element values into at least one decomposition value, convert each decomposition value into a specific graphic and draw it into the corresponding cell of the dot matrix screen. After drawing all the model element values in the two-dimensional model array, the final dot matrix pattern is obtained.
[0010] Further, the preset shape definition specification includes: defining a graphic using characters, combining the defined characters into a string, and each string is used as a model element value in the two-dimensional model array;
[0011] Among them, the defining a graphic using characters at least includes defining a basic graphic shape using a first character; the basic graphic shape includes one or more of, but is not limited to, a circle, a line segment, a triangle, a quadrilateral, a semi-circle.
[0012] Further, the defining a graphic using characters also includes, but is not limited to, at least one of the following:
[0013] Defining the color of the graphic using a second character;
[0014] Defining the scaling factor of the graphic using a third character;
[0015] Defining whether the graphic has filling using a fourth character;
[0016] Defining the rotation angle of the graphic using a fifth character;
[0017] Defining the proportion of the graphic in the cell using a sixth character;
[0018] Defining the position of the graphic in the cell using a seventh character.
[0019] Further, the string is a number including an integer part and a decimal part; where:
[0020] Define the positive or negative of the number as whether the graphic has filling;
[0021] Define the units digit of the integer part as the basic graphic shape, the tens digit of the integer part as the scaling factor of the graphic, and the hundreds digit of the integer part as the color of the graphic;
[0022] Define the decimal part as the rotation angle of the graphic, the proportion of the graphic in the cell, or the position of the graphic in the cell.
[0023] Further, the initializing the display screen and dividing the display screen into a dot matrix screen with basic pixel units specifically includes:
[0024] Taking a square cell with a side length of Z pixels as the basic pixel unit, the display screen is divided into a cell array of X columns and Y rows, and this cell array is defined as a dot matrix screen;
[0025] Define the initial two-dimensional array corresponding to the dot matrix screen with the cell data type of DOT. The initial two-dimensional array corresponds one-to-one with the cells on the dot matrix screen, and the initial element values in the initial two-dimensional array correspond to the graphics presented by the cells on the dot matrix screen;
[0026] Define the cell data type DOT. The attributes of DOT include: position in the dot matrix screen, cell side length, instruction array to be updated, current valid instruction set, flag bit indicating whether the cell has changed, and flag bit indicating whether the cell is cleared; The flag bit indicating whether the cell has changed and the flag bit indicating whether the cell is cleared are both set to false in the initial state;
[0027] Define a cell drawing function for receiving drawing commands. The parameters received by the cell drawing function include the starting position data of the starting cell to be displayed on the dot matrix screen and the model two-dimensional array. The starting cell corresponds to the first model element value in the model two-dimensional array;
[0028] Create a pattern update rendering thread and define a dot matrix screen refresh function. Start the pattern update rendering thread, and through the pattern update rendering thread, regularly run the dot matrix screen refresh function at a time interval of 1 second divided by the set frame rate;
[0029] Define a cell clearing function for clearing cells.
[0030] Further, the initialization of the display screen further includes:
[0031] Define a one-dimensional array for area refresh, which is used to record the cells that need to update the graphics when the dot matrix screen is refreshed next time;
[0032] Detect whether the model element value in the model two-dimensional array is consistent with the corresponding initial element value in the initial two-dimensional array through the cell drawing function. If they are consistent, no processing is performed; if they are inconsistent, mark the cells with inconsistent element values as needing to be updated, and add the cells that need to be updated to the one-dimensional array for area refresh.
[0033] Further, the extraction of the model element value in the model two-dimensional array, decomposing the model element value into at least one decomposed value, and converting each decomposed value into a specific graphic and drawing it into the corresponding cell on the dot matrix screen specifically means:
[0034] Set the flag bit indicating whether the cell is cleared to true through the cell clearing function, and clear the instruction array to be updated;
[0035] The cell drawing function extracts the values of the model elements to be updated from the two-dimensional array or area of the model in the refreshed one-dimensional array, stores the extracted values of the model elements into the instruction array to be updated, and sets the flag indicating whether the cell has changed to true;
[0036] The dot matrix screen refreshing function checks whether the flag indicating whether the cell is cleared is true. If it is true, it clears the current valid instruction set and at the same time resets the flag indicating whether the cell is cleared to false; if it is false, it adds the values of the model elements stored in the instruction array to be updated to the current valid instruction set and clears the instruction array to be updated; the cell drawing function takes out the values of the model elements stored in the current valid instruction set and disassembles them into at least one decomposed value, converts each decomposed value into a specific graphic and draws it into the corresponding cell of the dot matrix screen, and resets the flag indicating whether the cell has changed to false.
[0037] In a second aspect, the present invention provides a rendering device for converting characters into dot matrix patterns. The rendering device is used for a game logic server. The rendering device includes a dot matrix management module, a model reading module, a data mapping module, and a cell drawing module;
[0038] The dot matrix management module is used to initialize the display screen and divide the display screen into a dot matrix screen with basic pixel units;
[0039] The model reading module is used to read the input model data. The model data includes shape data and the starting position data of the starting cell to be displayed on the dot matrix screen;
[0040] The data mapping module is used to parse the shape data into a two-dimensional model array and map it to the cells of the dot matrix screen according to the starting position data of the starting cell;
[0041] The cell drawing module is used to extract the values of the model elements in the two-dimensional model array according to the preset shape definition specification, disassemble the values of the model elements into at least one decomposed value, convert each decomposed value into a specific graphic and draw it into the corresponding cell of the dot matrix screen. After drawing all the values of the model elements in the two-dimensional model array, the final dot matrix pattern is obtained.
[0042] In a third aspect, the present invention provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the method described in the first aspect is implemented.
[0043] In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.
[0044] One or more technical solutions provided in the embodiments of the present invention have at least the following technical effects or advantages:
[0045] By dividing the display screen into a dot matrix screen with basic pixel units and defining simple graphics in the form of characters, students can input model data in the form of characters or strings in the client. After receiving the model data, the game logic server can parse the model data into a model two-dimensional array and map it to the cells of the dot matrix screen, and disassemble and convert the model element values in the model two-dimensional array into specific graphics according to the preset shape definition specifications and draw them in the corresponding cells of the dot matrix screen; Therefore, by adopting the technical solution of this application to build the required game scenes or characters, not only can the complexity of building game scenes or characters be reduced, thereby improving the building efficiency of game scenes or characters, but also simple basic graphics are built into complex game scenes or characters, which requires students to exert a certain amount of imagination and creativity, thereby being able to enhance students' programming interest and thinking innovation ability.
[0046] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically illustrates the specific embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The present invention will be further described below with reference to the accompanying drawings in conjunction with embodiments.
[0048] Figure 1 It is a flowchart of the execution of a method for rendering a character-to-dot matrix pattern in the first embodiment of the present invention;
[0049] Figure 2 It is one of the schematic diagrams of the definition of the basic graphic shape in the first embodiment of the present invention;
[0050] Figure 3 It is another schematic diagram of the definition of the basic graphic shape in the first embodiment of the present invention;
[0051] Figure 4 It is a schematic diagram of the definition of the decimal part in the first embodiment of the present invention;
[0052] Figure 5 It is one of the schematic diagrams of the definition of the graphic scaling factor in the first embodiment of the present invention;
[0053] Figure 6 It is another schematic diagram of the definition of the graphic scaling factor in the first embodiment of the present invention;
[0054] Figure 7 It is a schematic diagram of the definition of the graphic color in the first embodiment of the present invention;
[0055] Figure 8 Schematic diagram showing that different types of basic graphic shapes cannot appear in the same cell in the first embodiment of the present invention;
[0056] Figure 9 Schematic diagram showing four line segments with different rotation angles drawn in a cell in the first embodiment of the present invention;
[0057] Figure 10 The small sailboat drawn on the dot matrix screen in the first practical operation of the pattern case in the first embodiment of the present invention;
[0058] Figure 11 The values corresponding to the graphics of each cell in the dot matrix screen in the first practical operation of the pattern case in the first embodiment of the present invention;
[0059] Figure 12 The small castle drawn on the dot matrix screen in the second practical operation of the pattern case in the first embodiment of the present invention;
[0060] Figure 13 The values corresponding to the graphics of each cell in the dot matrix screen in the second practical operation of the pattern case in the first embodiment of the present invention;
[0061] Figure 14 The robot drawn on the dot matrix screen and the values corresponding to the graphics of each cell in the dot matrix screen in the third practical operation of the pattern case in the first embodiment of the present invention;
[0062] Figure 15 The small fish drawn on the dot matrix screen and the values corresponding to the graphics of each cell in the dot matrix screen in the fourth practical operation of the pattern case in the first embodiment of the present invention;
[0063] Figure 16 The little dog drawn on the dot matrix screen and the values corresponding to the graphics of each cell in the dot matrix screen in the fifth practical operation of the pattern case in the first embodiment of the present invention;
[0064] Figure 17 Schematic diagram of the structure of a character-to-dot matrix pattern rendering device in the second embodiment of the present invention;
[0065] Figure 18 Schematic diagram of the structure of an electronic device in the third embodiment of the present invention;
[0066] Figure 19 Schematic diagram of the structure of a medium in the fourth embodiment of the present invention. Detailed implementation manners
[0067] Embodiments of the present application provide a rendering method, device, equipment and medium for converting characters into dot matrix patterns, aiming to solve the problems existing in existing game programming, such as low efficiency due to using drawing tools to draw game scenes or characters, and being not conducive to enhancing students' programming interest and thinking innovation ability. Compared with the existing method of using drawing tools to draw game scenes or characters, the technical solution of the present application can build complex game scenes or characters by using simple basic graphics, which can not only improve the building efficiency of game scenes or characters, but also enhance students' programming interest and thinking innovation ability.
[0068] The general idea of the technical solution in the embodiments of the present application is as follows: Divide the display screen into a dot matrix screen with basic pixel units, and use numbers including an integer part and a decimal part to define basic graphics; Students input model data according to the game scenes or characters to be built. After the background receives the input model data, it parses the model data into a model two-dimensional array and maps it to the cells of the dot matrix screen; By extracting the model element values in the model two-dimensional array and according to the preset shape definition specification, the model element values can be disassembled and converted into specific graphics and drawn into the corresponding cells of the dot matrix screen. After all the model element values in the model two-dimensional array are drawn, the required game scenes or characters can be obtained.
[0069] Embodiment 1
[0070] This embodiment provides a rendering method for converting characters into dot matrix patterns. As Figure 1 shown, the rendering method is used for a game logic server, and the rendering method includes the following steps:
[0071] Step S1: Initialize the display screen and divide the display screen into a dot matrix screen with basic pixel units;
[0072] Step S2: Read the input model data, where the model data includes shape data and the starting position data of the starting cell to be displayed in the dot matrix screen; Among them, the model data is input by students through the client according to the game scenes or characters to be built. The client is a program corresponding to the server that provides local services for clients; The starting position data of the starting cell refers to the row and column position information of the starting cell. For example, if the cell in the upper left corner of the dot matrix screen is used as the starting cell, then the starting position data of this starting cell is the 1st column and the 1st row;
[0073] Step S3: According to the starting position data of the starting cell, parse the shape data into a two-dimensional model array and map it to the cells of the dot matrix screen. Since the dot matrix screen has columns and rows, and the two-dimensional model array also has columns and rows, when performing the specific mapping, only by corresponding the first model element value in the two-dimensional model array to the starting cell of the dot matrix screen can each model element value in the two-dimensional model array be corresponding to a cell in the dot matrix screen.
[0074] Step S4: According to the preset shape definition specification, extract the model element values in the two-dimensional model array, disassemble the model element values into at least one decomposed value, convert each decomposed value into a specific graphic and draw it into the corresponding cell of the dot matrix screen. After drawing all the model element values in the two-dimensional model array, the final dot matrix pattern is obtained. Among them, the preset shape definition specification is used to define simple graphics in the form of characters.
[0075] In the present invention, the display screen is divided into a dot matrix screen with basic pixel units, and simple graphics are defined in the form of characters, enabling students to input model data in the form of characters or character strings in the client. After receiving the model data, the game logic server can parse the model data into a two-dimensional model array and map it to the cells of the dot matrix screen, and disassemble and convert the model element values in the two-dimensional model array into specific graphics according to the preset shape definition specification and draw them into the corresponding cells of the dot matrix screen. Therefore, by adopting the technical solution of the present application to build the required game scenes or characters, not only can the complexity of building game scenes or characters be reduced, thereby improving the building efficiency of game scenes or characters, but also simple basic graphics are built into complex game scenes or characters, which requires students to exert a certain amount of imagination and creativity, thus being able to enhance students' programming interest and thinking innovation ability.
[0076] As a specific implementation manner of the present invention, in step S4, the preset shape definition specification includes: using characters to define graphics, where the characters can include numbers, letters, etc.; combining the defined characters into a character string, and each character string serves as a model element value in the two-dimensional model array. In this way, through each model element value in the two-dimensional model array, the required specific graphics can be drawn in the corresponding cell of the dot matrix screen according to the preset shape definition specification.
[0077] Among them, the use of characters to define a graphic at least includes using a first character to define a basic graphic shape, and the first character may specifically include one or more characters; the basic graphic shape includes, but is not limited to, one or more of a circle, a line segment, a triangle, a quadrilateral, and a semi-circle. Among them, a circle, a line segment, a triangle, a quadrilateral, and a semi-circle are the most commonly used shapes sorted out according to the actual implementation of this solution. Of course, this application is not limited to this. In specific implementation, other required basic graphic shapes can be added according to actual needs, such as an ellipse, a hexagon, an octagon, etc.
[0078] As a preferred embodiment of the present invention, in order to enrich the content of the graphic and thus better meet the requirements for building game scenes or characters, the use of characters to define a graphic further includes, but is not limited to, at least one of the following:
[0079] Using a second character to define the color of the graphic;
[0080] Using a third character to define the scaling factor of the graphic;
[0081] Using a fourth character to define whether the graphic has filling;
[0082] Using a fifth character to define the rotation angle of the graphic;
[0083] Using a sixth character to define the proportion of the graphic in the cell;
[0084] Using a seventh character to define the position of the graphic in the cell; among them, the second character, the third character, the fourth character, the fifth character, the sixth character, and the seventh character may specifically include one or more characters. Of course, this application is not limited to this. In specific implementation, other definitions of the graphic can be made according to actual needs, such as the offset of the graphic in the cell, etc.
[0085] As an optimal specific implementation manner of the present invention, the string is a number including an integer part and a decimal part; where:
[0086] Define the positive or negative of the number as whether the graphic has filling; for example, define a positive number as the graphic having filling and a negative number as the graphic having no filling;
[0087] Define the units digit of the integer part as the basic graphic shape, the tens digit of the integer part as the scaling factor of the graphic, and the hundreds digit of the integer part as the color of the graphic;
[0088] Define the fractional part as the rotation angle of the graphic, the proportion of the graphic in the cell, or the position of the graphic in the cell; in the specific implementation of the present invention, the rotation angle of the graphic, the proportion of the graphic in the cell, or the position of the graphic in the cell can all be defined by a single number, and the fractional part can include multiple numbers. In this way, when disassembling the fractional part of the model element value, each number in the fractional part can be regarded as an independent content, so that multiple identical graphics can be drawn in the same cell. For example, according to different rotation angles of the graphic, multiple graphics with the same shape but different rotation angles can be drawn in the same cell.
[0089] As a specific implementation manner of the present invention, in step S1, the initialization of the display screen and the division of the display screen into a dot matrix screen by basic pixel units specifically include:
[0090] Use a square unit with a side length of Z pixels as the basic pixel unit, divide the display screen into a cell array of X columns and Y rows, and define this cell array as a dot matrix screen. Here, Z, X, and Y are all positive integers; a pixel refers to the basic color element and its basic encoding of gray scale. A pixel is the basic unit that constitutes a digital image, and usually the image resolution is expressed in pixels per inch (PPI). The display screen needs to use a screen based on pixel units to ensure that the display screen can be divided by the basic pixel unit.
[0091] Define the initial two-dimensional array DOT_ARRAY corresponding to the dot matrix screen with the cell data type DOT. The initial two-dimensional array DOT_ARRAY corresponds one-to-one with the cells on the dot matrix screen. The initial element value in the initial two-dimensional array DOT_ARRAY corresponds to the graphic presented by the cell on the dot matrix screen, that is, each initial element value in the initial two-dimensional array DOT_ARRAY corresponds to a cell on the dot matrix screen; dot() is a function provided in the NumPy library of the Python programming language, and the dot() function is used for matrix multiplication operations.
[0092] Define the cell data type DOT. The attributes of DOT include: the position in the dot matrix screen (i.e., column X, row Y), the side length Z of the cell (in pixels), the instruction array NEW_BUFFER to be updated, the current effective instruction set INS_BUFFER, the flag bit FLAG_MODIFIED indicating whether the cell has changed, and the flag bit FLAG_CLEAR indicating whether the cell is cleared; the flag bit FLAG_MODIFIED indicating whether the cell has changed and the flag bit FLAG_CLEAR indicating whether the cell is cleared are both set to false in the initial state.
[0093] Define a cell drawing function DRAW for receiving drawing commands. The parameters received by the cell drawing function DRAW include the starting position data (S_X, S_Y) of the starting cell to be displayed on the dot matrix screen and the model two-dimensional array V_MODEL. The starting cell corresponds to the first model element value in the model two-dimensional array V_MODEL;
[0094] Create a pattern update rendering thread REFRESH_CLOCK and define a dot matrix screen refresh function REFRESH. The pattern update rendering thread REFRESH_CLOCK is an independent thread used to periodically run the dot matrix screen refresh function REFRESH; the pattern update rendering thread REFRESH_CLOCK is managed by an independent thread to run periodically to achieve the refresh of the dot matrix screen; start the pattern update rendering thread REFRESH_CLOCK, and through the pattern update rendering thread REFRESH_CLOCK, periodically run the dot matrix screen refresh function REFRESH. The time interval is 1 second divided by the set frame rate, and by default, it runs once every 20 milliseconds;
[0095] Define a cell clearing function CLEAR for clearing cells. When running this cell clearing function CLEAR, the flag bit FLAG_CLEAR indicating whether the cell is cleared can be set to true, and the instruction array NEW_BUFFER to be updated can be cleared.
[0096] As a preferred embodiment of the present invention, in order to improve the rendering efficiency of the dot matrix screen, the initialization of the display screen further includes:
[0097] Define a one-dimensional array DOT_REFRESH for area refresh. This one-dimensional array DOT_REFRESH for area refresh is a one-dimensional array of the DOT data type; the one-dimensional array DOT_REFRESH for area refresh is used to record the cells that need to update the graphics when the dot matrix screen is refreshed next time. It is ensured that when updating the pattern on the dot matrix screen each time, it is not necessary to update all the cells on the entire dot matrix screen, but only the cells that have changed, thereby improving the rendering efficiency of the dot matrix screen;
[0098] The cell drawing function DRAW is used to detect whether the model element values in the two-dimensional model array V_MODEL are consistent with the corresponding initial element values in the initial two-dimensional array DOT_ARRAY. If they are consistent, no processing is performed. If they are inconsistent, the cells with inconsistent element values are marked as needing to be updated, and the cells to be updated are added to the one-dimensional area refresh array DOT_REFRESH. When specifically performing the update operation on the pattern on the dot matrix screen, it is necessary to sequentially retrieve the cells to be updated and the corresponding model element values from the one-dimensional area refresh array DOT_REFRESH, so as to update the cells according to the model element values. After all the cells to be updated in the one-dimensional area refresh array DOT_REFRESH are retrieved, the one-dimensional area refresh array DOT_REFRESH is cleared. At the same time, when the update operation on the pattern on the dot matrix screen is completed, the updated two-dimensional model array V_MODEL is used as the initial two-dimensional array DOT_ARRAY for comparison during the next update.
[0099] As a specific implementation manner of the present invention, in step S4, the extracting the model element values in the two-dimensional model array, decomposing the model element values into at least one decomposed value, and converting each decomposed value into a specific graph and drawing it into the corresponding cell of the dot matrix screen specifically includes:
[0100] The cell clearing function CLEAR sets the flag bit FLAG_CLEAR indicating whether the cell is cleared to true, and clears the instruction array NEW_BUFFER to be updated to facilitate storing the content to be updated subsequently;
[0101] The cell drawing function DRAW extracts the model element values to be updated from the two-dimensional model array V_MODEL or the one-dimensional area refresh array DOT_REFRESH. In specific implementation, if the rendering efficiency is not considered, the model element values can be directly extracted from the two-dimensional model array V_MODEL, and the model element values can be extracted from the two-dimensional model array V_MODEL in the order of rows first and then columns. If it is necessary to improve the rendering efficiency, the model element values corresponding to the cells to be updated can be extracted from the one-dimensional area refresh array DOT_REFRESH; the extracted model element values are stored in the instruction array NEW_BUFFER to be updated, and the flag bit FLAG_MODIFIED indicating whether the cell has changed is set to true;
[0102] The dot matrix screen refresh function REFRESH checks whether the flag bit FLAG_CLEAR indicating whether the cell is cleared is true. If it is true, the current valid instruction set INS_BUFFER is cleared, and at the same time, the flag bit FLAG_CLEAR indicating whether the cell is cleared is reset to false. If it is false, the model element values stored in the instruction array NEW_BUFFER to be updated are added to the current valid instruction set INS_BUFFER, and the instruction array NEW_BUFFER to be updated is cleared. The cell drawing function DRAW takes out the model element values stored in the current valid instruction set INS_BUFFER and disassembles them into at least one decomposed value, converts each decomposed value into a specific graphic and draws it into the corresponding cell of the dot matrix screen, and resets the flag bit FLAG_MODIFIED indicating whether the cell has changed to false. In specific implementation, each defined basic graphic shape (such as circle, line segment, triangle, quadrilateral, semi-circle, etc.) is stored in the graphic library of the programming language. The cell drawing function DRAW can obtain the corresponding graphic from the graphic library according to the disassembled decomposed value and draw the obtained graphic into the corresponding cell of the dot matrix screen.
[0103] Taking a string as a number including an integer part and a decimal part as an example, the cell drawing function DRAW will disassemble the model element value into a hundreds digit, a tens digit, a units digit, and a decimal. Among them, the hundreds digit corresponds to the color of the graphic in this cell, the tens digit corresponds to the scaling factor of the graphic in this cell, the units digit corresponds to the basic graphic shape of the graphic in this cell, and the decimal digit corresponds to several deformations of the graphic, including the rotation angle of the graphic, the proportion of the graphic in the cell, or the position of the graphic in the cell. In addition, if the model element value is positive, it means that the basic graphic shape is a filled graphic, and if the model element value is negative, it means that the basic graphic shape is an unfilled graphic.
[0104] To better understand the technical solution of this application, the following lists some examples of using numbers to define graphics to further introduce this application in detail:
[0105] (1) Definition of basic graphic shape
[0106] As Figure 2 shown, when the value of the cell is 1, it represents a circle, when the value of the cell is 2, it represents a line segment, when the value of the cell is 3, it represents a triangle, when the value of the cell is 4, it represents a quadrilateral, and when the value of the cell is 5, it represents a semi-circle; the above are all positive integer parts, which means that the basic graphic shape is a filled graphic.
[0107] (2) Definition of basic graphic shape
[0108] As Figure 3As shown, when the value of a cell is -1, it represents a circle; when the value is -2, it represents a line segment; when the value is -3, it represents a triangle; when the value is -4, it represents a quadrilateral; when the value is -5, it represents a semi-circle. The above are all negative integer parts, indicating that the basic graphic shape is a line type, that is, a graphic without filling.
[0109] (3) Definition of the decimal part
[0110] The numbers after the decimal point represent the rotation angle of the graphic, the proportion of the graphic in the cell, or the position of the graphic in the cell. For example, Figure 4 as shown, 1.0 represents a circle that occupies 100% of the size in the cell, and 1.1 represents a circle that occupies 50% of the size in the cell; 2.0 represents a line segment standing upright against the left side, and 2.4 represents a line segment lying horizontally in the middle of the cell; 3.0 represents an equilateral triangle that occupies 100% of the size in the cell, and 3.2 represents an inverted triangle that occupies 100% of the size in the cell; 4.0 represents a quadrilateral that occupies 100% of the size in the cell, and 4.1 represents a quadrilateral that occupies 50% of the size in the cell; 5.0 represents a semi-circle placed upright, and 5.1 represents a semi-circle against the left side of the cell.
[0111] (4) Definition of the scaling factor of the graphic
[0112] For example, Figure 5 as shown, when the value is 21, the units digit 1 indicates that this graphic is a filled circle, and the tens digit 2 indicates that the circle is enlarged by 2 times on the original basis. As Figure 6 shown, when the value is 33, the units digit 3 indicates that this graphic is a filled triangle, and the tens digit 3 indicates that the triangle is enlarged by 3 times on the original basis. In specific implementation, the scaling factor can support 1 - 9 times.
[0113] (5) Definition of the graphic color
[0114] For example, Figure 7 as shown, the Figure 7 represents the colors supported by the graphic. From 0 - 9, they are the original background color, red, orange, yellow, green, cyan, blue, purple, gray, and white; color customization is also supported. For example, the value 323 represents a yellow triangle enlarged by 2 times on the original basis. Among them, the hundreds digit represents the color of the graphic, the tens digit represents the scaling factor of the graphic, and the units digit represents the basic graphic shape.
[0115] (6) Summary of special cases
[0116] For example, Figure 9As shown, the value is 2.1467, which can be decomposed into four independent parts: 2.1, 2.4, 2.6, and 2.7. This indicates that four line segments with different rotation angles need to be drawn in a single cell, and this operation is correct. As Figure 8 shown, different types of basic graphic shapes cannot appear in the same cell, and this operation is incorrect.
[0117] (7) Practical Operation of Pattern Case One
[0118] As Figure 10 shown, this Figure 10 represents a small sailboat drawn on the dot matrix screen; as Figure 11 shown, this Figure 11 represents the values corresponding to the graphics of each cell in the dot matrix screen. Among them, 0 indicates that the cell is blank, and the value 3.45 can be decomposed into the values 3.4 and 3.5, which means it is composed of two triangles with different rotation angles. Specifically, it can be understood in combination with Figure 4 ; and so on. Other values can be understood by referring to the definition of Figure 2-9 .
[0119] (8) Practical Operation of Pattern Case Two
[0120] As Figure 12 shown, this Figure 12 represents a small castle drawn on the dot matrix screen; as Figure 13 shown, this Figure 13 represents the values corresponding to the graphics of each cell in the dot matrix screen; among them, 0 indicates that the cell is blank, and the value 25 represents a semi - circle enlarged by 2 times on the original basis. That is, the units digit 5 indicates that the basic graphic shape is a semi - circle, and the tens digit 2 indicates that it is enlarged by 2 times on the original semi - circle; and so on. Other values can be understood by referring to the definition of Figure 2-9 .
[0121] (9) Practical Operation of Pattern Case Three
[0122] As Figure 14 shown, the left half of this Figure 14 represents a robot drawn on the dot matrix screen, and the right half represents the values corresponding to the graphics of each cell in the dot matrix screen; among them, 0 indicates that the cell is blank, and the value 44 represents a quadrilateral enlarged by 4 times. The units digit 4 indicates that the basic graphic shape is a quadrilateral, and the tens digit 4 indicates that it is enlarged by 4 times on the original quadrilateral; and so on. Other values can be understood by referring to the definition of Figure 2-9 .
[0123] (10) Practical Operation of Pattern Case Four
[0124] As Figure 15 shown, the left half of this Figure 15 represents a small fish drawn on the dot matrix screen, and the right half represents the values corresponding to the graphics of each cell in the dot matrix screen; among them, 0 indicates that the cell is blank, the value 33 represents a triangle magnified 3 times, the single digit 3 indicates that the basic graphic shape is a triangle, and the tens digit 3 indicates that the triangle is magnified 3 times on the original basis; and so on, other values can be understood with reference to Figure 2-9 the definition of
[0125] (11) Practical Operation of Pattern Case Five
[0126] As Figure 16 shown, the left half of this Figure 16 represents a puppy drawn on the dot matrix screen, and the right half represents the values corresponding to the graphics of each cell in the dot matrix screen; among them, 0 indicates that the cell is blank, the value 4.01 can be disassembled into the value 4.0 and the value 4.1, which represents a combination of two quadrilaterals with different proportions; and so on, other values can be understood with reference to Figure 2-9 the definition of
[0127] Based on the same inventive concept, the present application also provides an apparatus corresponding to the method in Embodiment 1. For details, see Embodiment 2.
[0128] Embodiment 2
[0129] In this embodiment, a rendering apparatus for converting characters into dot matrix patterns is provided. As Figure 2-17 shown, the rendering apparatus is used for a game logic server, and the rendering apparatus includes a dot matrix management module, a model reading module, a data mapping module, and a cell drawing module;
[0130] The dot matrix management module is used to initialize the display screen and divide the display screen with basic pixel units to form a dot matrix screen;
[0131] The model reading module is used to read the input model data, and the model data includes shape data and starting position data of the starting cell that needs to be displayed on the dot matrix screen; among them, the model data is input by the student through the client according to the game scene or character to be built, and the client (Client) refers to a program corresponding to the server that provides local services for the client; the starting position data of the starting cell refers to the row and column position information of the starting cell. For example, if the cell in the upper left corner of the dot matrix screen is used as the starting cell, then the starting position data of this starting cell is the 1st column and the 1st row;
[0132] The data mapping module is used to parse the shape data into a model two-dimensional array according to the starting position data of the starting cell and map it to the cells of the dot matrix screen. Since the dot matrix screen has columns and rows, and the model two-dimensional array also has columns and rows, in specific mapping, only by corresponding the first model element value in the model two-dimensional array to the starting cell of the dot matrix screen can each model element value in the model two-dimensional array be corresponded to a cell in the dot matrix screen;
[0133] The cell drawing module is used to extract the model element values in the model two-dimensional array according to the preset shape definition specification, disassemble the model element values into at least one decomposed value, convert each decomposed value into a specific graphic and draw it into the corresponding cell of the dot matrix screen. After all the model element values in the model two-dimensional array are drawn, the final dot matrix pattern is obtained. Among them, the preset shape definition specification is used to define simple graphics in the form of characters.
[0134] In the present invention, the display screen is divided into a dot matrix screen with basic pixel units, and simple graphics are defined in the form of characters, so that students can input model data in the form of characters or character strings in the client. After receiving the model data, the game logic server can parse the model data into a model two-dimensional array and map it to the cells of the dot matrix screen, and disassemble and convert the model element values in the model two-dimensional array into specific graphics according to the preset shape definition specification and draw them into the corresponding cells of the dot matrix screen. Therefore, by adopting the technical solution of the present application to build the required game scenes or characters, not only can the complexity of building game scenes or characters be reduced, thereby improving the building efficiency of game scenes or characters, but also simple basic graphics are built into complex game scenes or characters, which requires students to exert a certain amount of imagination and creativity, thus being able to enhance students' programming interest and thinking innovation ability.
[0135] For the specific function implementation of the dot matrix management module, the model reading module, the data mapping module, and the cell drawing module, since the dot matrix management module corresponds to step S1 of the first specific embodiment, the model reading module corresponds to step S2 of the first specific embodiment, the data mapping module corresponds to step S3 of the first specific embodiment, and the cell drawing module corresponds to step S4 of the first specific embodiment, which are all one-to-one corresponding relationships. For the detailed introduction, please refer to the first embodiment, and will not be elaborated here.
[0136] Based on the same inventive concept, the present application provides an electronic device embodiment corresponding to the first embodiment, as detailed in the third embodiment.
[0137] Embodiment Three
[0138] This embodiment provides an electronic device, such as Figure 18As shown, it includes a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, any implementation manner in Embodiment 1 can be realized.
[0139] Since the electronic device introduced in this embodiment is the device used to implement the method in Embodiment 1 of the present application, based on the method introduced in Embodiment 1 of the present application, those skilled in the art can understand the specific implementation manners and various variations of the electronic device in this embodiment. Therefore, the specific implementation of how this electronic device realizes the method in the embodiments of the present application will not be described in detail here. As long as the device used by those skilled in the art to implement the method in the embodiments of the present application belongs to the scope protected by the present application.
[0140] Based on the same inventive concept, the present application provides a storage medium corresponding to Embodiment 1. For details, see Embodiment 4.
[0141] Embodiment 4
[0142] This embodiment provides a computer-readable storage medium, as Figure 19 shown, on which a computer program is stored. When the computer program is executed by a processor, any implementation manner in Embodiment 1 can be realized.
[0143] Those skilled in the art should understand that the embodiments of the present invention can be provided as methods, devices, or computer program products. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0144] The present invention is described with reference to the flowcharts and / or block diagrams of methods, devices, and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be realized by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for realizing the specified functions in Figure 1 one or more flows or multiple flows and / or blocks Figure 1 one or more blocks or multiple blocks.
[0145] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including an instruction means that implements the functions specified in one or more of the processes and / or blocks Figure 1 one or more of the processes and / or blocks Figure 1 specified in the block(s).
[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one or more of the processes and / or blocks Figure 1 one or more of the processes and / or blocks Figure 1 specified in the block(s).
[0147] Although the specific embodiments of the present invention have been described above, those skilled in the art of this technology should understand that the specific embodiments we described are illustrative only and not used to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered by the scope of the claims of the present invention.
Claims
1. A rendering method for converting characters into dot matrix patterns, characterized in that: The rendering method is used for a game logic server, and the rendering method includes the following steps: Initialize the display screen, and divide the display screen into a dot matrix screen with basic pixel units, including: using a square unit with a side length of Z pixels as the basic pixel unit, dividing the display screen into a cell array of X columns and Y rows, and defining this cell array as the dot matrix screen; Define the initial two-dimensional array corresponding to the dot matrix screen with the cell data type of DOT. The initial two-dimensional array corresponds one-to-one with the cells on the dot matrix screen, and the initial element values in the initial two-dimensional array correspond to the graphics presented by the cells on the dot matrix screen; Read the input model data, where the model data includes shape data and the starting position data of the starting cell that needs to be displayed on the dot matrix screen; According to the starting position data of the starting cell, parse the shape data into a model two-dimensional array and map it to the cells of the dot matrix screen; According to the preset shape definition specification, extract the model element values in the model two-dimensional array, decompose the model element values into at least one decomposition value, convert each decomposition value into a specific graphic and draw it into the corresponding cell of the dot matrix screen. After drawing all the model element values in the model two-dimensional array, the final dot matrix pattern is obtained.
2. The rendering method of converting characters into dot matrix patterns according to claim 1, characterized in that: The preset shape definition specification includes: defining graphics using characters, combining the defined characters into a string, and each of the strings is used as a model element value in the model two-dimensional array; Among them, the defining graphics using characters at least includes using the first character to define the basic graphic shape; the basic graphic shape includes one or more of, but is not limited to, a circle, a line segment, a triangle, a quadrilateral, a semi-circle; 3. The rendering method of converting characters into dot matrix patterns according to claim 2, wherein: The defining graphics using characters also includes at least one of the following: Using the second character to define the color of the graphic; Using the third character to define the scaling factor of the graphic; Using the fourth character to define whether the graphic has filling; Using the fifth character to define the rotation angle of the graphic; Using the sixth character to define the proportion of the graphic in the cell; Using the seventh character to define the position of the graphic in the cell.
4. The rendering method of converting characters into dot matrix patterns according to claim 3, wherein: The string is a number including an integer part and a decimal part; where: Define the positive or negative of the number as whether the graphic has filling; Define the units digit of the integer part as the basic graphic shape, the tens digit of the integer part as the scaling factor of the graphic, and the hundreds digit of the integer part as the color of the graphic; Define the decimal part as the rotation angle of the graphic, the proportion of the graphic in the cell, or the position of the graphic in the cell.
5. The rendering method of converting characters into dot matrix patterns according to claim 1, characterized in that: The initializing the display screen and dividing the display screen into a dot matrix screen with basic pixel units specifically further includes: Define the cell data type DOT, and the attributes of DOT include: the position in the dot matrix screen, the side length of the cell, the instruction array to be updated, the current valid instruction set, the flag bit indicating whether the cell has changed, and the flag bit indicating whether the cell is cleared; the flag bit indicating whether the cell has changed and the flag bit indicating whether the cell is cleared are both set to false in the initial state; Define a cell drawing function for receiving drawing commands. The parameters received by the cell drawing function include the starting position data of the starting cell to be displayed on the dot matrix screen and the model two-dimensional array. The starting cell corresponds to the first model element value in the model two-dimensional array; Create a pattern update rendering thread and define a dot matrix screen refresh function. Start the pattern update rendering thread and run the dot matrix screen refresh function regularly through the pattern update rendering thread. The time interval is 1 second divided by the set frame rate; Define a cell clearing function for clearing cells.
6. The rendering method of converting characters into dot matrix patterns according to claim 5, characterized in that: The initialization of the display screen further includes: Define a one-dimensional array for area refresh, which is used to record the cells that need to update the graphics when the dot matrix screen is refreshed next time; Use the cell drawing function to detect whether the model element value in the model two-dimensional array is consistent with the corresponding initial element value in the initial two-dimensional array. If they are consistent, do nothing; if they are inconsistent, mark the cells with inconsistent element values as needing to be updated and add the cells that need to be updated to the one-dimensional array for area refresh.
7. The rendering method of character-to-dot matrix pattern according to claim 5 or 6, characterized in that: The extraction of the model element values in the model two-dimensional array, disassembling the model element values into at least one decomposed value, and converting each decomposed value into a specific graphic and drawing it into the corresponding cell of the dot matrix screen specifically includes: Use the cell clearing function to set the flag position indicating whether the cell is cleared to true and clear the instruction array that needs to be updated; The cell drawing function extracts the model element values that need to be updated from the model two-dimensional array or the one-dimensional array for area refresh, stores the extracted model element values into the instruction array that needs to be updated, and sets the flag position indicating whether the cell has changed to true; The dot matrix screen refresh function detects whether the flag bit indicating whether the cell is cleared is true. If it is true, clear the current effective instruction set and at the same time reset the flag bit indicating whether the cell is cleared to false; If it is false, add the model element values stored in the instruction array that needs to be updated to the current effective instruction set and clear the instruction array that needs to be updated; The cell drawing function takes out the model element values stored in the current effective instruction set, disassembles them into at least one decomposed value, converts each decomposed value into a specific graphic and draws it into the corresponding cell of the dot matrix screen, and resets the flag bit indicating whether the cell has changed to false.
8. A rendering device for converting characters into dot matrix patterns, characterized in that: The rendering device is used for a game logic server. The rendering device includes a dot matrix management module, a model reading module, a data mapping module, and a cell drawing module; The dot matrix management module is used to initialize the display screen, divide the display screen with basic pixel units to form a dot matrix screen, including: using a square unit with a side length of Z pixels as the basic pixel unit, dividing the display screen into a cell array of X columns and Y rows, and defining this cell array as the dot matrix screen; Define an initial two-dimensional array corresponding to the dot matrix screen with the cell data type of DOT. The initial two-dimensional array corresponds to the cells on the dot matrix screen one by one, and the initial element values in the initial two-dimensional array correspond to the graphics presented by the cells on the dot matrix screen; The model reading module is configured to read the input model data, where the model data includes shape data and starting position data of a starting cell to be displayed on the dot matrix screen; The data mapping module is configured to parse the shape data into a model two-dimensional array according to the starting position data of the starting cell and map it to the cells of the dot matrix screen; The cell drawing module is configured to extract model element values from the model two-dimensional array according to the preset shape definition specification, disassemble the model element values into at least one decomposed value, convert each decomposed value into a specific graphic and draw it into the corresponding cell of the dot matrix screen. After all the model element values in the model two-dimensional array are drawn, the final dot matrix pattern is obtained.
9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for drawing monochrome screen and electronic device
CN106875884A
Drawing data management device and drawing data management program
JP2013246782A