Is there a clever way to program this?

Get help using Construct 2

Post » Thu Jan 03, 2013 8:30 pm

After burning my brain a little bit I finally got some good results with my code.

To give you guys a context:

The player must collect the "eggs" that are at the screen. When the player touches an egg, it starts following the player.

Touching a second egg, it follows the first egg, the third follows the second, etc.


But I feel that there is a way to do some refactoring to the "Follow Player" part, but I have no idea how to do it. So I'm here to ask you guys, what can I do to improve it?

The code, so far:



Here's the demo: http://dl.dropbox.com/u/12937330/follow_test/index.html



Thanks in advance!


B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Thu Jan 03, 2013 9:04 pm

I tried this last time you posted, but the result was kind of wonky.

Not perfect this time around either, but definitely better than last time:
EggFollow.capx (r114)Nimtrix2013-01-03 21:04:59
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jan 03, 2013 9:57 pm

Yeah, the eggs are going too smoothly, it's weird. I don't have any ideas on how to solve this matter. Is there any other thing that you noticed?


Just saw your .capx, thanks for your time man. =)

It works nice for a top-down view, as you suggested with your, but my game is a side scroller.

Regardless, now I can see clearly how I could simplify the "following" code! Thanks a lot for the tip!



B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Thu Jan 03, 2013 10:17 pm

Here's one example of followers in a platformer. It saves the players position to a queue and positions the first follower to say 10 positions ago, the second 20 and so forth.

http://www.scirra.com/forum/eek-slowdown_topic46528.htmlR0J0hound2013-01-03 22:18:13
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Fri Jan 04, 2013 9:09 am

Thanks man, that is exactly what I want to do!

Already got the .capx, I'll try to study it.
B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Sun Jan 06, 2013 3:52 am

Thanks H0j0hound, took a good look on what you did on that .capx and adapted it to my game. It worked like a charm! But it's ok to use a code based on what you made?
B
12
S
6
G
3
Posts: 100
Reputation: 3,836

Post » Sun Jan 06, 2013 7:10 pm

Certainly, you can use it. Most, if not all of the capx I post are free to use.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Colorfish, zenox98 and 27 guests