Link List with Graphics For this project you will be creating a link list and drawing the nodes to the screen. Each node will be drawn as a rectangle. Each node will have the ability to link to at...


Link List with Graphics
For this project you will be creating a link list and drawing the nodes to the screen. Each node will be
drawn as a rectangle. Each node will have the ability to link to at least 4 other nodes. Create a SDL2
project 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 fit
Before your main loop create 5 Node objects on the heap. Link the nodes to each other in the pattern
shown below. Begin by linking each node to the node adjacent to it. The center node will be linked to
all 4 surrounding nodes. Then link each outer node to the node on the opposite side, creating a wrap￾around 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 using
the WASD keys to change the current pointer to one of the linked nodes. Example, if the current node
is the center node, then pressing W will change it to the left of the center, pressing W again will change
it 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 right
may 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

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here