Make the person walk randomly around the screen as part of the act method. The line does not have to hold the Color value in a field, but it could to make it more accessible, rather than getting the image and getting the color from it.1. Something to think about: instead of 'int' values, you could just have a unique Color value for each boat and that would determine the color of the line and the color to follow. Then have the boats only follow lines that have the same value in its field. When creating the line objects for the boats, have the value of that field in the line take on the same value as the boat that is to follow it. Give each boat a different value for that field. In other words, add an instance 'int' field to the Boat class and to the Line class. You could have your line actors and the boat that follow them both hold a key number where the boat will only follow lines with the same number that it has. Using an array or separate classes would both work, but neither is really necessary. I am sure there are several ways to accomplish that, since you are using actors. The width of the image of the line object can be more than one to avoid skipping over it (the line drawn on the image can still be of width one) A continuous check to see if more than one line is intersected should be made to jump from one line to the next. This process would probably require more fields in the Ship class (one for the line it is currently on and one for its offset from the center of that line). Your ships can then find the appropriate line by the color they hold, take on their rotation, follow them from back to front and change to the next line. The lines should also hold the color value given them. These lines can be created horizontal (from left to right) with the appropriate length, placed halfway between the last and current location of the mouse and turned the appropriate angle using 'Math.atan2'. If you add three instance 'int' fields to the class your mouse 'drag' detection is at (one to hold the drawing mouse button and the other two to hold the coordinates the mouse was last at), you can then set all three fields when a mouse button is pressed for each mouse drag event and for the final mouse clicked event, you can create a line actor to 'connect' the last location to the current one and save the current one. If you create an actor at every pixel between those currently being created, you will end up with quite a few actors, and this may cause some lag. With the method you are using now, you are getting large gaps when the mouse is moved quickly. The title of this discussion should be more like 'Making a line for an actor to follow'. Keep in mind that I'm a beginning programmer and this is all self-taught. The movement isn't really natural at the moment, since ships generally don't drift Need for Speed-style through ports.Īny other general suggestions that would improve this project would be nice. How to align the ship so that it doesn't stay slightly diagonal when following a straight horizontal line after taking a turn up/downwards. Any suggestions on making the objects spawn more rapidly or how to connect them so they form a solid line would be awesome. Maybe I should be using a different method than a seperate actor that guides the boats, but this was the only option that came to mind. How to make the line of objects solid when I move the mouse too quickly. I have a few things that are bothering me and I can't quite figure out though When you drag your mouse, it creates a line of objects and if the first node is within range of the right boat, it will start moving along the line, constantly removing a line object and orienting on the next. Right now I'm using a different line object actor that creates a new instace on mouse click (left for a blue line, red for a red line, the appropriately colored ship will rotate and move towards the closest guide object). So I'm trying to make a game similar to Flight Control where a user draws a line to guide an Actor along a path.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |