A framework construction method for implementing asynchronous speed animation interactive program in VBA

By designing the framework of an asynchronous speed animation interactive program in VBA, the problem of the lack of speed setting interface functions is solved, asynchronous updating of animation elements and user input processing are realized, simplifying program writing, flexible expansion, and suitable for game and data element animation writing .

CN112346719BInactive Publication Date: 2024-10-18SHANDONG NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011109903.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-16
Publication Date
2024-10-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The lack of direct speed setting interface functions in VBA makes it difficult to implement different speed settings for different elements in interactive games, which limits the flexibility and complexity of animation programs.

Method used

By designing the framework of an asynchronous speed animation interactive program in VBA, setting the initial speed values ​​of different elements, defining control variables and time length variables, establishing an overall loop and nesting different speed element animation codes, adding interactive control codes, and realizing animation Asynchronous updates of elements and user input handling.

Benefits of technology

It realizes the writing of demand-based event response functions and animation keyframe change codes in VBA, which simplifies the writing of animation programs and is flexible in expansion. It is suitable for writing game and data element animations, and facilitates user input and program expansion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112346719B_ABST
    Figure CN112346719B_ABST
Patent Text Reader

Abstract

The present disclosure provides a framework construction method for realizing asynchronous speed animation interactive program in VBA, comprising the following steps: setting the initial speed values ​​of different elements according to preset requirements, and normalizing the different speeds; defining corresponding control variables and time length variables for different speed elements; establishing an overall loop, and according to the size of the speed value, using the loop to nest different speed element animation codes; adding the interactive control code of all elements in the corresponding loop to complete the program framework construction; the present disclosure can fill in the corresponding event response function and the animation key frame change code in the framework according to different needs, and can be used for the writing of game codes based on VBA, and can also be used for the writing of animation programs of different data elements, and is simple to implement, the algorithm is easy to understand, and the expansion is flexible.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of program framework design, and in particular to a framework construction method for realizing asynchronous speed animation interactive program in VBA. Background Art

[0002] The statements in this section merely provide background art related to the present disclosure and do not necessarily constitute prior art.

[0003] Excel is a common spreadsheet software. Due to its powerful calculation, visualization and data processing functions, this software is applied to various fields. VBA (Visual Basic for Applications) is a macro programming language embedded in Excel. This language can be used to construct powerful applications in Excel software (or other Office software). Furthermore, various visualization or dynamic programs related to spreadsheets can be established based on VBA. The animation technology implemented based on VBA in Excel can be used in fields such as game design, game programming education, algorithm demonstration and dynamic data visualization.

[0004] The inventors of the present disclosure have discovered that although VBA is a function that helps implement interactive animation, some advanced functions are not available in VBA. When using VBA to generate interactive animations, such as implementing different speeds of different elements in an interactive game, there is no direct speed setting interface function in VBA. Summary of the invention

[0005] In order to address the deficiencies in the prior art, the present disclosure provides a framework construction method for implementing asynchronous speed animation interactive programs in VBA, which can fill in corresponding event response functions and animation key frame change codes in the framework according to different needs. It can be used for writing game codes based on VBA, and can also be used for writing animation programs for different data elements. It is simple to implement, the algorithm is easy to understand, and the expansion is flexible.

[0006] In order to achieve the above objectives, the present disclosure adopts the following technical solutions:

[0007] A first aspect of the present disclosure provides a framework construction method for implementing an asynchronous speed animation interactive program in VBA.

[0008] A framework construction method for realizing an asynchronous speed animation interactive program in VBA comprises the following steps:

[0009] Set the initial speed values ​​of different elements according to preset requirements and normalize different speeds;

[0010] Define corresponding control variables and time length variables for different speed elements;

[0011] Establish an overall loop, and use loops to nest different speed element animation codes according to the speed value;

[0012] Add the interactive control codes of all elements in the corresponding loop to complete the construction of the program framework.

[0013] As some possible implementations, in the program framework, updates of all animation elements and user input information appear in an overall loop, and the codes of different elements in the overall loop are combined in a nested loop manner.

[0014] As some possible implementations, for an element, in a nested loop, the auxiliary variables are first initialized and the element is updated last.

[0015] As a further limitation, the time occupied by the initialization of auxiliary variables and the updating code of elements is less than a preset value, and the time occupied by any element is mainly the loop filling code.

[0016] As a further limitation, in the loop of the current element, the loop setting of the next element is performed until the setting of the last element is completed.

[0017] As some implementations may be possible, add interaction control code for all elements to all loops.

