Quill wrote:This is great and will/has come in useful. This also has helped me understand how to use variables proporly, so that actually gets one question in my mind out the way (how to make a health system. Simple, use a variable as the health and when the collision event/whatever event happens make the variable go down) but I have one more question. How do you make a title screen? I'm getting a friend to draw the graphics but I'm not sure how to impliment it.
Do you simple have to create an actor that's the title screen somewhere, and when you press the 'start' button (or any button in my case) you then use the create actors event for the characters/ enemies and then use the script to move the view to the main actor?
That will work, yes.
I avoid situations like what was mentioned before. I am not in favour of if statements. To me, its like having the computer make a decision over and over when the programmer can plan ahead and avoid that. Ifs are branches in the code and make things more cluttered too.
What I like to do is have a variable and use that as a multiplier. For example, when jumping, you dont say this in key down event
- Code: Select all
if (jump == 1)
{
yvelocity = 5;
}
Two reasons. First, thats four lines of code. second, you will have to set it to zero again later. Thats at least 4 more lines.
Instead, try to do things like this in draw actor:
- Code: Select all
yvelocity = 5*jump; // jump flips on and off in key down event: always comment your code.
See? One line.
now in the key down event put
- Code: Select all
jump = abs(jump-1); // takes one off jump, then ignore the negative sign if there is one. result is either zero or one.
And thats only two lines. You can see that its much cleaner looking too. My comments make it a bit longer, but they are important reminders.