tips and kliks

Danni's picture

Tips and Kliks #03: Important Conditions

In order to make sense of how and when conditions are true and to use them to create the behaviors you want, it's good to know some of the most important ones. You'll find these under either the "Special" or "Storyboard Controls" categories when you go to create a new condition.

Always and Never

The simplest conditions are the ones that are either simply true or false: Always is always true, and Never is always false.

Always is extremely important as you need it for actions which should happen continuously. For example, you might always want the screen to scroll with your player character, or you might have a turret that should always point at its target. If you have your own custom movement system you might also want to keep objects moving. These are just a few examples of things which you would want to "always" happen, and for which using the "Always" condition is basically a requirement.

Note that Always only makes sense if you aren't placing it in an event with other conditions. In such cases, Always is unnecessary, because actions will repeat for as long as the conditions are true anyway.

Never is essentially the opposite of Always. Since Never is always false, and an event requires all its conditions to be true before it runs the actions, you might be wondering how the heck Never would ever be useful. Its use is not in running actions, but not running actions. More specifically, you can use Never to disable events for debugging purposes.

Start of frame/Start of level

"Start of frame" is only ever true once: at the very beginning of your level. Therefore, you can use it to perform any kind of setup you need. Common uses include playing music, making certain objects invisible (if you're on something older than MMF2), creating and/or positioning objects according to a set of rules, etc.

Only one action when event loops

An event's actions will keep happening every step of your game as long as the conditions are true, but what if you don't want that to happen? You add "Only one action when event loops" to the event. This condition is only true if the event's conditions were not true in the previous step.

Let's say you are making an arcade game where the player gets an extra life after reaching 50,000 points. Your first attempt at the conditions might look like this:

However, doing this will cause the game to flood the player with a constant stream of extra lives! Not what you want. Now let's add "Only one action when event loops":

This rewards the player with an extra life just once after obtaining enough points.

I should note that if the player's score somehow falls below 50,000 again, the player will become eligible for another extra life. If this isn't what you want, use "Run this event once" instead of "Only one action when event loops".

Danni's picture

Tips and Kliks #02: Anatomy of an Event

We will start off by jumping straight into the Event Editor, as that is the heart of Klik's true power, the place where you will spend most of your time designing your game's behaviors. For these next few articles, we will cover the basics you need to know to get the most out of the Event Editor.

In order to become a Klik Ace, you need ACE: Actions, Conditions, and Events. In the Event Editor, these are the building blocks that you use to describe your object behaviors. Understanding the role of each is key to understanding the Event Editor.

Actions are simply things that you can do in your game. Some examples of actions:

- Stop
- Destroy
- Create a new object
- Change animation sequence
- Add to the player's score
- Jump to the next level/frame

Conditions are bits of criteria. Some examples of conditions:

- Start of frame/start of level
- Player pressed Fire 1
- Two objects are overlapping each other
- An object is below a certain Y coordinate
- An animation has finished

Events are units that contain a set of Actions and Conditions. If the conditions for a given event are satisfied, the actions are performed.

Pictured: An event that causes the player to fire a bullet when pressing button 1, as long as there are less than three bullets in play.

Note that conditions actually have two functions. First, a condition may either be true or false. For example, if the player is holding button 1, then the condition "Repeat while Player pressed Fire 1" would be true. If the player's score is only 1000, then the condition "Player's score is greater than 2000" would be false.

An event's actions are only run if all of its conditions are true!

Second, a condition may limit which object(s) an action is applied to. Let's say you have an event with one condition: "Player pressed Fire 1". If we give this event a "Destroy Monster" action, it will destroy every single Monster in the level when you press button 1.

What if we replace that condition with "Collision between Bullet and Monster"? We will keep the "Destroy Monster" action. This time, when the condition is true, only the Monsters that have collided with any Bullets will be destroyed.

Typically, conditions serve to eliminate possible objects. That is, you use conditions to only apply actions to certain objects, and each additional limiting condition further reduces which objects targeted by the actions. There are exceptions, of course. Take the "Pick an object at random" condition. Its first use will eliminate all objects of a given type except for one that has been chosen at random. What happens if you add multiple copies of this condition? Now the actions apply to more objects! If you have "Pick an object at random" three times in an event, three objects will be picked (assuming there are three - if there are less than three, only that many will be picked).

Feel free to play around with different conditions and actions! Next, we will be covering the use of a few specific basic but important conditions.

Danni's picture

Tips and Kliks #01: A Note on the Step-thru Editor

I will start off by saying that Tips and Kliks is mostly intended to be aimed at novice to intermediate Klikkers. Tutorials for absolute beginners are important, but this is not one of them. We do have a good beginner's tutorial on this site already - see the Learning KNP FAQ.

I'd like to take the time to mention the Step-thru Editor because it's a novel concept, and also an important one - I was using it before I even touched the Event Editor.

When you use the Step-thru Editor, your game will run until certain things happen, and then pause to bring up a dialog asking you what to do next, like this:

You'll see a row of icons. By clicking on one of these, you can select an action you want the game to take in response.

The capabilities of the Step-thru Editor are rather limited, especially when it comes to the number of conditions you can write actions for:

- An object leaves or enters the playfield on the left, right, top, or bottom edge.
- An object collides with another object.
- An object collides with the background.
- All objects of one type are destroyed.
- A player presses one of the fire buttons.
- A player loses all of their lives.
- A certain amount of time has passed (accessed by pressing the Esc key).

Additionally, if you are using Klik & Play, you may only perform actions on the object(s) that triggered the event in question, and you are limited to these four actions:

- Bounce
- Wrap around playfield
- Shoot another object
- Destroy

I don't think these limitations are necessarily a bad thing. Because only a small number of the available conditions and actions are exposed, it is much easier for new users to grasp the basics of how the program works. Of course, you can't do anything advanced with this, but that's not really the point - the Event Editor covers those bases.

Because these Tips and Kliks will mostly focus on working within the Event Editor, I would strongly suggest you tinker around with the Step-thru Editor first if you're still unfamiliar with Klik. Otherwise you won't find these articles very useful.

And have fun with Step-thru! I know I did!

(Note: The Step-thru Editor was removed since MMF2.)

Danni's picture

Tips and Kliks: Introduction

Hi, all! Now that I've finished my Secret Santa game and the new year is fast approaching, I would like to announce a new series of tutorials and articles called "Tips and Kliks". I've seen quite a few people here picking up on Klik tools lately, and I think that's great! These tools actually have a lot to offer - even Klik & Play is more powerful than it seems at first glance!

Why am I doing this series? After all I've kind of sworn off of Klik and I can write code in Lua, Java, C++! Well, before I was using any traditional programming language I used Klik for all my games (and a few "apps"). Using Klik to try out new gameplay ideas helped me gain familiarity with programming, and working around limitations by writing my own behaviors trained me to think critically. It is my hope that with this series I can help others do the same.

I plan to do a new article twice a week. I most likely won't provide game files for these articles (unless it's requested), because everyone is on different tools and sometimes things change between programs. I will provide plenty of images, however, and if you need help feel free to ask.

Scope

Focus will mainly be on the earlier Klik products (KnP/TGF1), but applicable to the later programs.

- (Re)familiarization with Klik basics (objects, built-in movements, editors, etc.)
- Basics of creating your own behaviors
- Some applications of custom behaviors, such as custom movements
- Other tips and tricks

Syndicate content