This is an old revision 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.
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!
The rmlist function will call clearlist() function. After the list is successfully cleared, then the list itself will be deallocated from memory.