Link List with GraphicsFor this project you will be creating a link list and drawing the nodes to the screen. Each node will bedrawn as a rectangle. Each node will have the ability to link to at least 4 other nodes. Create a SDL2project to open a graphics window for this assignment. Set the background color to something dull.Create a Node structure as follows to create the nodes for the link list.Node:• rectangle SDL_Rect• color SDL_Color or rgb values, your choice• 4 Node pointers (links)• draw() Draws a solid (filled) rectangle• Node() Add arguments to your constructor(s) as you see fitBefore your main loop create 5 Node objects on the heap. Link the nodes to each other in the patternshown below. Begin by linking each node to the node adjacent to it. The center node will be linked toall 4 surrounding nodes. Then link each outer node to the node on the opposite side, creating a wraparound effect as indicated by the green arrows.Create a Node pointer called current and set it to one of the five nodes.In the main loop collect input from the user using an event switch. Implement keyboard controls usingthe WASD keys to change the current pointer to one of the linked nodes. Example, if the current nodeis the center node, then pressing W will change it to the left of the center, pressing W again will changeit to the node right of the center.Call draw() on all of the nodes.Finally, draw a rectangle around the current node using a contrasting color.Pressing the Esc key should free up all memory and end the program.Tips:• Follow this assignment line by line, 1 step at a time.• The 4 pointers in the structure can be called whatever you want, but up, down, left and rightmay be most intuitive.• Initialize all pointers to nullptr.• Hard code the size of the rectangles in the Node constructor, but pass in the x and y location
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here