# [Behavior] Zigzag

### » Sat Nov 19, 2011 12:51 am

Zigzag
(Update: 2013/05/27)

Using LOGO-like script to move/rotate sprite.

Currently, zigzag provides 5 commands.
- Move (F)orward.
(ex: "F 100" means move the spsrite forward 100 pixels.)
- Move (B)ack
- Turn (L)eft
(ex: "L 60" means rotate the spsrite left 60 degrees.)
- Turn (R)ight
- (W)ait
(ex: "W 1" means do nothing, just wait 1 second.)
The format of one command is "F/B/L/R/W #".
ex: "F 100","B 100","L 60","R 60","W 0.5"

You can use a sequence of commands to describe the moving path. ";" is used to join commands. ex: "F 100;R 60"

Zigzag also provides repeat count setting. If repeat count = 0 means repeat infinity.

So combining command sting "F 100;R 60" with repeat infinity, you can image the sprite will move through a hex path repeatly.

Here is an example

- Zigzag uses as moving path of bullet

- Zigzag uses as moving path of platform object

Or, zigzag can be used to describe the moving path of an enemy, or the moving path of laser (combine with step behavior).

Basically, zigzag can wok well without adding any event.
It still has some conditions/actions.
- Condition: On command queue finish
- Condition: On command start
- Condition: On command finish
- Action: Set activated
- Action: Execution start
- Action: Execution stop
- Action: Clean command queue

The different between "Activated" and "Start" is --
"Activated" is more likely to "pause".

You can assign speed at command string by adding "[max,acc,dec]" after a command.
ex: "F 100 [200,0,0]; R 60; F 100 [100,0,0]; R 60"
- F 100 [200,0,0] -> using max speed =200, acc = 0, dec = 0 to execute command "F 100"
- F 100 [100,0,0] -> using max speed =100, acc = 0, dec = 0 to execute command "F 100"

The speed setting is used javascript's "eval" to get the array, so that you can use "[100+100*Math.random(),0,0]" to assign speed.

--
Yes, this is another plugin for lazy guy like me. rexrainbow2013-05-28 09:29:27
B
60
S
13
G
11
Posts: 1,900
Reputation: 14,039

### » Sat Nov 19, 2011 1:38 am

Thankyou for this.

P.S. I'm lazy too.....!tonycrew2011-11-19 01:39:13
B
38
S
12
G
10
Posts: 241
Reputation: 8,588

### » Sat Nov 19, 2011 7:44 am

You've made some pretty awesome contributions to C2, you know that? :D
B
18
S
2
G
2
Posts: 148
Reputation: 1,765

### » Sat Nov 19, 2011 8:24 am

I'm glad that you like it.
B
60
S
13
G
11
Posts: 1,900
Reputation: 14,039

### » Sat Nov 19, 2011 8:37 am

Thanks Rexrainbow this is just what I needed. This ones a great time saver.

I agree you do make some pretty awesome contributions. My Construct 2 plugins, and behaviors folders are full of rex_folders.
B
48
S
8
G
8
Posts: 479
Reputation: 9,465

### » Sat Nov 19, 2011 4:49 pm

very nice sir,

you've pretty much automated enemy patrols for a lot of people.

well done.
B
32
S
7
G
10
Posts: 934
Reputation: 12,660

### » Sat Nov 19, 2011 5:25 pm

Oh, this looks like it could be quite useful for my current project. Well done, man!
B
14
S
2
G
3
Posts: 301
Reputation: 2,693

### » Mon Jan 23, 2012 3:53 pm

Great !
One more time!
Lets Drink a beer to comemorate your presence here!

I love U man! Im reading all of your topics / posts of plugins / behaviors u made!

Thanks again!
B
21
S
1
G
5
Posts: 49
Reputation: 4,575

### » Wed Jan 25, 2012 8:12 am

@jardelbr

If you are using zigzag plugin to create laser, try to combine this plugin with step behavior.
B
60
S
13
G
11
Posts: 1,900
Reputation: 14,039

### » Sat Jan 28, 2012 12:55 pm

@rexrainbow

Good. for now im not using lasers yet, maybe in future;

Thanks again.
B
21
S
1
G
5
Posts: 49
Reputation: 4,575

Next