Construct 2 Tutorialshttps://c2tutorials.wordpress.com
Construct 2 Tutorials & ExamplesThu, 24 May 2018 17:32:24 +0000enhourly1http://wordpress.com/https://s0.wp.com/i/buttonw-com.pngConstruct 2 Tutorialshttps://c2tutorials.wordpress.com
Dead Linkshttps://c2tutorials.wordpress.com/2017/07/21/dead-links/
https://c2tutorials.wordpress.com/2017/07/21/dead-links/#respondFri, 21 Jul 2017 15:08:06 +0000http://c2tutorials.wordpress.com/?p=153Continue reading Dead Links→]]>As you can see there hasn’t been any updates on the site for ages. All the previews and example links are completely dead. So I’ve zipped together all the examples that you can find on here into one zip file.

]]>https://c2tutorials.wordpress.com/2017/07/21/dead-links/feed/0minor78Point Towards Position On 2 Different Layershttps://c2tutorials.wordpress.com/2014/11/24/point-towards-position-on-2-different-layers/
https://c2tutorials.wordpress.com/2014/11/24/point-towards-position-on-2-different-layers/#commentsMon, 24 Nov 2014 11:39:04 +0000http://c2tutorials.wordpress.com/?p=150Made for a user on the forums this example shows how to make an arrow point towards another object. While this may seem pretty trivial the two objects are on 2 different layers with 2 different parallax settings.

The example makes use of the System Expressions LayerToCanvasX and LayerToCanvasY.

]]>https://c2tutorials.wordpress.com/2014/11/24/point-towards-position-on-2-different-layers/feed/2minor78Xbox Controller: Platform Shooter Right Stick Mouse Aimhttps://c2tutorials.wordpress.com/2014/11/23/xbox-controller-platform-shooter-right-stick-mouse-aim/
https://c2tutorials.wordpress.com/2014/11/23/xbox-controller-platform-shooter-right-stick-mouse-aim/#commentsSun, 23 Nov 2014 13:17:17 +0000http://c2tutorials.wordpress.com/?p=148A quick example for a user on the forums. In this example the movement of a platform character is controller by the left stick while the right stick is used to aim (like mouse aim). The character will always face in the direction of aiming.

]]>https://c2tutorials.wordpress.com/2014/11/23/xbox-controller-platform-shooter-right-stick-mouse-aim/feed/1minor78Array: Copy Values From One Array To Another – No Repeathttps://c2tutorials.wordpress.com/2014/11/17/array-copy-values-from-one-array-to-another-no-repeat/
https://c2tutorials.wordpress.com/2014/11/17/array-copy-values-from-one-array-to-another-no-repeat/#respondMon, 17 Nov 2014 21:41:48 +0000http://c2tutorials.wordpress.com/?p=144Created for a user on the forums but never actually posted because I was ninja’d.

This example has an array of names, each time space bar is pressed, a random name is chosen and moved to a new array. That name is then removed from the original array so the names are never repeated.

]]>https://c2tutorials.wordpress.com/2014/11/17/array-copy-values-from-one-array-to-another-no-repeat/feed/0minor78Array: Count Number Of Times A Value Appearshttps://c2tutorials.wordpress.com/2014/11/12/array-count-number-of-times-a-value-appears/
https://c2tutorials.wordpress.com/2014/11/12/array-count-number-of-times-a-value-appears/#respondWed, 12 Nov 2014 13:06:50 +0000http://c2tutorials.wordpress.com/?p=139Here’s a quick example of counting how many times a certain value appears in an Array. Made for a user on the forums it counts the number of times “dog” and “cat” appears in the array and can easily be expanded to check for more values or different values depending on your project.

]]>https://c2tutorials.wordpress.com/2014/11/12/array-count-number-of-times-a-value-appears/feed/0minor78Mario Style Coinboxhttps://c2tutorials.wordpress.com/2014/11/10/mario-style-coinbox/
https://c2tutorials.wordpress.com/2014/11/10/mario-style-coinbox/#commentsMon, 10 Nov 2014 10:49:51 +0000http://c2tutorials.wordpress.com/?p=136Here’s a basic example of a Mario style coinbox. This is the type of box that you’d jump at from underneath and bump your head on and a coin comes out of the top.

]]>https://c2tutorials.wordpress.com/2014/11/10/mario-style-coinbox/feed/1minor78Let’s Look At: Random Numbershttps://c2tutorials.wordpress.com/2014/10/26/lets-look-at-random-numbers/
https://c2tutorials.wordpress.com/2014/10/26/lets-look-at-random-numbers/#commentsSun, 26 Oct 2014 20:32:58 +0000http://c2tutorials.wordpress.com/?p=114Continue reading Let’s Look At: Random Numbers→]]>This is something a little different from my usual examples. I’m going to take you through Construct 2’s random number expressions, how they work and how we can manipulate them to our advantage when creating a game.

Click below to read the whole post.

Firstly lets look at C2’s random number expressions, then later, we’ll look at how we can manipulate them for our needs.

Random(X) – This is the most basic random expression in C2. To use this we simply replace the “X” in the brackets with a number. C2 will then generate a random number between 0 & “X” but not including “X”.

So what does that mean?

