Page 1 of 1

Switches?

PostPosted: Tue Dec 30, 2008 12:51 pm
by Quill
Hello, I'm new to the Game-editor but I feel it's a great program for making games and I'm enjoying it alot.

One question though, is there a 'switch' function in Game editor? When I say switches I mean as an event, put 'Switch1 = on' or similar. Then in other events you can put 'if switch1 = on something happens' and 'if switch1 = off something else happens'.

When I've used another program this really helped the process, but I'm not sure whether game editor has this.

Re: Switches?

PostPosted: Tue Dec 30, 2008 1:42 pm
by skydereign
This can be done many ways. I believe your 'switch' would be a global variable. You can set the variable to 1, simulating on, and 0 for off. If you know a little scripting then you can use this to make the events you wish. I believe there are several gameEditor tutorials, some built in, that can help teach you. If you don't know much scripting then looking on the forum can help. If you can't find what you are looking for, just ask.

Re: Switches?

PostPosted: Tue Dec 30, 2008 3:45 pm
by Quill
Ah thanks. Currently I don't know any script except yvelocity and xvelocity, but that's the reason why I chose this, to start programming.

Thanks again!

Re: Switches?

PostPosted: Wed Dec 31, 2008 6:09 pm
by Freddy
Yeah, you can make a variable and use it like this:
If(variable = 1)
{ xvelocity = xvelocity + 1}

Re: Switches?

PostPosted: Thu Jan 01, 2009 7:25 pm
by BlarghNRawr
if(variable==1)
{xvelocity=xvelocity+1}

forgot an equls

Re: Switches?

PostPosted: Thu Jan 01, 2009 11:08 pm
by DST
xvelocity+=variable;

Re: Switches?

PostPosted: Mon Jan 12, 2009 8:14 pm
by Quill
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?

Re: Switches?

PostPosted: Mon Jan 12, 2009 11:57 pm
by skydereign
There are many ways to do this, it really depends on what you like and are comfortable with.

Re: Switches?

PostPosted: Wed Jan 14, 2009 7:04 am
by Fuzzy
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.

Re: Switches?

PostPosted: Mon Jan 19, 2009 9:57 pm
by Quill
That makes sence. I'll try that out next time. Thanks!

Re: Switches?

PostPosted: Sat Mar 07, 2009 9:02 pm
by BlarghNRawr
that 4 line code dont have to be 4 lines, it can be one line with spaces... like this=> code {more code}

... just putting that out there

Re: Switches?

PostPosted: Sun Mar 08, 2009 5:36 pm
by Fuzzy
BlarghNRawr wrote:that 4 line code dont have to be 4 lines, it can be one line with spaces... like this=> code {more code}

... just putting that out there


You are missing the point. Reductionism in coding is a laudable enterprise. Elimination of line feeds is simply an exercise in obfuscation.

Re: Switches?

PostPosted: Sun Mar 08, 2009 6:29 pm
by BlarghNRawr
i only understood the word 'of' :shock: ....