This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Diagonal Movement of an Image
Let’s examine step by step how the logo will move diagonally.
*Step 1: First, we define the logo photo under the “private” line in “header(.h)”.
*Step 2: We upload our logo that we defined in “.h” to our code in the setup function under our “.cpp” code page.
Our logo we uploaded; Located at C: \ dev \ glist \ myglistapp \ GlistApp \ assets \ images.
*Step 3: In this step, we define a special x and y in “.h”. In the draw function in “.cpp”, we first clean the background, then determine the drawing color and draw our logo.
Code: (.h)
*Step 4: The deltax (dx) and deltay (dy) values that specify how much the photo will move in a frame are defined in “.h” and given the value in “.cpp”.
Code: (.cpp)
*Step 5: We give the first movement to our logo.
Code: (.cpp)
In this step, our logo moves but goes out of frame.
*Step 6: Increase x until reaching left or right side of the screen and increase y until reaching top or bottom side of the screen.
Code:
By doing this step, we ensure that our logo moves and stays on the screen.
*Step 7: And finally, we hit the run button to run our code and we see our logo move diagonally across the screen.
Categories
Recent Posts
Installation – Linux
31/01/2023Installation – MacOS
31/01/2023Installation – Windows
31/01/2023