If..Then..Else?

For questions about using Classic.

Post » Thu Feb 11, 2010 7:37 pm

Hi,
Only had Construct for one week so still complete noob, many years ago I used to program in Speccy Basic, and then Stos ( on the Atari ST ).
Have created a one screen game, move collect keys, open doors leave screen. I have a variable "keys" that debug shows to be working just as I hoped, ie increases by one if key is picked up, decreases when door is destroyed, but I need to know how to perform the equivalent of:-

If "keys" = 0
Then Bounce
Else Destroy

So that if I have no key then the door will remain locked

Hope the explaination is clear, TIA Brett
B
2
G
2
Posts: 12
Reputation: 674

Post » Thu Feb 11, 2010 7:54 pm

if dude collides with door
+value "keys" = 0
--> bounce

if dude collides with door
+value "keys" = bigger than 0
--> destroy door
--> subtract 1 from "keys"

try something like that.
B
2
S
1
G
4
Posts: 71
Reputation: 1,342

Post » Thu Feb 11, 2010 8:29 pm

Hi thanks for your reply, the real problem is in using construct, I know what I want to do, and the order I need to do them in, the trouble is that I right click here and can only compare a variable if it is the first set of an event, I would like to set it up as :-

if dude hits door
and keys = 0

But can only seem to start from :-

if keys = 0
and dude hits door
Then new action does not include Bounce in the options. I just seem to be fighting the programs controls rather than getting on with what I want to do. Have tried the FAQ and Wiki but not like a real manual. Cheers Brett
B
2
G
2
Posts: 12
Reputation: 674

Post » Thu Feb 11, 2010 9:13 pm

I'm not 100% sure what your problem was so this cap might be what you've got made already.

http://dl.dropbox.com/u/1646976/doorsandkeys.cap

Try go through the gray door at the start, yellow square is the key.

Sorry if this is what you already have.

Also posting a cap is always helpful to anyone understanding your problem.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Fri Feb 12, 2010 7:25 pm

Hi many thanks for taking the time and trouble to help, sadly the .cap you uploaded will not run, I get an error message saying that construct.exe has come to an unexpected termination. try to follow this:-
I right click in the event editor and create an event sprite 1 collides with sprite 2 ( dude collides with door)
by right clicking this I can add sub event: is global variable 'keys' Equal to 0
but right click or left click on this I can only find options to delete the event or change/add conditions, there is no way to add the action to make dude bounce

I can add the action bounce or destroy after the event dude collides door, but after the event or sub event is global variable 'keys' Equal to 0 I cannot add an action, only sub events which do not have the option to bounce or destroy.

Hope this is clearer
Brett
B
2
G
2
Posts: 12
Reputation: 674

Post » Fri Feb 12, 2010 7:41 pm

Hi Minor,
Have uploaded the file keydoor.cap to Forums Uploads, onehourcomp,
hope this helps make things clearer

Cheers

Brett
B
2
G
2
Posts: 12
Reputation: 674

Post » Fri Feb 12, 2010 7:52 pm

Since you can't open Minor's file I allowed myself to edit it a little(rename the sprites) and make a screenshot. I hope it helps you.

B
3
G
3
Posts: 33
Reputation: 941

Post » Fri Feb 12, 2010 8:17 pm

Tyrus rules O.K.

Have it working now,

Any idea why I colud not open Minor's file?

Think it may be to do with my version of C++

Anyway many thanks maybe now i can sleep at night.

Cheers

Brett
B
2
G
2
Posts: 12
Reputation: 674

Post » Fri Feb 12, 2010 8:19 pm

[quote="thevolunteer":1u6n7aia]Any idea why I colud not open Minor's file?[/quote:1u6n7aia]

What version of Construct are you using? The most likely reason is that he's using a newer version.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Feb 12, 2010 10:00 pm

My bad - I'm using the latest unstable build 0.99.82.

viewtopic.php?f=2&t=5588

I always forget to mention my version when making a cap
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests