Quick question on making barriers?

Get help using Construct 2

Post » Thu Mar 22, 2012 3:37 am

I am making a vertical shooter game, the movement is caused by the mouse clicks. I need a way to keep the player from moving too far up on the screen. Bullets and enemies need to be able to pass through the barrier but the player cannot be able to. Any suggestions?
B
7
S
1
Posts: 97
Reputation: 1,167

Post » Thu Mar 22, 2012 4:39 am

The behavior bound to layout.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Thu Mar 22, 2012 5:59 am

That is not what I need. The layout is bigger than what I need the area of movement to be. I just need to have an area that the player cannot leave near the bottom of the screen. But I still need bullets and enemies to be able to pass through it. And also another quick question, how do I make backgrounds invisible on Gimp editor??? Thanks!
B
7
S
1
Posts: 97
Reputation: 1,167

Post » Thu Mar 22, 2012 6:12 pm

Using the Clamp() expression would work well in this situation.
Clamp takes 3 parameters like this: Clamp(value, min, max).

With a window size of 640x480 and no scrolling you can restrict the player to the bottom half of the screen with this:
Every Tick:
--player| set X to Clamp(player.X, 0, 640)
--player| set Y to Clamp(player.Y, 240, 480)

With scrolling change it to this:
Every Tick:
--player| set X to clamp(Mouse.X-ScrollX, -320,320)+ScrollX
--player| set Y to clamp(Mouse.Y-ScrollY, 0,240)+ScrollY

ex:
http://dl.dropbox.com/u/5426011/examples%209/vertical_scroller.capx
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Mar 22, 2012 8:41 pm

Awesome thanks!
B
7
S
1
Posts: 97
Reputation: 1,167


Return to How do I....?

Who is online

Users browsing this forum: Aserak2012, Colorfish and 4 guests