Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Construct 2

You're reading from   Learning Construct 2 Design and create your own engaging, extensible, and addictive game using Construct 2

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781784397678
Length 234 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Aryadi Subagio Aryadi Subagio
Author Profile Icon Aryadi Subagio
Aryadi Subagio
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Learning random generation

I defined random generation at the beginning of this chapter and now I will discuss it in a technical fashion. We will create the obstacles at a random position on the scrolling ground. So, first we will make the ground scroll.

Making the ground scroll

To make the ground scroll, we need to first make it move in one direction at all times; to do this, we need to use a movement behavior. We'll use a behavior that is different from the 8 Direction behavior; to make an object move in one direction, we will use the Bullet behavior. Add this to the ground object, just like we added the 8 Direction behavior to the plane object. It doesn't matter to which of the two instances of the ground object you add the behavior; it will be added to all instances of this object.

Now, the ground will automatically move, so we will make it move in the direction we want it to. First, we will set the Set angle property from the Bullet behavior's property to No because the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image