[0018] A second aspect of the present disclosure provides a framework system for implementing an asynchronous speed animation interactive program in VBA.

[0019] A framework system for implementing an asynchronous speed animation interactive program in VBA, comprising: a total loop and nested loops of codes of different elements in the total loop;

[0020] All animation element updates and user input information appear in the overall loop, in which the codes of different elements are combined in a nested loop;

[0021] In the loop of the current element, the loop of the next element is set, and the loop of the last element is set in the loop of the previous element.

[0022] As some possible implementations, for an element, in a nested loop, the auxiliary variables are first initialized and the element is updated last.

[0023] As some possible implementations, the interaction control codes of all elements are set in all loops.

[0024] A third aspect of the present disclosure provides an electronic device, comprising the framework system for implementing an asynchronous speed animation interactive program in VBA as described in the second aspect of the present disclosure.

[0025] Compared with the prior art, the beneficial effects of the present invention are:

[0026] 1. The method, framework system or electronic device disclosed in the present invention can fill in the corresponding event response function and animation key frame change code in the framework according to different needs, and can be used for writing VBA-based game codes as well as writing animation programs for different data elements.

[0027] 2. The method, framework system or electronic device described in the present disclosure is simple to implement, the algorithm is easy to understand, and the expansion is flexible. People with a certain programming foundation can expand it and implement corresponding program content according to needs.

[0028] 3. In the method, framework system or electronic device disclosed in the present invention, the interactive control codes of all elements are set in all loops, which can facilitate user input at any time point.

[0029] Advantages of additional aspects of the present disclosure will be given in part in the following description and in part will become apparent from the following description or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The accompanying drawings constituting a part of the present disclosure are used to provide a further understanding of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure.

[0031] Figure 1 A flowchart of a method for constructing a framework for implementing an asynchronous speed animation interactive program in VBA provided in Embodiment 1 of the present disclosure.

[0032] Figure 2 A schematic diagram of the framework algorithm provided for Example 1 of the present disclosure.

[0033] Figure 3 This is a screenshot of block movement in the initial stage provided in Example 1 of the present disclosure.

[0034] Figure 4 This is a screenshot of the block movement after pressing the button provided in Example 1 of the present disclosure. DETAILED DESCRIPTION

[0035] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.

[0036] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.

[0037] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.

[0038] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.

[0039] Embodiment 1:

[0040] like Figure 1 As shown, Embodiment 1 of the present disclosure provides a framework construction method for implementing an asynchronous speed animation interactive program in VBA, comprising the following steps:

[0041] Step 1: Set the initial speed values ​​of different elements according to the requirements; normalize the different speeds to a ratio with the maximum speed as 1;

[0042] Step 2: Define corresponding control variables and time length variables for different speed elements;

[0043] Step 3: Create an overall loop and use loops to nest different speed element animation codes according to the speed value.

[0044] Step 4: Add interactive control code in the corresponding loop;

[0045] Step 5: Testing.

[0046] Steps 2 to 4 are the main part of the program framework described in this embodiment. The basic code of the framework is as follows Figure 2 For ease of understanding, pseudocode based on general high-level languages ​​is used here, and VBA codes are used to describe subsequent specific cases.

[0047] In this embodiment, for convenience, it is assumed that there are three elements: element 1, element 2 and element 3, and the speed of each element is speed 1, speed 2 and speed 3. It is stipulated that speed 1 is the slowest, speed 2 is the second, and speed 3 is the fastest.

[0048] Figure 2 In the framework algorithm, it is explained as follows:

[0049] Line 1 is the overall loop of the animation. All animation element updates and user input information appear in this overall loop. The code of different elements in the overall loop is combined in a nested loop.

[0050] Lines 3 to 17 are loops for element 1. Line 3 is the initialization of auxiliary variables. Line 16 is the update of the element. For example, for an element moving in a straight line, the animation code may be to erase at the old position and redraw at the new position.

[0051] The code in lines 3 and 16 takes almost no time, so the time for element 1 is filled by the loop in line 4. In the loop for element 1, the setting for element 2 is done in the same way.

[0052] The structure of the code for element 2 is exactly the same as that for element 1, except for the specific variables. Lines 7 to 14 in the figure are the code for element 2. Similarly, element 3 can be added, etc.

[0053] Also note that lines 5 and 9 are interactive codes for all elements, that is, accepting user input and updating related variables. Since the user may input at any time, this code needs to be placed in all loops.

[0054] Let's use a specific example to illustrate. Suppose there are three blocks moving at different speeds. The blocks in the first row are the slowest, the blocks in the second row are the second slowest, and the blocks in the third row are the fastest. In addition, to demonstrate user interaction, when the user presses A, B, or C on the keyboard, the three blocks change color.

