How do I make sprite travel up and down blocks?

Get help using Construct 2

Post » Tue Jun 07, 2016 7:23 pm

I Have these tiles and sprites. The sprites have to traverse these tiles that vary in height, so the sprites have to travel up and down these tiles but I've got no clue how to fully put them over a tile or how I would make them abide next to the tile if they were going down. They could just fall down but the main problem is having them go up, something like a ladder but this is a wall kind of ladder.

Here's an example image of what I mean:

Image

And here's the Capx:

https://www.dropbox.com/s/j9smbimeijc6e ... .capx?dl=0
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Tue Jun 07, 2016 8:11 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Jun 17, 2016 4:05 am



Wow! Thanks but that's not exactly how the sprites should move along the terrain.

Let's see if this clears things up:

Image

The sprite goes straight until it reaches a tiles that is either taller or shorter than the one it's currently on. If it's taller, then the sprite climbs up it to scale it. If it's shorter, then the sprite climbs down it and continues straight until it goes to another tile that is not leveled.
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Sat Jun 18, 2016 6:42 am

bump
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Sat Jun 18, 2016 7:22 am

Will they always be traveling to the right or will they also be going left sometimes as well?

I have an idea how to make it work - and should even work with terrain that's moving up or down, but implementation will be a bit different depending which way the sprites are moving. If always to the right it will be a bit easier, but if they need to go both ways it will be a little more tricky.

Basically you will need an instance variable for each sprite, let's call it "direction". You will then need to set this instance variable to either "up" "down" "left" or "right" (or 1,2,3 or 4) using conditions - then set the movement in the desired direction based on the variable value. You will need a second variable for which *general* direction it's heading (left or right) if the sprites can move both ways. This second variable will act as a secondary condition check.

Pseudo code:
----------------------
[condition]
--- sub event
--- sub event
----------------------

(these vents would handle the "flat" sides of your sprite collision polygon)
[sprite is overlapping terrain at offset.x +1] (or x-1 if moving left)
--- Set Sprite.DirectionVariable to "up"

[sprite is overlapping terrain at offset.y +1]
--- Set Sprite.DirectionVariable to "right" (or left)

[sprite is overlapping terrain at offset.x -1]
--- Set Sprite.DirectionVariable to "down"

(Diagonals would be a little trickier)
[sprite is overlapping terrain at offset.x+1 AND offest.y+1] (upper left corner of your terrain object)
--- Set Sprite.DirectionVariable to "right" (if moving RIGHT, or set to DOWN here if moving LEFT - this is what I meant by it being a bit trickier with multiple directions)

[sprite is overlapping terrain at offset.x-1 AND offest.y+1] (upper right corner)
--- Set Sprite.DirectionVariable to "down" (if moving RIGHT, or set to LEFT here if moving LEFT)

(Then finally the movement itself)
[sprite.DirectionVariable = "up"]
--- Move sprite and angle 270 at speed X (bullet behaviour - customer movement - however you're moving them)

[sprite.DirectionVariable = "right"]
--- Move sprite and angle 0 at speed X

[sprite.DirectionVariable = "down"]
--- Move sprite and angle 90 at speed X

[sprite.DirectionVariable = "left"]
--- Move sprite and angle 180 at speed X

I hope that made sense. I can't make an example right now - but hopefully that helps a little?

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Sat Jun 18, 2016 7:06 pm

SoldjahBoy wrote:Will they always be traveling to the right or will they also be going left sometimes as well?

I have an idea how to make it work - and should even work with terrain that's moving up or down, but implementation will be a bit different depending which way the sprites are moving. If always to the right it will be a bit easier, but if they need to go both ways it will be a little more tricky.

Basically you will need an instance variable for each sprite, let's call it "direction". You will then need to set this instance variable to either "up" "down" "left" or "right" (or 1,2,3 or 4) using conditions - then set the movement in the desired direction based on the variable value. You will need a second variable for which *general* direction it's heading (left or right) if the sprites can move both ways. This second variable will act as a secondary condition check.

Pseudo code:
----------------------
[condition]
--- sub event
--- sub event
----------------------

(these vents would handle the "flat" sides of your sprite collision polygon)
[sprite is overlapping terrain at offset.x +1] (or x-1 if moving left)
--- Set Sprite.DirectionVariable to "up"

[sprite is overlapping terrain at offset.y +1]
--- Set Sprite.DirectionVariable to "right" (or left)

[sprite is overlapping terrain at offset.x -1]
--- Set Sprite.DirectionVariable to "down"

(Diagonals would be a little trickier)
[sprite is overlapping terrain at offset.x+1 AND offest.y+1] (upper left corner of your terrain object)
--- Set Sprite.DirectionVariable to "right" (if moving RIGHT, or set to DOWN here if moving LEFT - this is what I meant by it being a bit trickier with multiple directions)

[sprite is overlapping terrain at offset.x-1 AND offest.y+1] (upper right corner)
--- Set Sprite.DirectionVariable to "down" (if moving RIGHT, or set to LEFT here if moving LEFT)

(Then finally the movement itself)
[sprite.DirectionVariable = "up"]
--- Move sprite and angle 270 at speed X (bullet behaviour - customer movement - however you're moving them)

[sprite.DirectionVariable = "right"]
--- Move sprite and angle 0 at speed X

[sprite.DirectionVariable = "down"]
--- Move sprite and angle 90 at speed X

[sprite.DirectionVariable = "left"]
--- Move sprite and angle 180 at speed X

I hope that made sense. I can't make an example right now - but hopefully that helps a little?

~Sol


@SoldjahBoy, thank you for the text examples but I'm still quite confused on how to go about implementing this. Can you please provide a example? I'm not too good with working with surfaces currently and things on them but I'm really interested in the movement and terrain that the sprites traverse on.

Again, thank you for taking your time to assist me.
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Sun Jun 19, 2016 2:02 am

Yeah I'll see if I can make an example of this a little later today when I get some time. I have a few things on today, but later on I should be able to throw something together :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Tue Jun 21, 2016 9:07 pm

SoldjahBoy wrote:Yeah I'll see if I can make an example of this a little later today when I get some time. I have a few things on today, but later on I should be able to throw something together :)

~Sol

Hey there,

Any luck with an example?
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Post » Wed Jun 22, 2016 3:21 am

Hi Usman, sorry I have been super busy with work. I will make something for you as soon as possible, or I will at least try. I'm not 100% sure my idea will work but I think it should.

*EDIT*
Did you need the sprites to travel left AND right or just one direction only?

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
84
S
34
G
40
Posts: 3,032
Reputation: 30,499

Post » Wed Jun 22, 2016 5:40 am

SoldjahBoy wrote:Hi Usman, sorry I have been super busy with work. I will make something for you as soon as possible, or I will at least try. I'm not 100% sure my idea will work but I think it should.

*EDIT*
Did you need the sprites to travel left AND right or just one direction only?

~Sol


Left and Right.

Thanks for your help, even with being super busy!
Risk Rocket now available on Google Play
Image
B
36
S
15
G
6
Posts: 337
Reputation: 6,300

Next

Return to How do I....?

Who is online

Users browsing this forum: OddConfection and 31 guests