Well let’s replace “X” with 10. Our expression is now random(10). C2 will now generate a random number between 0 & 10 but not including 10. Another thing to note is that the number generated will be a float or in simpler terms a decimal number.

Random(a,b) – This expression now lets us generate a random number between a & b but not including b.

Again let’s look in a little more detail. Lets replace a with 10 and b with 20. Our expression is now random(10,20). C2 will now generate a number between 10 & 20 but not including 20. Again the number generated will be a float.

Here are 10 random numbers that I generated in C2 using random(10,20).

Before looking at the third way of generating random numbers let’s take a look at how we can manipulate the numbers generated using random(X) and random(a,b).

It’s not very often that a project will require a randomly generated number with 10 decimal places, usually what we’d want was whole numbers (integers). C2 has three expressions that easily allow us to convert a float into an integer, it’s just a matter of picking the correct one for our needs.

Floor() – Will round down a float to the nearest integer. For example floor(5.6) would round down to 5.

Round() – Will round up or down to the nearest integer. For example round(5.6) would round up to 6, while round(5.3) would round down to 5.

Ceil() – Will round up to the nearest integer. For example ceil(5.2) would round up to 6.

Let’s use one of our new expressions and add it to random(10) to create some more random numbers . Here are 10 numbers generated using ceil(random(10)).

6, 7, 2, 2, 10, 3, 8, 6, 5, 6

Excellent! Gone are our 10 digit decimal floats and we end up with some nice integers.

But this has given us a problem!

Remember from earlier we learned that random(10) generates a number from 0 & 10 but NOT including 10. If you look at the list of numbers you’ll see that 10 is included in the list.

Why is this?

It’s simply down to our rounding method. Random(10) still generates a number between 0 & 10 not including 10 but we are rounding that number up. So if random(10) generates 9.0094645182 and we use ceil() to round up. Our interger will become 10.

Just keep in mind when using floor(), round() and ceil() how they’ll effect the numbers generated for your project.

Now let’s say that you want your generated number to be to 2 decimal places. C2 doesn’t have any built in expressions to do this, but using a tiny bit of Math you can convert your 10 decimal place float to a 2 decimal place float. You do that by using the following round(yourvalue*100)/100 and simply replace yourvalue with the number you wish to covert.

You can do this for any number of decimal places by using this formula as the number of 0’s represents the number of decimals. For example round((random(10))*10000)/10000 will round the decimals to 4 decimal places.

As you can see from the numbers above if we killed 100 monsters we would only get 3 rare item drops.

And that’s the basics of random numbers. I hope you find it useful. If you do please leave a rating for the post and I’ll create more of these types of posts.

]]>https://c2tutorials.wordpress.com/2014/10/26/lets-look-at-random-numbers/feed/3minor788 Direction Movement With Gamepad – Twin Stick Versionhttps://c2tutorials.wordpress.com/2014/10/15/8-direction-movement-with-gamepad-twin-stick-version/
https://c2tutorials.wordpress.com/2014/10/15/8-direction-movement-with-gamepad-twin-stick-version/#respondWed, 15 Oct 2014 13:14:44 +0000http://c2tutorials.wordpress.com/?p=111Continue reading 8 Direction Movement With Gamepad – Twin Stick Version→]]>While working on a personal project I was thinking about the control scheme. It was going to be an 8 Directional shooter with Twin Stick controls. I came up with 2 versions so I though I’d share them here.

The example has 2 groups that hold the events. Simply activate one and deactivate the other to try each version.

Type 1 – You move with left stick but always face the direction the right stick is/was held in.

Type 2 – This is my preferred version. You can move with left stick and you always face the direction of movement until you use the right stick when you’ll face in the right stick direction but move in any direction.

]]>https://c2tutorials.wordpress.com/2014/10/15/8-direction-movement-with-gamepad-twin-stick-version/feed/0minor78Detect Sword Hits With Image Pointshttps://c2tutorials.wordpress.com/2014/10/13/detect-sword-hits-with-image-points/
https://c2tutorials.wordpress.com/2014/10/13/detect-sword-hits-with-image-points/#respondMon, 13 Oct 2014 22:24:06 +0000http://c2tutorials.wordpress.com/?p=108Continue reading Detect Sword Hits With Image Points→]]>Another older example that I never posted here. Created for a user on the forums it shows how you can use image points rather than detector sprites for detecting sword hits on an enemy. This is useful if you use sword swing animations rather than a sword object in your game. It can of course be used in other situations.

]]>https://c2tutorials.wordpress.com/2014/10/13/detect-sword-hits-with-image-points/feed/0minor788 Direction Movement With Gamepadhttps://c2tutorials.wordpress.com/2014/10/13/8-direction-movement-with-gamepad/
https://c2tutorials.wordpress.com/2014/10/13/8-direction-movement-with-gamepad/#respondMon, 13 Oct 2014 13:33:50 +0000http://c2tutorials.wordpress.com/?p=105Continue reading 8 Direction Movement With Gamepad→]]>Realised I hadn’t posted this. So here it is. Created for a user on the forums this is an example of 8 direction movement using the left thumbstick on a Gamepad. The user was creating multiple conflicting actions where as this example uses only 4 actions.