[0055] Figure 3 and Figure 4 This is a screenshot of the example. Figure 3 Take a screenshot of the start run; Figure 4 This is a screenshot taken after pressing three keys for a while.

[0056] The complete code is as follows:

[0057]

[0058]

[0059]

[0060]

[0061] The DoEvents in the code provides intermittent control for the VBA program. It is not the main part of the code and can be omitted.

[0062] The temporary variables in the code are all global variables and need to be declared globally. The keyboard scanning function GetAsyncKeyState needs to be defined additionally, but it is no different from the general method.

[0063] The movement of the blocks is achieved by coloring different cells, and other codes can be understood through comments.

[0064] The time interval is inversely proportional to the speed, so the slowest block here uses the largest interval, and the same applies to the others. Note that the speeds of the three blocks are all doubled. Figure 3 and Figure 4 From the position of the block, we can see that the distance it moves is also twice as much.

[0065] If you only use animation and do not need interactive control, you can delete the input control function processInput.

[0066] Embodiment 2:

[0067] Embodiment 2 of the present disclosure provides a framework system for implementing an asynchronous speed animation interactive program in VBA, including: a total loop and nested loops of codes of different elements in the total loop;

[0068] All animation element updates and user input information appear in the overall loop, in which the codes of different elements are combined in a nested loop;

[0069] In the loop of the current element, the loop of the next element is set, and the loop of the last element is set in the loop of the previous element.

[0070] The specific details of the frame system are the same as those in Example 1 and will not be repeated here.

[0071] Embodiment 3:

[0072] Embodiment 3 of the present disclosure provides an electronic device, including the framework system for implementing the asynchronous speed animation interaction program in VBA as described in Embodiment 2 of the present disclosure.

[0073] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer-usable program code.

[0074] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0075] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0076] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0077] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).

[0078] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. For those skilled in the art, the present disclosure may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A framework construction method for implementing an asynchronous speed animation interactive program in VBA, characterized in that: The following steps are involved: Set the initial speed values ​​of different elements according to preset requirements and normalize different speeds; Define corresponding control variables and time length variables for different speed elements; Establish an overall loop, and use loops to nest different speed element animation codes according to the size of the speed value; specifically, in the program framework, the update of all animation elements and user input information appear in the overall loop, and the codes of different elements in the overall loop are combined in a nested loop manner; Add the interactive control codes of all elements in the corresponding loops to complete the construction of the program framework. Specifically, add the interactive control codes of all elements to all loops.

2. The framework construction method for realizing asynchronous speed animation interactive program in VBA as claimed in claim 1, characterized in that: For an element, in a nested loop, the auxiliary variables are initialized first and the element is updated last.

3. The framework construction method for realizing asynchronous speed animation interactive program in VBA as claimed in claim 2, characterized in that: The time occupied by the initialization of auxiliary variables and the updating code of elements is less than the preset value, and the main time occupied by any element is the loop filling code.

4. The framework construction method for realizing asynchronous speed animation interactive program in VBA as claimed in claim 2, characterized in that: In the loop of the current element, the next element is set in a loop until the last element is set.

5. A framework system for implementing asynchronous speed animation interactive program in VBA, characterized in that: include: The speed normalization processing module is used to set the initial speed values ​​of different elements according to preset requirements and perform normalization processing on different speeds; Speed ​​element definition module, used to define corresponding control variables and time length variables for different speed elements; The overall loop building module is used for the overall loop and the nested loops of the codes of different elements in the overall loop; specifically, the updates of all animation elements and user input information appear in the overall loop, and the codes of different elements in the overall loop are combined in a nested loop manner; The program framework construction module sets the loop of the next element in the loop of the current element, and the loop of the last element is set in the loop of the previous element; the interactive control codes of all elements are added in the corresponding loops to complete the program framework construction. Specifically, the interactive control codes of all elements are added to all loops.

6. The framework system for implementing asynchronous speed animation interactive program in VBA as claimed in claim 5, characterized in that: It also includes, that the overall loop establishes a submodule, and for an element, in a nested loop, firstly initializes the auxiliary variables, and finally updates the element.

7. An electronic device comprising a memory, a processor, and a program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps in the framework construction method for implementing an asynchronous speed animation interactive program in VBA as described in any one of claims 1 to 4 are implemented.

Citation Information

Patent Citations

  • Job shop scheduling Gantt chart forming method based on Excel and VB

    CN106502976A

  • VBA-based multi-software co-simulation system

    CN106842982A