distance counter

Get help using Construct 2

Post » Thu Jun 21, 2012 6:26 pm

Hello friends
in platform game im fly from left to right layout(very long layout- 30 000 pixels ;p width). How do a distance counter?

Regardsdelgado2012-06-21 18:29:24
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Thu Jun 21, 2012 7:26 pm

What is the problem ? 30000 is not a great number for a computer !
You can display the distance in percent XX.XX% as 3 px = 0.01% of total width, ... i don't know your layout "height" but it can more easiest for you to manage the screen display in C2 to cut this layout in 10-20 "rows" to shorter the width and increase the height instead and use scroll system when you reach the right side of the layout "row" to move to left side of row+1.
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Thu Jun 21, 2012 7:49 pm

You can measure the distance between two points with the expression:
"distance(x1, y1, x2, y2)"

At the beginning of your flight have the system to create an Object:Sprite, and when you need to measure the distance, measure it from this Object to your Players hitbox (or similar).

If you've chopped up your layout into seveal wide layout screens as the user above has mentioned. So that your player wraps at X=??? and is repositioned to X=0 at a greated Y value. Then calculate your distance as previously suggested but also add on the layout width multiplied by how many times you've wrapped.
B
85
S
31
G
14
Posts: 106
Reputation: 16,440

Post » Thu Jun 21, 2012 7:58 pm

You don't tell a lot about your game, so I'm not sure if you want the distance from a starting point or the distance travelled, which might be quite different if the player can go back and forth.

Here is an example that uses an 8-direction behavior for the spaceship, but automatically flies to the right by simulating the right control.

For the distance displayed, the spaceship saves off its starting point and then every tick calculates the distance it has gone from the starting point.

LongDistanceFlight.capx
kittiewan2012-06-21 19:58:50
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Thu Jun 21, 2012 8:21 pm

Another thing don't forget you can now load a tiledbackground from url so create or load your levels during the game and not have load all 30000 px full detail background before the game start !. So if you cut your layout in 10 rows there is probably no interest when player is in row 1 to have row 3-10 loaded in memory ! ... you can load row 3 only when player reach row 2 and so on.naelian2012-06-21 20:27:51
B
16
S
5
G
3
Posts: 298
Reputation: 5,240

Post » Thu Jun 21, 2012 8:30 pm



@kittiewan i think your tips are closest to what I need :)delgado2012-06-21 23:14:22
B
94
S
19
G
34
Posts: 1,840
Reputation: 27,988

Post » Thu Jun 21, 2012 9:29 pm

Your welcome, Delgado.

@naelian - Have you tried loading tiled backgrounds on the fly yet? I have a project in mind where it might be useful, but haven't sat down to try it out yet. I could go from having many layouts to just having one endless one. Awesome!
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Fri Jun 22, 2012 5:05 am

@kittiewan Yes i used it in my Compan360 project ... i ref the 7mb 360 tiledbackground from Ockley in project using the import features, and then i loaded it in runtime from local project dir with "./tlbg.png". . So for a big adventure game with 100-200 scenes you can keep in memory only the scene where the player can go in one or two "moves" and not load all the 200 scenes before the project start !

naelian2012-06-22 05:24:09
B
16
S
5
G
3
Posts: 298
Reputation: 5,240


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, plinkie and 20 guests