Corning Community College
CSCS2320 Data Structures
Evolve your space invaders game into something more, considering something like galaga. Also, implement a doubly-linked list and update everything to take advantage of that new list functionality.
You will want to go here to edit and fill in the various sections of the document:
One way to make randomly moving enemies is to have them spawn at random positions and going different directions at different speeds and bouncing around like PC screen saver!
One way to use trigonometric functions is to model how your enemies will move. Maybe you want them to move in a circle? Or in a cosine wave? The Vircon “math.h” library has functions to help you achieve this. Remember, a circle is X squared + Y squared = r squared. Since we can only manipulate X and Y individually, this is where the sin and cos functions will come into play. Both can be used so that they come together and make the node move in a circle. A simple draw_region_at can be used as well, as the rotated counterpart will spin the node.
The primary difference between a singly and doubly-linked list is that a singly-linked list can only move forward in direction. For example, if you start at First, you can only move to the next until you hit the Last. With a doubly-linked list, you can move both to the next and previous node, offering more freedom in data access. However, keep in mind this will require more hygiene of the user to keep the pointers between nodes in order, both for making the nodes and removing them.
To make a node you need to allocate memory for it, and initialize any values that need to be, for parameters you want to pass it anything that might change between nodes, like X and Y coordinates, but anything that remains the same, like speed, can be hard-coded into the function.
Don't forget that this is a non void function, meaning that it needs to return a value!
To be to use rmnode you must first use obtain(). rmnode does what it sounds like it does, removes the given node. First you will want to check if the given node is NULL or not as there is no reason to remove something that doesn't exists. Now your given node has an attribute to it (→ next) and (→ prev) which will both need to be set to NULL, if not then some undesirable stuff will happen. Then the node is prepped to be removed.
Don't forget that since this is not a void function it needs to return a value!
For mklist one must name there list like they have the other struct objects in previous projects. And also just like previous projects one must allocate memory for said list! Or else there will be issues in your future! In typical faction one must set their lists attributes to NULL.
Don't forget that this is a non void function, meaning that it needs to return a value!
The insert function should operate a bit like the append function. However, this time it should allow a node to be placed wherever in the last as opposed to strictly the end. If desired, insert could be used like obtain().
To Append is to Add After, not Before. With doubly linked lists we can now go backwards. When adding stuff to the end of a list we need to check where we are adding the node to as that decides the rest of what we do. You need to check for if the Old_Node that New_Node is going after is:
1. At the Start/Doesn't Exist 2. At the End 3. or in the Middle
One way to tell for the First option is to see if your list == NULL. If so then the lists two ends need to point to the New_Node and it's next and previous need to be NULL as there are no other nodes in the list.
One way to tell for the Second option is to see if your Old_Node == end of the list. If so then Old_Node now point to the New_Node which point's right back at it, but the New_Node also needs to point somewhere else else.
The Third option is like the Second in terms of pointing but that New_Node needs to point at what Old_Node was pointing at next before it was pointing at New_Node.
Don't forget that since this is a function it needs a return value!
For the most part, the obtain() function should be the same as the obtain() function in msi2. Loop through your list until you find the node you would like to obtain, then return the list.
The clearlist() function should be the same as in msi2, as well. Loop through your list and remove each node in the list using your rmnode() function until the list reaches NULL (end of list). Make sure the list's start and end is NULL, then return the list.
The rmlist function will call clearlist() function. After the list is successfully cleared, then the list itself will be deallocated from memory.
To be successful in this project, the following criteria (or their equivalent) must be met:
Let's say you have completed work on the project, and are ready to submit, you would do the following:
lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN
You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.
I'll be evaluating the project based on the following criteria:
156:msi3:final tally of results (156/156) *:msi3:doubly linked list and node implemented [52/52] *:msi3:API optimized for use with doubly linked node [52/52] *:msi3:additional game functionality implemented beyond space invaders [52/52]